Fix empty public.postscriptNames dict incorrectly triggering uniXXXX derivation#980
Merged
Conversation
An empty dict passed the `is not None` check, causing all glyphs to be renamed to uniXXXX production names. Treat empty the same as absent.
Member
Author
|
Note: the v2.4.0 release notes (https://github.com/googlefonts/ufo2ft/releases/tag/v2.4.0) already documented this as the intended behavior:
The empty-dict case was an oversight in the implementation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When a UFO's
lib.plistcontainspublic.postscriptNamesas an empty dict (<dict/>), ufo2ft incorrectly derivesuniXXXX/uXXXXXproduction names for all glyphs. But an empty mapping should mean "no glyphs are renamed," same as if it were absent.The Georama family has
<key>public.postscriptNames</key><dict/>in all 7 masters. fontmake renames every glyph to uniXXXX; fontc correctly keeps the source names.The problem is the
is not Nonecheck inprocess_glyph_names(): an empty dict{}passes that check, souseProductionNamesis set toTrue. Then in_build_production_name(), the truthiness guardif self._postscriptNames:skips the (empty) mapping and incorrectly falls through to unicode-based derivation.The fix changes
is not Noneto a truthiness check so empty and absent are treated the same, matching the documented semantics from commit 2f800cb:There is already a way to explicitly opt into uniXXXX renaming by setting the
com.github.googlei18n.ufo2ft.useProductionNameslib key totrue(or by passing--production-namesto fontmake CLI in absence of an explicitpublic.postscriptNamesdict in the lib):An empty
public.postscriptNamesdict was never supposed to implicitly trigger the same behavior.