hinting-diff
Compare the TrueType hinting of two versions of a font in a browser.
hinting-diff writes an HTML page that shows every glyph of a font, encoded or
not, rendered with its hinting at a size in pixels per em (ppem), for the old
and the new version of the font. Click old/new to switch between them
and see what changed.
Source Sans Pro without hinting (old) and hinted with ttfautohint (new), in Firefox on Windows 11, enlarged 3×.
Browsers only apply TrueType hinting on Windows, so open the page on Windows. It works in old browsers too, as far back as Internet Explorer 11, Chrome 49 and Firefox 52, for checking hinting on old versions of Windows.
Install
pip install hinting-diff
It needs Python 3.10 or later, and installs fontTools too.
Usage
hinting-diff old/Family-Regular.ttf new/Family-Regular.ttf -o hinting-diff/
This writes hinting-diff/Family-Regular-hinting.html, with copies of both
fonts next to it, and prints the page's path. Open it in a browser on Windows.
The output folder is optional, and is hinting-diff by default. All the
options:
usage: hinting-diff [-h] [-o OUTPUT] [--version] before after
Write a page to compare the TrueType hinting of two versions of a font.
Browsers only apply TrueType hinting on Windows, so open the page on Windows.
positional arguments:
before the old font (TTF)
after the new font (TTF)
options:
-h, --help show this help message and exit
-o OUTPUT, --output OUTPUT
folder for the page and copies of the fonts (default:
hinting-diff)
--version show program's version number and exit
The page has:
- Sample text, which starts as every character the new font encodes (without combining marks or spaces), for a quick look over the whole character set. You can edit it.
- Every glyph, at the Font Size you choose (48 ppem to start with). Hover over a glyph to see its name, or filter the glyphs by name. Glyphs that are only in one of the fonts say so.
- A waterfall of a glyph from 8 to 64 ppem: click a glyph to show it.
- For variable fonts, an Instance menu with the font's named instances.
The size, font, filter, selected glyph and edited text are kept for the browser tab's session, so they stay the same when you open another font's page in the same tab.
Sizes are in device pixels, so they stay the same with browser zoom or display scaling (e.g. 150% in Windows), which change how many device pixels a CSS pixel is.
Showing the page in a report
A page that shows the hinting page in a frame can pick a variable font's
instance by adding its name to the URL, e.g.
Family-Regular-hinting.html#style=Bold. This hides the page's own
Instance menu.
Python API
Everything the command does is available from Python too, e.g. to make hinting pages as part of a bigger report.
Writing a page
write_hinting_page() does the same as the hinting-diff command:
from pathlib import Path
from hinting_diff import write_hinting_page
page_path = write_hinting_page(
Path("old/Family-Regular.ttf"),
Path("new/Family-Regular.ttf"),
Path("hinting-diff"),
)
print(page_path) # hinting-diff/Family-Regular-hinting.html
Its arguments are:
before_path: the old font (TTF).after_path: the new font (TTF).output_path: the folder for the page and the copies of the fonts. It's made if it doesn't exist yet.page_name(optional): the page's file name. By default, it's the new font's name with-hinting.html, e.g.Family-Regular-hinting.html.
It returns the page's path. The copies of the fonts are saved next to the page as
hinting-old-<new font's file name> and hinting-new-<new font's file name>, so
pages for several fonts can share a folder:
from pathlib import Path
from hinting_diff import write_hinting_page
for after_path in sorted(Path("new").glob("*.ttf")):
before_path = Path("old", after_path.name)
if before_path.is_file():
write_hinting_page(before_path, after_path, Path("hinting-diff"))
Unlike the command, it doesn't check that the fonts exist first: a missing or
broken font raises fontTools' or Python's own error (e.g. FileNotFoundError),
and a font with too many glyphs to map to Private Use Area codepoints raises a
ValueError.
Lower-level functions
The functions the page is made with can be used on their own:
add_glyph_codepoints(font_path, output_path)saves a copy of a font with each glyph mapped to a Private Use Area codepoint (see How it works), and returns adictof each glyph's name and codepoint..notdefisn't mapped.get_sample_text(font)returns every character aTTFontencodes, in codepoint order, without combining marks or characters that show nothing.get_named_instances(font)returns a variableTTFont's named instances as a list of(name, coordinates), e.g.("Bold", {"wght": 700.0}). It returns an empty list for a static font.GLYPH_CODEPOINT_STARTis the codepoint the first glyph is mapped to (0xF0000). A glyph's codepoint is this plus its glyph ID.
from pathlib import Path
from fontTools.ttLib import TTFont
from hinting_diff import add_glyph_codepoints, get_named_instances
codepoints = add_glyph_codepoints(
Path("new/Family-Regular.ttf"), Path("Family-Regular-pua.ttf")
)
print(f"U+{codepoints['a']:X}") # e.g. U+F0024
with TTFont("new/Family-Regular.ttf", lazy=True) as font:
for name, coordinates in get_named_instances(font):
print(name, coordinates)
hinting_diff.__version__ is the package's version.
How it works
Browsers can only show characters, not glyphs, so the fonts on the page are
copies with each glyph mapped to a Private Use Area codepoint, from U+F0000.
Only their cmap table changes: the other tables, including glyf, fpgm,
prep and cvt , are saved as they are, so the hinting is kept. Glyphs that a
variable font swaps with feature variations (rvrn) at the selected instance
show the swapped glyph, as they would in use.
Contributing
Bug reports, ideas and pull requests are welcome: see the contributing guide for how to set up the project and make a change. Please report security problems privately, as the security policy explains.
Licence
Metadata
Release files for hinting-diff 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hinting_diff-0.1.1.tar.gz | 22.4 kB | With provenance | Details for hinting_diff-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hinting_diff-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for hinting_diff-0.1.1-py3-none-any.whl |
Total release size: 40.0 kB
Release files / hinting_diff-0.1.1.tar.gz
| Download URL | hinting_diff-0.1.1.tar.gz |
|---|---|
| Size | 22.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
20174f88735afd20e4c4e0db1249fd27bbc56e4a85b8cfd6719b878b679db06e
|
|
BLAKE2b-256 checksum How to use checksums |
c5056347d8b0a18ce1a7b51e0c28a29f509b5c6b07d9ff116d4edaaf38283508
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logRelease files / hinting_diff-0.1.1-py3-none-any.whl
| Download URL | hinting_diff-0.1.1-py3-none-any.whl |
|---|---|
| Size | 17.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f9671a58d55a594f10d93b8c9d24438ac43d201ceaced38dc0e0ce998c4cf5c3
|
|
BLAKE2b-256 checksum How to use checksums |
16a6cb71252f73b9e1b5b66d2a2b8c5fc60b2912e54153a23c9ccbf52692c2df
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logSecurity for hinting-diff 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for hinting_diff-0.1.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 23, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.