• Stars
    star
    135
  • Rank 268,046 (Top 6 %)
  • Language
    C++
  • License
    Other
  • Created over 8 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

tool for finding visual differences between two font versions

Build Status

fontdiff

fontdiff is a utility for testing fonts. When you modify a TrueType or OpenType font, fontdiff generates a PDF showing the typeset text both before and after the change. You can use this PDF to easily review the changes and spot any errors caused by a font switch.

For every line in the text sample, the tool renders two raster images in high resolution. One image is typeset using the original font, and the second uses the new font. If there is any difference between these two high-resolution images (even if it’s just whitespace caused by kerning changes), the output PDF highlights the difference in color.

Screenshot

Since fontdiff is using HarfBuzz for OpenType shaping, text gets rendered in a similar way across Firefox, Chrome, Android, LibreOffice, XeTeX, GNOME, KDE, ChromeOS, and other products.

Sample text

To provide sample text, use HTML with embedded CSS styling:

<html lang="la">
  <p>Lorem <span style="font-weight:700">ipsum</span> dolor sit amet.</p>
</html>

The lang tag can make a difference for rendering. For example, when diffing a font with Polish letter forms, you can write <span lang="pl">ćńóśź</span> to see the Polish variants of accented letters, or <span lang="und">ćńóśź</span> to see the default design. As with HTML, you can combine spans in multiple languages into the same document. fontdiff recognizes the same language tags as modern web browsers; “und” is the “undefined” or default language.

Limitations

This is not an official Google product. We needed a lightweight tool to test our font production pipeline, so we built fontdiff, and we hope you’ll find it useful, too. However, please understand that there are some limitations:

  • Not a full renderer: HTML and CSS are much richer than what this little testing tool supports. If you miss something, please do not hesitate to make the change yourself and send a pull request.

  • Lousy codebase: The current state of the codebase isn’t something we’d be proud to call production-ready: no tests, too many dependencies, and so on. fontdiff isn’t a “real” product, and definitely not a showcase for writing production code.

  • Not secure: Do not run this tool on untrusted input. It parses complicated input formats (TrueType, OpenType, HTML) but it isn’t hardened in any way. Use it at your own risk.

  • Not a sample generator: This tool compares how an existing sample text gets rendered in two versions of the same font. However, it won’t find text for you to render. Some font designers may want to manually craft samples. Others may want to see how an entire volume of text is rendered, or check the output of a font-affecting tool or script. Because the use cases for fontdiff are wildly different, we felt it would be best to limit its scope to the actual diffing operation.

Building

$ git clone --recursive https://github.com/googlefonts/fontdiff.git
$ cd fontdiff
$ ./src/third_party/gyp/gyp -f make --depth . --generator-output build src/fontdiff/fontdiff.gyp
$ make --directory build
$ build/out/Default/fontdiff \
    --before path/to/old/FooFont*.ttf \
    --after path/to/new/FooFont*.ttf \
    --specimen src/fontdiff/specimen.html \
    --out out.pdf

This incantation works on reasonably recent versions of Linux and MacOS X. If you want to support other platforms, feel free to make the change. Pull requests are very welcome!

Contributing

Here are a few features and concepts we’d love your help implementing, if you’re bored and/or want to get your hands dirty (or are just a magnanimous person who loves fontdiff):

  • Port to other platforms. This should be a very easy starter task for people familiar with the respective platforms. It shouldn’t take more than a few hours, since the project already uses cross-platform libraries and a cross-platform build system.

  • Testing. Currently, the codebase is entirely untested, which makes it hard to maintain the code.

  • More constructs from CSS and HTML.

  • MathML. With (even limited) support for MathML rendering, font designers could use fontdiff to test their mathematical fonts.

  • Sandboxing. To protect users against attacks that use malicious font or text sample files, set up a sandbox early in the tool’s execution and then do all the rendering inside the sandbox.

  • CSS box model. It might be nice to properly support the layout of CSS and HTML, where boxes can be inside boxes. Not sure if this is terribly important for testing/diffing fonts, but if this tickles your interest, go ahead.

  • Paragraph layout. The current paragraph layout is rather ad-hoc. On the positive side, fontdiff uses ICU for finding potential line breaks, so it can be used in testing fonts for Thai and other languages that don’t mark word boundaries. However, there is currently no hyphenation or justification, and the current support for bidirectional text is rather iffy. One option for doing this properly could be Raqm, another might be Minikin. If you want to look into this, make sure to think about the special needs for diffing fonts. In particular, a changed glyph width should not require a re-flow in the entire paragraph — the resulting diffs would become meaningless. When fontdiff breaks paragraphs into lines, it currently measures the width of text runs using both the old and the new font version. The decision about line breaking is then made based on the maximum of both these values, which means fontdiff doesn’t run into this reflowing problem. It will probably be difficult to replicate this logic when using an existing paragraph layout library. However, being able to precisely locate the difference between two fonts is important for font designers, which is why we wrote the tool in the first place.

  • Reduce binary size. To avoid dependency hell and to maintain reproducible versioning, fontdiff is statically linked to all its dependencies. This is a very intentional choice, but ICU’s data files are huge. By building a static ICU data library with only the needed data files (the break iterators), the size of the compiled fontdiff binary would shrink by about 20MB. If you are interested in this task, check out how NodeJS does it. This task shouldn’t be very difficult, but it’s probably also not the biggest problem fontdiff needs to solve.

