Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | #!/usr/bin/python |
michael@0 | 2 | # vim: set shiftwidth=4 tabstop=8 autoindent expandtab: |
michael@0 | 3 | # This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | # License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | # file, You can obtain one at http://mozilla.org/MPL/2.0/. |
michael@0 | 6 | |
michael@0 | 7 | # For general fontforge documentation, see: |
michael@0 | 8 | # http://fontforge.sourceforge.net/ |
michael@0 | 9 | # For fontforge scripting documentation, see: |
michael@0 | 10 | # http://fontforge.sourceforge.net/scripting-tutorial.html |
michael@0 | 11 | # http://fontforge.sourceforge.net/scripting.html |
michael@0 | 12 | # and most importantly: |
michael@0 | 13 | # http://fontforge.sourceforge.net/python.html |
michael@0 | 14 | |
michael@0 | 15 | # To install what you need, on Ubuntu, |
michael@0 | 16 | # sudo apt-get install python-fontforge |
michael@0 | 17 | |
michael@0 | 18 | import fontforge |
michael@0 | 19 | |
michael@0 | 20 | # generate a set of fonts, each with our special glyph at one codepoint, |
michael@0 | 21 | # and nothing else |
michael@0 | 22 | for codepoint in range(ord("A"), ord("D") + 1): |
michael@0 | 23 | for (mark, width) in [("", 1500), ("2", 1800)]: |
michael@0 | 24 | charname = chr(codepoint) |
michael@0 | 25 | f = fontforge.font() |
michael@0 | 26 | n = "Mark" + mark + charname |
michael@0 | 27 | f.fontname = n |
michael@0 | 28 | f.familyname = n |
michael@0 | 29 | f.fullname = n |
michael@0 | 30 | f.copyright = "Copyright (c) 2008 Mozilla Corporation" |
michael@0 | 31 | |
michael@0 | 32 | g = f.createChar(codepoint, charname) |
michael@0 | 33 | g.importOutlines("mark" + mark + "-glyph.svg") |
michael@0 | 34 | g.width = width |
michael@0 | 35 | |
michael@0 | 36 | f.generate("mark" + mark + charname + ".ttf") |
michael@0 | 37 | f.generate("mark" + mark + charname + ".otf") |
michael@0 | 38 | |
michael@0 | 39 | |
michael@0 | 40 | for codepoint in range(ord("A"), ord("A") + 1): |
michael@0 | 41 | for (mark, width) in [("", 1500), ("2", 1800)]: |
michael@0 | 42 | for (uposname, upos) in [("low", -350), ("high", -50)]: |
michael@0 | 43 | charname = chr(codepoint) |
michael@0 | 44 | f = fontforge.font() |
michael@0 | 45 | n = "Mark" + mark + charname |
michael@0 | 46 | f.fontname = n |
michael@0 | 47 | f.familyname = n |
michael@0 | 48 | f.fullname = n |
michael@0 | 49 | f.descent = 400 |
michael@0 | 50 | f.upos = upos |
michael@0 | 51 | f.uwidth = 100 |
michael@0 | 52 | f.copyright = "Copyright (c) 2008 Mozilla Corporation" |
michael@0 | 53 | |
michael@0 | 54 | g = f.createChar(codepoint, charname) |
michael@0 | 55 | g.importOutlines("mark" + mark + "-glyph.svg") |
michael@0 | 56 | g.width = width |
michael@0 | 57 | |
michael@0 | 58 | f.generate("mark" + mark + charname + "-" + uposname + |
michael@0 | 59 | "underline.ttf") |
michael@0 | 60 | |
michael@0 | 61 | # font with a ligature involving a space |
michael@0 | 62 | |
michael@0 | 63 | f = fontforge.font() |
michael@0 | 64 | n = "MarkAB-spaceliga" |
michael@0 | 65 | f.fontname = n |
michael@0 | 66 | f.familyname = n |
michael@0 | 67 | f.fullname = n |
michael@0 | 68 | f.copyright = "Copyright (c) 2008-2011 Mozilla Corporation" |
michael@0 | 69 | |
michael@0 | 70 | g = f.createChar(ord(" "), "space") |
michael@0 | 71 | g.width = 1000 |
michael@0 | 72 | for charname in ["A", "B"]: |
michael@0 | 73 | g = f.createChar(ord(charname), charname) |
michael@0 | 74 | g.importOutlines("mark-glyph.svg") |
michael@0 | 75 | g.width = 1500 |
michael@0 | 76 | |
michael@0 | 77 | f.addLookup("liga-table", "gsub_ligature", (), (("liga",(("latn",("dflt")),)),)) |
michael@0 | 78 | f.addLookupSubtable("liga-table", "liga-subtable") |
michael@0 | 79 | g = f.createChar(-1, "spaceA") |
michael@0 | 80 | g.glyphclass = "baseligature"; |
michael@0 | 81 | g.addPosSub("liga-subtable", ("space", "A")) |
michael@0 | 82 | g.importOutlines("mark2-glyph.svg") |
michael@0 | 83 | g.width = 1800 |
michael@0 | 84 | |
michael@0 | 85 | f.generate("markAB-spaceliga.otf") |
michael@0 | 86 | |
michael@0 | 87 | # font with a known line-height (which is greater than winascent + windescent). |
michael@0 | 88 | |
michael@0 | 89 | f = fontforge.font() |
michael@0 | 90 | lineheight = 1500 |
michael@0 | 91 | n = "MarkA-lineheight" + str(lineheight) |
michael@0 | 92 | f.fontname = n |
michael@0 | 93 | f.familyname = n |
michael@0 | 94 | f.fullname = n |
michael@0 | 95 | f.copyright = "Copyright (c) 2008-2011 Mozilla Corporation" |
michael@0 | 96 | |
michael@0 | 97 | g = f.createChar(ord(" "), "space") |
michael@0 | 98 | g.width = 1000 |
michael@0 | 99 | g = f.createChar(ord("A"), "A") |
michael@0 | 100 | g.importOutlines("mark-glyph.svg") |
michael@0 | 101 | g.width = 1500 |
michael@0 | 102 | |
michael@0 | 103 | f.os2_typoascent_add = False |
michael@0 | 104 | f.os2_typoascent = 800 |
michael@0 | 105 | f.os2_typodescent_add = False |
michael@0 | 106 | f.os2_typodescent = -200 |
michael@0 | 107 | f.os2_use_typo_metrics = True |
michael@0 | 108 | f.os2_typolinegap = lineheight - (f.os2_typoascent - f.os2_typodescent) |
michael@0 | 109 | # glyph height is 800 (hhea ascender - descender) |
michael@0 | 110 | f.hhea_linegap = lineheight - 800 |
michael@0 | 111 | |
michael@0 | 112 | f.generate("markA-lineheight" + str(lineheight) + ".ttf") |