def NowarApplyPaltMultiplied(font, multiplier): for palt in GetLookupPalt(font): for sub in palt['subtables']: for (n, d) in sub.items(): glyph = font['glyf'][n] if any([ IsKana(ch) for ch in GetUnicodeScalars(n, font) ]): if 'dx' in d: Transform(glyph, 1, 0, 0, 1, d['dx'], 0) if 'dWidth' in d: ChangeAdvanceWidth(glyph, d['dWidth']) else: if 'dx' in d: Transform(glyph, 1, 0, 0, 1, d['dx'] * multiplier, 0, roundToInt = True) if 'dWidth' in d: ChangeAdvanceWidth(glyph, round(d['dWidth'] * multiplier))
def ApplyPalt(font): for palt in GetLookupPalt(font): for sub in palt['subtables']: for (n, d) in sub.items(): glyph = font['glyf'][n] if 'dx' in d: Transform(glyph, 1, 0, 0, 1, d['dx'], 0) if 'dWidth' in d: ChangeAdvanceWidth(glyph, d['dWidth'])
def ProportionalizeKana(font): for palt in GetLookupPalt(font): for sub in palt['subtables']: for (n, d) in sub.items(): if any([ IsKana(ch) for ch in GetUnicodeScalars(n, font) ]): glyph = font['glyf'][n] if 'dx' in d: Transform(glyph, 1, 0, 0, 1, d['dx'], 0) if 'dWidth' in d: ChangeAdvanceWidth(glyph, d['dWidth'])
for n in num + pnum + onum + tonum: numFont['glyf'][n] = Dereference(numFont['glyf'][n], numFont) for n in num + tonum: tGlyph = numFont['glyf'][n] tWidth = tGlyph['advanceWidth'] pName = gsubPnum[n] pGlyph = numFont['glyf'][pName] pWidth = pGlyph['advanceWidth'] if pWidth > tWidth: numFont['glyf'][pName] = copy.deepcopy(tGlyph) pGlyph = numFont['glyf'][pName] pWidth = tWidth if changeWidth != 0: ChangeAdvanceWidth(pGlyph, changeWidth) Transform(pGlyph, 1, 0, 0, 1, (changeWidth + 1) // 2, 0) for n in num + pnum + onum + tonum: baseFont['glyf'][n] = numFont['glyf'][n] ApplyGsubSingle('pnum', baseFont) with open( "build/rhr/{}.otd".format(configure.GenerateFilename(dep['CJK'])), 'rb') as asianFile: asianFont = json.loads(asianFile.read().decode('UTF-8', errors='replace')) # pre-apply `palt` in UI family if "UI" in param["feature"]: ApplyPalt(asianFont)