Have fun!

More Repositories

1

roboto

The Roboto family of fonts
Python
3,796
star
2

noto-emoji

Noto Emoji fonts
Python
3,331
star
3

Inconsolata

Development repo of Inconsolata Fonts by Raph Levien
Rust
1,201
star
4

fontmake

Compile fonts from sources (UFO, Glyphs) to binary (OpenType, TrueType).
Python
763
star
5

morisawa-biz-ud-gothic

Python
615
star
6

compute-shader-101

Sample code for compute shader 101 training
Rust
515
star
7

morisawa-biz-ud-mincho

Python
471
star
8

fontra

A browser-based font editor
JavaScript
463
star
9

roboto-flex

HTML
434
star
10

sfntly

A Library for Using, Editing, and Creating SFNT-based Fonts
Java
432
star
11

amstelvar

a parametric variable font by David Berlow
330
star
12

fontview

Demo app that displays fonts with a free/libre/open-source text rendering stack: FreeType, HarfBuzz and Raqm
C++
321
star
13

spacemono

Original monospace display typeface family
318
star
14

decovar

A multistyle decorative variable font by David Berlow
Python
314
star
15

gftools

Misc tools for working with the Google Fonts library
Python
242
star
16

nanoemoji

A wee tool to build color fonts.
Python
239
star
17

opensans

Open Sans font
Shell
221
star
18

literata

A contemporary serif typeface family for long-form reading
Python
219
star
19

dm-fonts

DM Sans, DM Serif
Shell
190
star
20

rubik

Rubik fonts
Shell
182
star
21

glyphsLib

A bridge from Glyphs source files (.glyphs) to UFOs
Python
181
star
22

korean

Google Fonts Korean showcase
JavaScript
161
star
23

atkinson-hyperlegible

HTML
157
star
24

ufo2ft

A bridge from UFOs to FontTools objects (and therefore, OTFs and TTFs).
Python
151
star
25

roboto-classic

Development of a Roboto Variable font
Python
151
star
26

science-gothic

Science Gothic, a libre variable font
Python
142
star
27

picosvg

Helps simplify SVG files. Intended for use as part of a font build.
Python
137
star
28

fontations

Reading and writing font files
Rust
114
star
29

pyfontaine

Python tool to check font files for language/character set support
Python
100
star
30

gf-docs

Documentation for things related to github.com/google/fonts
99
star
31

color-fonts

Experimental color font builds.
Python
96
star
32

googlefonts-project-template

(DEMO) Repository architecture example for a typeface design project
Python
93
star
33

inter-gf-tight

Specialized version of Inter with tighter spacing, for use by Google Workspace
Python
79
star
34

glyphsets

Python
77
star
35

fontdiffenator

Font comparison tool
Python
76
star
36

dm-mono

DM Mono
Shell
73
star
37

lexend

A variable font family designed to aid in reading proficiency.
Shell
72
star
38

zen-marugothic

ZenFonts.jp Maru Gothic
Python
72
star
39

fontcrunch

Tool to optimize TrueType font splines
C++
70
star
40

RobotoMono

Shell
64
star
41

colr-gradients-spec

HTML
63
star
42

cu2qu

Cubic-to-quadratic bezier curve conversion
Python
62
star
43

fontreport

