| Crates.io | fontheight |
| lib.rs | fontheight |
| version | 0.1.7 |
| created_at | 2025-08-21 10:24:30.836034+00 |
| updated_at | 2025-09-17 09:24:03.374106+00 |
| description | Find out the vertical extents your font reaches on shaped words |
| homepage | |
| repository | https://github.com/googlefonts/fontheight |
| max_upload_size | |
| id | 1804552 |
| size | 74,256 |
fontheight is a tool that provides recommendations on setting font vertical metrics based on shaped words.
Vertical metrics frequently decide clipping boundaries, but are not used consistently across platforms: e.g. Windows uses OS/2 WinAscent/WinDescent, whereas for system fonts Android uses TypoAscent/TypoDescent and a combination of custom heuristics.
It is often desirable to derive metrics from shaped words as opposed to individual glyphs, as words may reach greater extents:
Early versions of this specification suggested that the usWinAscent value be computed as the yMax for all characters in the Windows “ANSI” character set. For new fonts, the value should be determined based on the primary languages the font is designed to support, and should take into consideration additional height that could be required to accommodate tall glyphs or mark positioning.
⬆️ OS/2 — OS/2 and Windows Metrics Table, OpenType Specification 1.9.1
For this reason, vertical metrics must be chosen with a combination of design (e.g. aesthetic, legibility) and engineering (e.g. clipping) considerations in mind.
For the latter, fontheight evaluates the extents of a corpus of shaped text across each writing system that a font intends to support.
Fontheight comes in three flavours:
fontheight as a commandline toolCurrently, both installation methods involve compiling fontheight from its source code, meaning you need to have a Rust toolchain installed and cargo available in your terminal.
If you're new to Rust, check out https://www.rust-lang.org/tools/install for instructions on getting it installed and configured.
You only need a stable compiler for Font Height's crates.
From GitHub:
STATIC_LANG_WORD_LISTS_LOCAL=1 cargo install --locked --git https://github.com/googlefonts/fontheight fontheight-cli
From crates.io (note: the build script for static-lang-word-lists requires network access, see its README for why):
cargo install --locked fontheight-cli
Note: after installing, the command you run is fontheight (not fontheight-cli).
Usage: fontheight [OPTIONS] [FONT_PATH]...
Arguments:
[FONT_PATH]... The TTF(s) to analyze
Options:
-n, --results <RESULTS> The number of words to log [default: 5]
-k, --words <WORDS_PER_LIST> The number of words from each list to test [default: 25]
-h, --help Print help
-V, --version Print version
Most of the word list shipped with fontheight are sorted by greatest vertical extremes to try and help reduce the number of words which need to be checked to produce a useful report.
However, not all word lists have been sorted at this time, and so for greater reliability you may wish to use a greater value for --words, or use ⚠️ Not yet available --all.
Sorted DiffenatorAdlam based on:
Sorted DiffenatorArabic based on:
Sorted DiffenatorArmenian based on:
Sorted DiffenatorAvestan based on:
Sorted DiffenatorBengali based on:
Sorted DiffenatorCanadian_Aboriginal based on:
Sorted DiffenatorChakma based on:
Sorted DiffenatorCherokee based on:
Sorted DiffenatorCommon based on:
Sorted DiffenatorCyrillic based on:
Sorted DiffenatorDevanagari based on:
Sorted DiffenatorEthiopic based on:
Sorted DiffenatorGreek based on:
Sorted DiffenatorGujarati based on:
Sorted DiffenatorGurmukhi based on:
Sorted DiffenatorHebrew based on:
Sorted DiffenatorKhmer based on:
Sorted DiffenatorLao based on:
Sorted DiffenatorLatin based on:
Sorted DiffenatorLisu based on:
Sorted DiffenatorMalayalam based on:
Sorted DiffenatorMongolian based on:
Sorted DiffenatorMyanmar based on:
Sorted DiffenatorOl_Chiki based on:
Sorted DiffenatorOriya based on:
Sorted DiffenatorOsage based on:
Sorted DiffenatorSinhala based on:
Sorted DiffenatorSyriac based on:
Sorted DiffenatorTamil based on:
Sorted DiffenatorTelugu based on:
Sorted DiffenatorThai based on:
Sorted DiffenatorTibetan based on:
Sorted DiffenatorVai based on:
fontheight's Python API⚠️ Not yet available
The API will be available under the package fontheight.
See the method signatures & data types below, approximately written in Python. k_words is equivalent to --words in the CLI, and n_exemplars is equivalent to -n/--results.
import fontheight
# Entrypoints
fontheight.get_min_max_extremes_from(path: os.pathLike, k_words: int, n_exemplars: int) -> list[fontheight.Report]
fontheight.get_min_max_extremes(font_bytes: bytes, k_words: int, n_exemplars: int) -> list[fontheight.Report]
# Returned data types
@dataclass(frozen=True)
class fontheight.Report:
location: dict[str, float]
word_list_name: str
exemplars: fontheight.Exemplars
@dataclass(frozen=True)
class fontheight.Exemplars:
lowest: list[fontheight.WordExtremes] # sorted, lowest lows first
highest: list[fontheight.WordExtremes] # sorted, highest highs first
@dataclass(frozen=True)
class fontheight.WordExtremes:
word: str
lowest: float
highest: float
fontheight's Rust crateOn crates.io as fontheight.
For documentation, please refer to docs.rs.