From 44928b3e4ed601cdf5afd19c5abb613fe3e8b4a0 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 23 Jul 2012 21:54:54 +0000 Subject: amiri 0.104 (23jul12) git-svn-id: svn://tug.org/texlive/trunk@27114 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/fonts/amiri/tools/build.py | 110 ++++++++++++++++------- 1 file changed, 79 insertions(+), 31 deletions(-) (limited to 'Master/texmf-dist/doc/fonts/amiri/tools') diff --git a/Master/texmf-dist/doc/fonts/amiri/tools/build.py b/Master/texmf-dist/doc/fonts/amiri/tools/build.py index 72e9993d768..a2573752d8c 100755 --- a/Master/texmf-dist/doc/fonts/amiri/tools/build.py +++ b/Master/texmf-dist/doc/fonts/amiri/tools/build.py @@ -13,6 +13,9 @@ # with this software. If not, see # . +# minimum required FontForge version +min_ff_version = "20120702" + import fontforge import psMat import sys @@ -300,7 +303,7 @@ def buildLatinExtras(font, italic): medium.width = 900 centerGlyph(medium) -def mergeLatin(font, italic=False): +def mergeLatin(font, feafile, italic=False): styles = {"Regular": "Roman", "Slanted": "Italic", "Bold": "Bold", @@ -335,10 +338,18 @@ def mergeLatin(font, italic=False): # keep also Unicode Latin Extended-A block if glyph.glyphname not in latinglyphs: latinglyphs.append(glyph.glyphname) + elif glyph.unicode == -1 and '.prop' in glyph.glyphname: + # proportional digits + latinglyphs.append(glyph.glyphname) # keep ligatures too - ligatures = ("f_f", "f_i", "f_f_i", "f_l", "f_f_l", "f_b", "f_f_b", "f_k", - "f_f_k", "f_h", "f_f_h", "f_j", "f_f_j", "T_h") + ligatures = ("f_b", "f_f_b", + "f_h", "f_f_h", + "f_i", "f_f_i", + "f_j", "f_f_j", + "f_k", "f_f_k", + "f_l", "f_f_l", + "f_f") # and Arabic romanisation characters romanisation = ("afii57929", "uni02BE", "uni02BE", "amacron", "uni02BE", @@ -400,19 +411,20 @@ def mergeLatin(font, italic=False): shared = ("exclam", "quotedbl", "numbersign", "dollar", "percent", "quotesingle", "parenleft", "parenright", "asterisk", "plus", - "slash", "zero", "one", "two", "three", "four", "five", - "six", "seven", "eight", "nine", "colon", "semicolon", - "less", "equal", "greater", "question", "at", "bracketleft", - "backslash", "bracketright", "asciicircum", "braceleft", - "bar", "braceright", "brokenbar", "section", "copyright", - "guillemotleft", "logicalnot", "registered", "plusminus", - "uni00B2", "uni00B3", "paragraph", "uni00B9", "ordmasculine", - "guillemotright", "onequarter", "onehalf", "threequarters", - "questiondown", "quoteleft", "quoteright", "quotesinglbase", - "quotereversed", "quotedblleft", "quotedblright", - "quotedblbase", "uni201F", "dagger", "daggerdbl", - "perthousand", "minute", "second", "guilsinglleft", - "guilsinglright", "fraction", "uni2213") + "slash", "colon", "semicolon", "less", "equal", "greater", + "question", "at", "bracketleft", "backslash", "bracketright", + "asciicircum", "braceleft", "bar", "braceright", "brokenbar", + "section", "copyright", "guillemotleft", "logicalnot", + "registered", "plusminus", "uni00B2", "uni00B3", "paragraph", + "uni00B9", "ordmasculine", "guillemotright", "onequarter", + "onehalf", "threequarters", "questiondown", "quoteleft", + "quoteright", "quotesinglbase", "quotereversed", + "quotedblleft", "quotedblright", "quotedblbase", "uni201F", + "dagger", "daggerdbl", "perthousand", "minute", "second", + "guilsinglleft", "guilsinglright", "fraction", "uni2213") + + digits = ("zero", "one", "two", "three", "four", "five", "six", + "seven", "eight", "nine") for name in shared: glyph = latinfont[name] @@ -429,6 +441,34 @@ def mergeLatin(font, italic=False): rtl.addReference(name, italic) rtl.useRefsMetrics(name) + for name in digits: + glyph = latinfont[name] + glyph.glyphname += '.ltr' + glyph.unicode = -1 + upright.selection.select(name) + upright.copy() + latinfont.createChar(upright[name].encoding, name) + latinfont.selection.select(name) + latinfont.paste() + + rtl = latinfont.createChar(-1, name + ".rtl") + rtl.addReference(name, italic) + rtl.useRefsMetrics(name) + + for name in digits: + pname = name + ".prop" + upright.selection.select(pname) + upright.copy() + latinfont.createChar(-1, pname) + latinfont.selection.select(pname) + latinfont.paste() + + for name in digits: + pname = name + ".prop" + rtl = latinfont.createChar(-1, name + ".rtl" + ".prop") + rtl.addReference(pname, italic) + rtl.useRefsMetrics(pname) + # copy kerning classes kern_lookups = {} for lookup in latinfont.gpos_lookups: @@ -455,16 +495,15 @@ def mergeLatin(font, italic=False): # we want to merge features after merging the latin font because many # referenced glyphs are in the latin font - if font.sfd_path: - feafile = os.path.splitext(font.sfd_path)[0] + '.fea' - mergeFeatures(font, feafile) - - font.mergeFeature("sources/latin_gsub.fea") if italic: font.mergeFeature("sources/italic_ltra.fea") font.mergeFeature("sources/italic_rtla.fea") + mergeFeatures(font, feafile) + + font.mergeFeature("sources/latin_gsub.fea") + for lookup in kern_lookups: font.addLookup(lookup, kern_lookups[lookup]["type"], @@ -554,9 +593,9 @@ def makeWeb(infile, outfile): os.remove(tmpfont) -def makeSlanted(infile, outfile, version, slant): +def makeSlanted(infile, outfile, feafile, version, slant): - font = makeDesktop(infile, outfile, version, False, False) + font = makeDesktop(infile, outfile, feafile, version, False, False) # compute amout of skew, magic formula copied from fontforge sources skew = psMat.skew(-slant * math.pi/180.0) @@ -575,11 +614,11 @@ def makeSlanted(infile, outfile, version, slant): font.fontname = font.fontname.replace("Regular", "Slanted") font.appendSFNTName("Arabic (Egypt)", "SubFamily", "مائل") - mergeLatin(font, skew) + mergeLatin(font, feafile, skew) generateFont(font, outfile) -def makeDesktop(infile, outfile, version, latin=True, generate=True): +def makeDesktop(infile, outfile, feafile, version, latin=True, generate=True): font = fontforge.open(infile) if version: @@ -597,7 +636,7 @@ def makeDesktop(infile, outfile, version, latin=True, generate=True): font.appendSFNTName(lang, 'Sample Text', sample) if latin: - mergeLatin(font) + mergeLatin(font, feafile) if generate: generateFont(font, outfile, True) @@ -613,6 +652,7 @@ def usage(extramessage, code): Options: --input=FILE file name of input font --output=FILE file name of output font + --features=FILE file name of features file --version=VALUE set font version to VALUE --slant=VALUE autoslant --css output is a CSS file @@ -625,15 +665,20 @@ Options: sys.exit(code) if __name__ == "__main__": + if fontforge.version() < min_ff_version: + print "You need FontForge %s or newer to build Amiri fonts" %min_ff_version + sys.exit(-1) + try: opts, args = getopt.gnu_getopt(sys.argv[1:], "h", - ["help","input=","output=", "version=", "slant=", "css", "web"]) + ["help", "input=", "output=", "features=", "version=", "slant=", "css", "web"]) except getopt.GetoptError, err: usage(str(err), -1) infile = None outfile = None + feafile = None version = None slant = False css = False @@ -644,15 +689,16 @@ if __name__ == "__main__": usage("", 0) elif opt == "--input": infile = arg elif opt == "--output": outfile = arg + elif opt == "--features": feafile = arg elif opt == "--version": version = arg elif opt == "--slant": slant = float(arg) elif opt == "--css": css = True elif opt == "--web": web = True if not infile: - usage("No input file", -1) + usage("No input file specified", -1) if not outfile: - usage("No output file", -1) + usage("No output file specified", -1) if css: makeCss(infile, outfile) @@ -661,8 +707,10 @@ if __name__ == "__main__": else: if not version: usage("No version specified", -1) + if not feafile: + usage("No features file specified", -1) if slant: - makeSlanted(infile, outfile, version, slant) + makeSlanted(infile, outfile, feafile, version, slant) else: - makeDesktop(infile, outfile, version) + makeDesktop(infile, outfile, feafile, version) -- cgit v1.2.3