Get detailed font metrics

Open Beginner friendly
#1,512 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
62/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Stale
Tech stack
javascript

Research direction

Read pdfkit/lib/mixins/fonts.js, starting after currentLineHeight(includeGap). Confirm how the current font and font size are represented, then add the requested font metric getters. Done means the five metrics are available through getters and are scaled consistently with the current font size.

Written by the indexing model from the issue text.

Description

Feature Request

Feature description

I would like to have more font metric information to render initials, etc. in form of a few getter functions.

The new methods should be placed after the currentLineHeight(includeGap) method in the pdfkit/lib/mixins/fonts.js file.

I already use them locally:

currentFontAscender() { return (this._font.ascender) / 1000 * this._fontSize; },
currentFontDescender() { return (this._font.descender) / 1000 * this._fontSize; },
currentFontLineGap() { return (this._font.lineGap) / 1000 * this._fontSize; },
currentFontXHeight() { return (this._font.xHeight) / 1000 * this._fontSize; },
currentFontCapHeight() { return (this._font.capHeight) / 1000 * this._fontSize; },
Dominant language
JavaScript
Stars
10.7k
Forks
1.2k
Avg merge
1d 13h
Merged PRs (30d)
18

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from foliojs/pdfkit

All issues in foliojs/pdfkit

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.