@@ -41,6 +41,7 @@ def extractFontFromOpenType(
4141 extractOpenTypeInfo (source , destination )
4242 if doGlyphs :
4343 extractOpenTypeGlyphs (source , destination )
44+ extractUnicodeVariationSequences (source , destination )
4445 if doGlyphOrder :
4546 extractGlyphOrder (source , destination )
4647 if doKerning :
@@ -61,6 +62,33 @@ def extractGlyphOrder(source, destination):
6162 destination .lib ["public.glyphOrder" ] = glyphOrder
6263
6364
65+ # ---------------------------
66+ # Unicode Variation Sequences
67+ # ---------------------------
68+
69+
70+ def extractUnicodeVariationSequences (source , destination ):
71+ """
72+ Extract the Unicode Variation Sequences
73+ """
74+ cmap = source .get ("cmap" )
75+ mapping = cmap .getBestCmap ()
76+ for subtable in cmap .tables :
77+ if subtable .format == 14 :
78+ destination .lib ["public.unicodeVariationSequences" ] = {
79+ "%04X" % variationSelector : {
80+ "%04X" % charValue : glyphName if glyphName else mapping .get (charValue )
81+ for (charValue , glyphName ) in uvsList
82+ }
83+ for variationSelector , uvsList in subtable .uvsDict .items ()
84+ }
85+
86+
87+ # ------------
88+ # Instructions
89+ # ------------
90+
91+
6492def extractInstructions (source , destination ):
6593 if "glyf" not in source :
6694 return
@@ -500,7 +528,6 @@ def extractOpenTypeGlyphs(source, destination):
500528 # grab the cmap
501529 vmtx = source .get ("vmtx" )
502530 vorg = source .get ("VORG" )
503- cmap = source .getBestCmap ()
504531 is_ttf = "glyf" in source
505532 reversedMapping = source .get ("cmap" ).buildReversed ()
506533 # grab the glyphs
0 commit comments