{"id":13721438,"url":"https://github.com/googlefonts/fontdiff","last_synced_at":"2025-05-07T21:06:56.122Z","repository":{"id":55119538,"uuid":"53916282","full_name":"googlefonts/fontdiff","owner":"googlefonts","description":"tool for finding visual differences between two font versions","archived":false,"fork":false,"pushed_at":"2021-03-01T21:49:00.000Z","size":23523,"stargazers_count":136,"open_issues_count":15,"forks_count":24,"subscribers_count":29,"default_branch":"main","last_synced_at":"2025-05-07T21:06:45.350Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/googlefonts.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-03-15T05:05:20.000Z","updated_at":"2024-10-23T05:02:13.000Z","dependencies_parsed_at":"2022-08-14T12:31:27.019Z","dependency_job_id":null,"html_url":"https://github.com/googlefonts/fontdiff","commit_stats":null,"previous_names":["googlei18n/fontdiff"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googlefonts%2Ffontdiff","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googlefonts%2Ffontdiff/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googlefonts%2Ffontdiff/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/googlefonts%2Ffontdiff/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/googlefonts","download_url":"https://codeload.github.com/googlefonts/fontdiff/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252954428,"owners_count":21830904,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T01:01:17.050Z","updated_at":"2025-05-07T21:06:56.101Z","avatar_url":"https://github.com/googlefonts.png","language":"C++","funding_links":[],"categories":["Python","C++"],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/googlei18n/fontdiff.svg)](https://travis-ci.org/googlei18n/fontdiff)\n\n# fontdiff\n\n`fontdiff` is a utility for testing fonts. When you modify a TrueType\nor [OpenType](http://opentypecookbook.com/index.html) font, fontdiff\ngenerates a PDF showing the typeset text both before and after the\nchange. You can use this PDF to easily review the changes and spot any\nerrors caused by a font switch.\n\nFor every line in the text sample, the tool renders two raster images\nin high resolution. One image is typeset using the original font, and\nthe second uses the new font.  If there is any difference between\nthese two high-resolution images (even if it’s just whitespace caused\nby kerning changes), the output PDF highlights the difference in\ncolor.\n\n![Screenshot](doc/fontdiff-1.png)\n\nSince fontdiff is using\n[HarfBuzz](https://www.freedesktop.org/wiki/Software/HarfBuzz/) for\nOpenType shaping, text gets rendered in a similar way across Firefox,\nChrome, Android, LibreOffice, XeTeX, GNOME, KDE, ChromeOS, and other\nproducts.\n\n\n## Sample text\n\nTo provide sample text, use HTML with embedded CSS styling:\n```html\n\u003chtml lang=\"la\"\u003e\n  \u003cp\u003eLorem \u003cspan style=\"font-weight:700\"\u003eipsum\u003c/span\u003e dolor sit amet.\u003c/p\u003e\n\u003c/html\u003e\n```\n\nThe `lang` tag can make a difference for rendering. For example, when\ndiffing a font with [Polish letter\nforms](https://glyphsapp.com/tutorials/localize-your-font-polish-kreska),\nyou can write `\u003cspan lang=\"pl\"\u003ećńóśź\u003c/span\u003e` to see the Polish\nvariants of accented letters, or `\u003cspan lang=\"und\"\u003ećńóśź\u003c/span\u003e`\nto see the default design.  As with HTML, you can combine spans in\nmultiple languages into the same document.  fontdiff recognizes the\nsame [language tags](https://www.w3.org/International/articles/language-tags/)\nas modern web browsers; “und” is the “undefined” or default language.\n\n\n## Limitations\n\nThis is not an official Google product. We needed a lightweight tool\nto test our font production pipeline, so we built fontdiff, and we hope\nyou’ll find it useful, too.  However, please understand that there are\nsome limitations:\n\n* **Not a full renderer:** HTML and CSS are much richer than what this\n  little testing tool supports. If you miss something, please do not\n  hesitate to make the change yourself and send a pull request.\n\n* **Lousy codebase:** The current state of the codebase isn’t something\n  we’d be proud to call production-ready: no tests, too many dependencies,\n  and so on. fontdiff isn’t a “real” product, and definitely not a showcase\n  for writing production code.\n\n* **Not secure:** Do not run this tool on untrusted input. It parses\n  complicated input formats (TrueType, OpenType, HTML) but it isn’t\n  hardened in any way.  Use it at your own risk.\n\n* **Not a sample generator:** This tool compares how an existing\n  sample text gets rendered in two versions of the same font. However,\n  it won’t find text for you to render.  Some font designers may want\n  to manually craft samples. Others may want to see how an entire\n  volume of text is rendered, or check the output of a font-affecting\n  tool or script.  Because the use cases for fontdiff are wildly\n  different, we felt it would be best to limit its scope to the actual\n  diffing operation.\n\n\n## Building\n\n```sh\n$ git clone --recursive https://github.com/googlefonts/fontdiff.git\n$ cd fontdiff\n$ ./src/third_party/gyp/gyp -f make --depth . --generator-output build src/fontdiff/fontdiff.gyp\n$ make --directory build\n$ build/out/Default/fontdiff \\\n    --before path/to/old/FooFont*.ttf \\\n    --after path/to/new/FooFont*.ttf \\\n    --specimen src/fontdiff/specimen.html \\\n    --out out.pdf\n```\n\nThis incantation works on reasonably recent versions of Linux and MacOS X.\nIf you want to support other platforms, feel free to make the change.\nPull requests are very welcome!\n\n\n## Contributing\n\nHere are a few features and concepts we’d love your help implementing,\nif you’re bored and/or want to get your hands dirty (or are just a\nmagnanimous person who loves fontdiff):\n\n* **Port to other platforms.** This should be a very easy starter task\n  for people familiar with the respective platforms. It shouldn’t\n  take more than a few hours, since the project already uses\n  cross-platform libraries and a cross-platform build system.\n\n* **Testing.** Currently, the codebase is entirely untested, which makes\n  it hard to maintain the code.\n\n* **More constructs from CSS and HTML.**\n\n* **MathML.** With (even limited) support for MathML rendering,\n  font designers could use fontdiff to test their mathematical fonts.\n\n* **Sandboxing.** To protect users against attacks that use malicious\n  font or text sample files, set up a\n  [sandbox](https://en.wikipedia.org/wiki/Sandbox_%28computer_security%29)\n  early in the tool’s execution and then do all the rendering inside\n  the sandbox.\n\n* **CSS box model.** It might be nice to properly support the layout of\n  CSS and HTML, where boxes can be inside boxes. Not sure if this is\n  terribly important for testing/diffing fonts, but if this tickles\n  your interest, go ahead.\n\n* **Paragraph layout.** The current paragraph layout is rather\n  ad-hoc. On the positive side, fontdiff uses\n  [ICU](http://site.icu-project.org/) for finding potential line\n  breaks, so it can be used in testing fonts for Thai and\n  other languages that don’t mark word boundaries. However, there is\n  currently no hyphenation or justification, and the current support\n  for bidirectional text is rather iffy. One option for doing this\n  properly could be [Raqm](https://github.com/HOST-Oman/libraqm),\n  another might be\n  [Minikin](https://android.googlesource.com/platform/frameworks/minikin/+/master). If\n  you want to look into this, make sure to think about the special\n  needs for diffing fonts. In particular, a changed glyph width should\n  not require a re-flow in the entire paragraph — the\n  resulting diffs would become meaningless. When fontdiff breaks\n  paragraphs into lines, it currently measures the width of text runs\n  using _both_ the old and the new font version. The decision about\n  line breaking is then made based on the maximum of both these\n  values, which means fontdiff doesn’t run into this reflowing\n  problem.  It will probably be difficult to replicate this\n  logic when using an existing paragraph layout library. However,\n  being able to precisely locate the difference between two fonts is\n  important for font designers, which is why we wrote\n  the tool in the first place.\n\n* **Reduce binary size.** To avoid dependency hell and to maintain\n  reproducible versioning, fontdiff is statically linked to all its\n  dependencies.  This is a very intentional choice, but ICU’s data\n  files are _huge_.  By building a static ICU data library with only\n  the needed data files (the break iterators), the size of the\n  compiled fontdiff binary would shrink by about 20MB. If you are\n  interested in this task, check out how\n  [NodeJS](https://github.com/nodejs/node/blob/master/tools/icu/README.md)\n  does it. This task shouldn’t be very difficult, but it’s probably also\n  not the biggest problem fontdiff needs to solve.\n\nHave fun!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooglefonts%2Ffontdiff","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgooglefonts%2Ffontdiff","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgooglefonts%2Ffontdiff/lists"}