Tool to create PDF files containing glyph images and information about a font.
Python
62
star
44

googlefonts.github.io

Google Fonts documentation
CSS
57
star
45

robotoslab

Roboto Slab Typeface by Google
Python
57
star
46

roboto-serif

55
star
47

tajawal

Distinctive low contrast Arabic and sans serif Latin typeface family
54
star
48

emoji-metadata

Emoji metadata for the construction of pickers
48
star
49

dosis-vf

Fork of Dosis
Makefile
45
star
50

oxidize

Notes on moving tools and libraries to Rust.
45
star
51

zen-kurenaido

ZenFonts.jp Kurenaido
Python
45
star
52

comfortaa

Open-source font by Johan Aakerlund
HTML
44
star
53

diffenator2

A font comparison tool that will not stop until your fonts are exhaustively compared.
Python
43
star
54

ibarrareal

Ibarra Real Fonts
Shell
40
star
55

zen-kakugothic

ZenFonts.jp Kaku Gothic
Python
40
star
56

Gulzar

Nastaliq font
Python
39
star
57

gulim

Python
39
star
58

how-to-hint-variable-fonts

A how-to guide to TrueType hinting variable fonts, with VTT
38
star
59

NunitoSans

Shell
36
star
60

zen-oldmincho

ZenFonts.jp Old Mincho
Python
36
star
61

fontra-pak

A cross-platform bundled Fontra server for local desktop use
Python
34
star
62

TachyFont

Lazily loaded web fonts.
JavaScript
34
star
63

majormono

Python
32
star
64

josefinsans

Google Improvement Project
HTML
31
star
65

shaperglot

Test font files for language support
Python
30
star
66

EQX

A typographically centric font testing tool.
JavaScript
29
star
67

fontbakery-dashboard

A library-scale web dashboard for Font Bakery, no longer developed
JavaScript
28
star
68

axisregistry

A Python API to access data from the Google Fonts variable fonts Axis Registry.
Python
27
star
69

fontmake-rs

Where in we pursue oxidizing (context: https://github.com/googlefonts/oxidize) fontmake.
Rust
24
star
70

chws_tool

Add OpenType chws/vchw features to fonts.
HTML
23
star
71

lang

A python API for evaluating language support in the Google Fonts collection.
Python
23
star
72

caveat

Caveat handwriting fonts
Shell
23
star
73

compreffor

A CFF table subroutinizer for FontTools
Python
23
star
74

kosugi-maru

Kosugi Maru fonts, originally by Motoya
Python
23
star
75

collidoscope

Brute force detection of glyph collisions
Python
22
star
76

zen-antique

ZenFonts.jp Antique
Python
21
star
77

karla

Python
21
star
78

questrial

A fork of John Prince font Questrial from the old Google font directory
Python
21
star
79

chinese

CSS
20
star
80

gf-glyphs-scripts

Scripts for Glyphs
Python
20
star
81

staatliches

Herbert Bayer’s title lettering for the first Bauhaus exhibition catalogue cover of 1923
Python
18
star
82

batang

Python
18
star
83

changa-vf

Variable font fork of the Changa typeface (Latin, Arabic)
Makefile
17
star
84

Roboto-Delta

Roboto as a “parametric” Variable Font
Python
17
star
85

picosvg-rs

A Rust version of picosvg.
Rust
15
star
86

silkscreen

Classic web design pixel font from Jason Kottke, 2001
Python
15
star
87

gfregression

Test local fonts against fonts host on fonts.google.com
Python
14
star
88

fez

Font Engineering made eaZy
Python
14
star
89

mavenproFont

Maven Pro family by Joe Prince
Makefile
14
star
90

BethEllen

Font project repo for the Beth Ellen font by Rod Jelinski
14
star
91

how-to-hint-complex-script-variable-fonts

A guide to hinting complex script variable fonts with Visual TrueType
11
star
92

ufomerge

ufomerge
Python
11
star
93

dynapuff

Fun blobby display font
Python
10
star
94

fontquant

Prove and quantify a font’s technical quality
Python
10
star
95

kosugi

Kosugi fonts, originally by Motoya
Python
10
star
96

zen-dots

Shell
10
star
97

flowify

Turn a font into a flow font
Python
10
star
98

namecheck

Python
9
star
99

ots-python

Python wheels for the OpenType Sanitizer
Python
9
star
100

variable-components-spec

8
star