def buildComposition(font, glyphnames): newnames = [] #dirty fix try: font.removeLookup("Latin composition") except EnvironmentError: pass font.addLookup("Latin composition", 'gsub_ligature', (), (('ccmp', script_lang), )) font.addLookupSubtable("Latin composition", "Latin composition subtable") import unicodedata for name in glyphnames: u = fontforge.unicodeFromName(name) if 0 < u < 0xfb00: decomp = unicodedata.decomposition(unichr(u)) if decomp: base = decomp.split()[0] mark = decomp.split()[1] if not '<' in base: nmark = None nbase = None for g in font.glyphs(): if g.unicode == int(base, 16): nbase = g.glyphname if g.unicode == int(mark, 16): nmark = g.glyphname if not nbase: nbase = "uni%04X" % int(base, 16) if not nmark: nmark = "uni%04X" % int(mark, 16) if nbase in font and nmark in font: font[name].addPosSub("Latin composition subtable", (nbase, nmark)) if base not in glyphnames: newnames.append(nbase) if mark not in glyphnames: newnames.append(nmark) return newnames
def buildComposition(font, glyphnames): newnames = [] #dirty fix try: font.removeLookup("Latin composition"); except EnvironmentError: pass font.addLookup("Latin composition", 'gsub_ligature', (), (('ccmp', script_lang),)) font.addLookupSubtable("Latin composition", "Latin composition subtable") import unicodedata for name in glyphnames: u = fontforge.unicodeFromName(name) if 0 < u < 0xfb00: decomp = unicodedata.decomposition(unichr(u)) if decomp: base = decomp.split()[0] mark = decomp.split()[1] if not '<' in base: nmark = None nbase = None for g in font.glyphs(): if g.unicode == int(base, 16): nbase = g.glyphname if g.unicode == int(mark, 16): nmark = g.glyphname if not nbase: nbase = "uni%04X" % int(base, 16) if not nmark: nmark = "uni%04X" % int(mark, 16) if nbase in font and nmark in font: font[name].addPosSub("Latin composition subtable", (nbase, nmark)) if base not in glyphnames: newnames.append(nbase) if mark not in glyphnames: newnames.append(nmark) return newnames
def buildComposition(font, glyphnames): newnames = [] font.addLookup("Latin composition", "gsub_ligature", (), (("ccmp", script_lang),)) font.addLookupSubtable("Latin composition", "Latin composition subtable") import unicodedata for name in glyphnames: u = fontforge.unicodeFromName(name) if 0 < u < 0xFB00: decomp = unicodedata.decomposition(unichr(u)) if decomp: base = decomp.split()[0] mark = decomp.split()[1] if not "<" in base: nmark = None nbase = None for g in font.glyphs(): if g.unicode == int(base, 16): nbase = g.glyphname if g.unicode == int(mark, 16): nmark = g.glyphname if not nbase: nbase = "uni%04X" % int(base, 16) if not nmark: nmark = "uni%04X" % int(mark, 16) if nbase in font and nmark in font: font[name].addPosSub("Latin composition subtable", (nbase, nmark)) if base not in glyphnames: newnames.append(nbase) if mark not in glyphnames: newnames.append(nmark) return newnames
def makeQuran(infile, outfile, feafile, version): font = makeDesktop(infile, outfile, feafile, version, False, False) # fix metadata font.fontname = font.fontname.replace("-Regular", "Quran-Regular") font.familyname += " Quran" font.fullname += " Quran" digits = ("zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine") mergeLatin(font, feafile, glyphs=digits, quran=True) punct = ( "period", "guillemotleft", "guillemotright", "braceleft", "bar", "braceright", "bracketleft", "bracketright", "parenleft", "parenright", "slash", "backslash", ) for name in punct: if name + ".ara" in font: glyph = font[name + ".ara"] glyph.glyphname = name glyph.unicode = fontforge.unicodeFromName(name) # abuse U+065C as a below form of U+06EC, for Qaloon dotabove = font["uni06EC"] dotbelow = font["uni065C"] delta = dotbelow.boundingBox()[-1] - dotabove.boundingBox()[-1] dotbelow.references = [] dotbelow.addReference(dotabove.glyphname, psMat.translate(0, delta)) dotbelow.addAnchorPoint("TashkilTashkilBelow", "basemark", 220, dotbelow.boundingBox()[1] - 100) # scale some vowel marks and dots down a bit font["uni0651"].transform(psMat.scale(0.8)) for mark in ("uni064B", "uni064C", "uni064E", "uni064F", "uni06E1"): font[mark].transform(psMat.scale(0.9)) for dot in ("TwoDots.a", "ThreeDots.a", "vTwoDots.a"): font[dot].transform(psMat.scale(0.9)) quran_glyphs = [] # create dummy glyphs used for some coding hacks for i in range(1, 11): dummy = font.createChar(-1, "dummy%s" % i) dummy.width = 0 quran_glyphs.append(dummy.glyphname) mergeFeatures(font, feafile) quran_glyphs += digits quran_glyphs += punct quran_glyphs += ( "space", "uni060C", "uni0615", "uni0617", "uni0618", "uni0619", "uni061A", "uni061B", "uni061E", "uni061F", "uni0621", "uni0622", "uni0623", "uni0624", "uni0625", "uni0626", "uni0627", "uni0628", "uni0629", "uni062A", "uni062B", "uni062C", "uni062D", "uni062E", "uni062F", "uni0630", "uni0631", "uni0632", "uni0633", "uni0634", "uni0635", "uni0636", "uni0637", "uni0638", "uni0639", "uni063A", "uni0640", "uni0641", "uni0642", "uni0643", "uni0644", "uni0645", "uni0646", "uni0647", "uni0648", "uni0649", "uni064A", "uni064B", "uni064C", "uni064D", "uni064E", "uni064F", "uni0650", "uni0651", "uni0652", "uni0653", "uni0654", "uni0655", "uni0656", "uni0657", "uni0658", "uni065C", "uni0660", "uni0661", "uni0662", "uni0663", "uni0664", "uni0665", "uni0666", "uni0667", "uni0668", "uni0669", "uni066E", "uni066F", "uni06A1", "uni06BA", "uni0670", "uni0671", "uni067A", "uni06CC", "uni06D6", "uni06D7", "uni06D8", "uni06D9", "uni06DA", "uni06DB", "uni06DC", "uni06DD", "uni06DE", "uni06DF", "uni06E0", "uni06E1", "uni06E2", "uni06E3", "uni06E4", "uni06E5", "uni06E6", "uni06E7", "uni06E8", "uni06E9", "uni06EA", "uni06EB", "uni06EC", "uni06ED", "uni06F0", "uni06F1", "uni06F2", "uni06F3", "uni06F4", "uni06F5", "uni06F6", "uni06F7", "uni06F8", "uni06F9", "uni08F0", "uni08F1", "uni08F2", "uni2000", "uni2001", "uni2002", "uni2003", "uni2004", "uni2005", "uni2006", "uni2007", "uni2008", "uni2009", "uni200A", "uni200B", "uni200C", "uni200D", "uni200E", "uni200F", "uni2028", "uni2029", "uni202A", "uni202B", "uni202C", "uni202D", "uni202E", "uni202F", "uni25CC", "uniFDFA", "uniFDFD", ) quran_glyphs += ("uni030A", "uni0325") # ring above and below subsetFont(font, quran_glyphs, True) # set font ascent to the highest glyph in the font so that waqf marks don't # get truncated # we could have set os2_typoascent_add and hhea_ascent_add, but ff makes # the offset relative to em-size in the former and font bounds in the # later, but we want both to be relative to font bounds ymax = 0 for glyph in font.glyphs(): bb = glyph.boundingBox() if bb[-1] > ymax: ymax = bb[-1] font.os2_typoascent = font.hhea_ascent = ymax # create overline glyph to be used for sajda line, it is positioned # vertically at the level of the base of waqf marks overline_pos = font[0x06D7].boundingBox()[1] makeOverUnderline(font, under=False, o_pos=overline_pos) generateFont(font, outfile)
def makeQuran(infile, outfile, feafile, version): font = makeDesktop(infile, outfile, feafile, version, False, False) # fix metadata font.fontname = font.fontname.replace("-Regular", "Quran-Regular") font.familyname += " Quran" font.fullname += " Quran" digits = ("zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine") mergeLatin(font, feafile, glyphs=digits, quran=True) punct = ("period", "guillemotleft", "guillemotright", "braceleft", "bar", "braceright", "bracketleft", "bracketright", "parenleft", "parenright", "slash", "backslash") for name in punct: if name + ".ara" in font: glyph = font[name + ".ara"] glyph.glyphname = name glyph.unicode = fontforge.unicodeFromName(name) # abuse U+065C as a below form of U+06EC, for Qaloon dotabove = font["uni06EC"] dotbelow = font["uni065C"] delta = dotbelow.boundingBox()[-1] - dotabove.boundingBox()[-1] dotbelow.references = [] dotbelow.addReference(dotabove.glyphname, psMat.translate(0, delta)) dotbelow.addAnchorPoint("TashkilTashkilBelow", "basemark", 220, dotbelow.boundingBox()[1] - 100) # scale some vowel marks and dots down a bit scaleGlyph(font["uni0651"], 0.8) for mark in ("uni064B", "uni064C", "uni064E", "uni064F", "uni06E1"): scaleGlyph(font[mark], 0.9) for dot in ("TwoDots.a", "ThreeDots.a", "vTwoDots.a"): scaleGlyph(font[dot], 0.9) quran_glyphs = [] for glyph in font.glyphs(): if glyph.name.startswith("dummy"): quran_glyphs.append(glyph.name) mergeFeatures(font, feafile) quran_glyphs += digits quran_glyphs += punct quran_glyphs += ( "space", "uni060C", "uni0615", "uni0617", "uni0618", "uni0619", "uni061A", "uni061B", "uni061E", "uni061F", "uni0621", "uni0622", "uni0623", "uni0624", "uni0625", "uni0626", "uni0627", "uni0628", "uni0629", "uni062A", "uni062B", "uni062C", "uni062D", "uni062E", "uni062F", "uni0630", "uni0631", "uni0632", "uni0633", "uni0634", "uni0635", "uni0636", "uni0637", "uni0638", "uni0639", "uni063A", "uni0640", "uni0641", "uni0642", "uni0643", "uni0644", "uni0645", "uni0646", "uni0647", "uni0648", "uni0649", "uni064A", "uni064B", "uni064C", "uni064D", "uni064E", "uni064F", "uni0650", "uni0651", "uni0652", "uni0653", "uni0654", "uni0655", "uni0656", "uni0657", "uni0658", "uni065C", "uni0660", "uni0661", "uni0662", "uni0663", "uni0664", "uni0665", "uni0666", "uni0667", "uni0668", "uni0669", "uni066E", "uni066F", "uni06A1", "uni06BA", "uni0670", "uni0671", "uni067A", "uni06CC", "uni06D6", "uni06D7", "uni06D8", "uni06D9", "uni06DA", "uni06DB", "uni06DC", "uni06DD", "uni06DE", "uni06DF", "uni06E0", "uni06E1", "uni06E2", "uni06E3", "uni06E4", "uni06E5", "uni06E6", "uni06E7", "uni06E8", "uni06E9", "uni06EA", "uni06EB", "uni06EC", "uni06ED", "uni06F0", "uni06F1", "uni06F2", "uni06F3", "uni06F4", "uni06F5", "uni06F6", "uni06F7", "uni06F8", "uni06F9", "uni08F0", "uni08F1", "uni08F2", "uni2000", "uni2001", "uni2002", "uni2003", "uni2004", "uni2005", "uni2006", "uni2007", "uni2008", "uni2009", "uni200A", "uni200B", "uni200C", "uni200D", "uni200E", "uni200F", "uni2028", "uni2029", "uni202A", "uni202B", "uni202C", "uni202D", "uni202E", "uni202F", "uni25CC", "uniFD3E", "uniFD3F", "uniFDFA", "uniFDFD") quran_glyphs += ("uni030A", "uni0325") # ring above and below subsetFont(font, quran_glyphs, True) # set font ascent to the highest glyph in the font so that waqf marks don't # get truncated # we could have set os2_typoascent_add and hhea_ascent_add, but ff makes # the offset relative to em-size in the former and font bounds in the # later, but we want both to be relative to font bounds ymax = 0 for glyph in font.glyphs(): bb = glyph.boundingBox() if bb[-1] > ymax: ymax = bb[-1] font.os2_typoascent = font.hhea_ascent = ymax # create overline glyph to be used for sajda line, it is positioned # vertically at the level of the base of waqf marks overline_pos = font[0x06D7].boundingBox()[1] makeOverUnderline(font, under=False, o_pos=overline_pos) generateFont(font, outfile)