Skip to content

Commit

Permalink
Merge pull request #53 from robotools/type1_macroman
Browse files Browse the repository at this point in the history
Type1 macroman
  • Loading branch information
benkiel committed Jun 8, 2023
2 parents 31576d4 + 0e070a2 commit 7929250
Showing 1 changed file with 3 additions and 21 deletions.
24 changes: 3 additions & 21 deletions Lib/extractor/formats/type1.py
Expand Up @@ -29,7 +29,7 @@ def extractFontFromType1(
doFeatures=False,
customFunctions=[],
):
source = T1Font(pathOrFile)
source = T1Font(pathOrFile, encoding="macroman")
destination.lib["public.glyphOrder"] = _extractType1GlyphOrder(source)
if doInfo:
extractType1Info(source, destination)
Expand Down Expand Up @@ -163,24 +163,6 @@ def extractType1Glyphs(source, destination):
# -----------


class GlyphOrderPSInterpreter(PSInterpreter):
def __init__(self):
PSInterpreter.__init__(self)
self.glyphOrder = []
self.collectTokenForGlyphOrder = False

def do_literal(self, token):
result = PSInterpreter.do_literal(self, token)
if token == "/FontName":
self.collectTokenForGlyphOrder = False
if self.collectTokenForGlyphOrder:
self.glyphOrder.append(result.value)
if token == "/CharStrings":
self.collectTokenForGlyphOrder = True
return result


def _extractType1GlyphOrder(t1Font):
interpreter = GlyphOrderPSInterpreter()
interpreter.interpret(t1Font.data)
return interpreter.glyphOrder
glyphSet = t1Font.getGlyphSet()
return list(glyphSet)

0 comments on commit 7929250

Please sign in to comment.