Skip to content

Commit

Permalink
use global postscriptNamesKey
Browse files Browse the repository at this point in the history
  • Loading branch information
schriftgestalt committed Dec 21, 2023
1 parent cde6d93 commit 3cbf81e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Lib/glyphsLib/builder/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
GLYPH_ORDER_KEY = PUBLIC_PREFIX + "glyphOrder"
OBJECT_LIBS_KEY = PUBLIC_PREFIX + "objectLibs"

POSTSCRIPT_NAMES_KEY = PUBLIC_PREFIX + "postscriptNames"

GLYPHS_PREFIX = "com.schriftgestaltung."
GLYPHLIB_PREFIX = GLYPHS_PREFIX + "Glyphs."
ROBOFONT_PREFIX = "com.typemytype.robofont."
Expand Down
14 changes: 7 additions & 7 deletions Lib/glyphsLib/builder/glyph.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
SHAPE_ORDER_LIB_KEY,
ORIGINAL_WIDTH_KEY,
BACKGROUND_WIDTH_KEY,
POSTSCRIPT_NAMES_KEY,
)
from glyphsLib.classes import LAYER_ATTRIBUTE_COLOR
from glyphsLib.types import floatToString3
Expand Down Expand Up @@ -108,10 +109,9 @@ def to_ufo_glyph(self, ufo_glyph, layer, glyph, do_color_layers=True): # noqa:
else:
production_name = glyphinfo.production_name
if production_name and production_name != ufo_glyph.name:
postscriptNamesKey = PUBLIC_PREFIX + "postscriptNames"
if postscriptNamesKey not in ufo_font.lib:
ufo_font.lib[postscriptNamesKey] = dict()
ufo_font.lib[postscriptNamesKey][ufo_glyph.name] = production_name
if POSTSCRIPT_NAMES_KEY not in ufo_font.lib:
ufo_font.lib[POSTSCRIPT_NAMES_KEY] = dict()
ufo_font.lib[POSTSCRIPT_NAMES_KEY][ufo_glyph.name] = production_name

if script:
ufo_glyph.lib[SCRIPT_LIB_KEY] = script
Expand Down Expand Up @@ -429,9 +429,9 @@ def to_glyphs_glyph(self, ufo_glyph, ufo_layer, master): # noqa: C901
glyph.export = False

ufo_font = self._sources[master.id].font
ps_names_key = PUBLIC_PREFIX + "postscriptNames"
if ps_names_key in ufo_font.lib and ufo_glyph.name in ufo_font.lib[ps_names_key]:
glyph.production = ufo_font.lib[ps_names_key][ufo_glyph.name]

if POSTSCRIPT_NAMES_KEY in ufo_font.lib and ufo_glyph.name in ufo_font.lib[POSTSCRIPT_NAMES_KEY]:
glyph.production = ufo_font.lib[POSTSCRIPT_NAMES_KEY][ufo_glyph.name]
# FIXME: (jany) maybe put something in glyphinfo? No, it's readonly
# maybe don't write in glyph.production if glyphinfo already
# has something
Expand Down

0 comments on commit 3cbf81e

Please sign in to comment.