from psautohint import autohint
from psautohint import psautohint

d = "tests/data/source-code-pro"
mm = ("Black", "Bold", "ExtraLight", "Light", "Medium", "Regular", "Semibold")
gg = []
ii = None

for m in mm:
    f = autohint.openOpenTypeFile("%s/%s/font.otf" % (d, m), "font.otf", None)
    g = f.convertToBez("A", False)
    gg.append(g[0])
    if ii is None:
        ii = f.getFontInfo(f.getPSName(), "%s/%s/font.otf" % (d, m), False, False, [], [])
        ii = ii.getFontInfo()

gg = psautohint.autohint(ii, gg, True)
gg = psautohint.autohintmm(ii, [gg], True)

from psautohint import autohint
from psautohint import psautohint

baseDir = "tests/data/source-code-pro"
masters = ("Black", "Bold", "ExtraLight", "Light", "Medium", "Regular", "Semibold")

glyphList = None

fonts = []
for master in masters:
    print("Hinting %s" % master)

    path = "%s/%s/font.otf" % (baseDir, master)
    font = autohint.openOpenTypeFile(path, "font.otf", None)
    names = font.getGlyphList()
    info = font.getFontInfo(font.getPSName(), path, False, False, [], [])
    info = info.getFontInfo()

    if glyphList is None:
        glyphList = names
    else:
        assert glyphList == names

    glyphs = []
    for name in names:
        glyph = font.convertToBez(name, False)
        glyphs.append(glyph[0])
    fonts.append(psautohint.autohint(info, glyphs, False, False, False))

glyphs = []
for i in range(len(glyphList)):
    glyphs.append([f[i] for f in fonts])

print("MM Hinting")
glyphs = psautohint.autohintmm(info, glyphs, True)

Rewrite the test script to hint all glyphs
Rewrite the test script to hint all glyphs

Which reveals that no MM-compatible hinting is really done :(

  from psautohint import autohint
  from psautohint import psautohint
  
- d = "tests/data/source-code-pro"
+ baseDir = "tests/data/source-code-pro"
- mm = ("Black", "Bold", "ExtraLight", "Light", "Medium", "Regular", "Semibold")
+ masters = ("Black", "Bold", "ExtraLight", "Light", "Medium", "Regular", "Semibold")
- gg = []
- ii = None
  
+ glyphList = None
- for m in mm:
-     f = autohint.openOpenTypeFile("%s/%s/font.otf" % (d, m), "font.otf", None)
-     g = f.convertToBez("A", False)
-     gg.append(g[0])
-     if ii is None:
-         ii = f.getFontInfo(f.getPSName(), "%s/%s/font.otf" % (d, m), False, False, [], [])
-         ii = ii.getFontInfo()
  
- gg = psautohint.autohint(ii, gg, True)
- gg = psautohint.autohintmm(ii, [gg], True)
+ fonts = []
+ for master in masters:
+     print("Hinting %s" % master)
  
+     path = "%s/%s/font.otf" % (baseDir, master)
+     font = autohint.openOpenTypeFile(path, "font.otf", None)
+     names = font.getGlyphList()
+     info = font.getFontInfo(font.getPSName(), path, False, False, [], [])
+     info = info.getFontInfo()
+ 
+     if glyphList is None:
+         glyphList = names
+     else:
+         assert glyphList == names
+ 
+     glyphs = []
+     for name in names:
+         glyph = font.convertToBez(name, False)
+         glyphs.append(glyph[0])
+     fonts.append(psautohint.autohint(info, glyphs, False, False, False))
+ 
+ glyphs = []
+ for i in range(len(glyphList)):
+     glyphs.append([f[i] for f in fonts])
+ 
+ print("MM Hinting")
+ glyphs = psautohint.autohintmm(info, glyphs, True)
+ 
Rewrite the test script to hint all glyphs
## Code Before:
from psautohint import autohint
from psautohint import psautohint

d = "tests/data/source-code-pro"
mm = ("Black", "Bold", "ExtraLight", "Light", "Medium", "Regular", "Semibold")
gg = []
ii = None

for m in mm:
    f = autohint.openOpenTypeFile("%s/%s/font.otf" % (d, m), "font.otf", None)
    g = f.convertToBez("A", False)
    gg.append(g[0])
    if ii is None:
        ii = f.getFontInfo(f.getPSName(), "%s/%s/font.otf" % (d, m), False, False, [], [])
        ii = ii.getFontInfo()

gg = psautohint.autohint(ii, gg, True)
gg = psautohint.autohintmm(ii, [gg], True)

## Instruction:
Rewrite the test script to hint all glyphs
## Code After:
from psautohint import autohint
from psautohint import psautohint

baseDir = "tests/data/source-code-pro"
masters = ("Black", "Bold", "ExtraLight", "Light", "Medium", "Regular", "Semibold")

glyphList = None

fonts = []
for master in masters:
    print("Hinting %s" % master)

    path = "%s/%s/font.otf" % (baseDir, master)
    font = autohint.openOpenTypeFile(path, "font.otf", None)
    names = font.getGlyphList()
    info = font.getFontInfo(font.getPSName(), path, False, False, [], [])
    info = info.getFontInfo()

    if glyphList is None:
        glyphList = names
    else:
        assert glyphList == names

    glyphs = []
    for name in names:
        glyph = font.convertToBez(name, False)
        glyphs.append(glyph[0])
    fonts.append(psautohint.autohint(info, glyphs, False, False, False))

glyphs = []
for i in range(len(glyphList)):
    glyphs.append([f[i] for f in fonts])

print("MM Hinting")
glyphs = psautohint.autohintmm(info, glyphs, True)
