Thu, 15 Jan 2015 15:59:08 +0100
Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.
1 #!/usr/bin/python
2 # vim: set shiftwidth=4 tabstop=8 autoindent expandtab:
3 # This Source Code Form is subject to the terms of the Mozilla Public
4 # License, v. 2.0. If a copy of the MPL was not distributed with this
5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
7 # For general fontforge documentation, see:
8 # http://fontforge.sourceforge.net/
9 # For fontforge scripting documentation, see:
10 # http://fontforge.sourceforge.net/scripting-tutorial.html
11 # http://fontforge.sourceforge.net/scripting.html
12 # and most importantly:
13 # http://fontforge.sourceforge.net/python.html
15 # To install what you need, on Ubuntu,
16 # sudo apt-get install python-fontforge
18 import fontforge
20 # generate a set of fonts, each with our special glyph at one codepoint,
21 # and nothing else
22 for codepoint in range(ord("A"), ord("D") + 1):
23 for (mark, width) in [("", 1500), ("2", 1800)]:
24 charname = chr(codepoint)
25 f = fontforge.font()
26 n = "Mark" + mark + charname
27 f.fontname = n
28 f.familyname = n
29 f.fullname = n
30 f.copyright = "Copyright (c) 2008 Mozilla Corporation"
32 g = f.createChar(codepoint, charname)
33 g.importOutlines("mark" + mark + "-glyph.svg")
34 g.width = width
36 f.generate("mark" + mark + charname + ".ttf")
37 f.generate("mark" + mark + charname + ".otf")
40 for codepoint in range(ord("A"), ord("A") + 1):
41 for (mark, width) in [("", 1500), ("2", 1800)]:
42 for (uposname, upos) in [("low", -350), ("high", -50)]:
43 charname = chr(codepoint)
44 f = fontforge.font()
45 n = "Mark" + mark + charname
46 f.fontname = n
47 f.familyname = n
48 f.fullname = n
49 f.descent = 400
50 f.upos = upos
51 f.uwidth = 100
52 f.copyright = "Copyright (c) 2008 Mozilla Corporation"
54 g = f.createChar(codepoint, charname)
55 g.importOutlines("mark" + mark + "-glyph.svg")
56 g.width = width
58 f.generate("mark" + mark + charname + "-" + uposname +
59 "underline.ttf")
61 # font with a ligature involving a space
63 f = fontforge.font()
64 n = "MarkAB-spaceliga"
65 f.fontname = n
66 f.familyname = n
67 f.fullname = n
68 f.copyright = "Copyright (c) 2008-2011 Mozilla Corporation"
70 g = f.createChar(ord(" "), "space")
71 g.width = 1000
72 for charname in ["A", "B"]:
73 g = f.createChar(ord(charname), charname)
74 g.importOutlines("mark-glyph.svg")
75 g.width = 1500
77 f.addLookup("liga-table", "gsub_ligature", (), (("liga",(("latn",("dflt")),)),))
78 f.addLookupSubtable("liga-table", "liga-subtable")
79 g = f.createChar(-1, "spaceA")
80 g.glyphclass = "baseligature";
81 g.addPosSub("liga-subtable", ("space", "A"))
82 g.importOutlines("mark2-glyph.svg")
83 g.width = 1800
85 f.generate("markAB-spaceliga.otf")
87 # font with a known line-height (which is greater than winascent + windescent).
89 f = fontforge.font()
90 lineheight = 1500
91 n = "MarkA-lineheight" + str(lineheight)
92 f.fontname = n
93 f.familyname = n
94 f.fullname = n
95 f.copyright = "Copyright (c) 2008-2011 Mozilla Corporation"
97 g = f.createChar(ord(" "), "space")
98 g.width = 1000
99 g = f.createChar(ord("A"), "A")
100 g.importOutlines("mark-glyph.svg")
101 g.width = 1500
103 f.os2_typoascent_add = False
104 f.os2_typoascent = 800
105 f.os2_typodescent_add = False
106 f.os2_typodescent = -200
107 f.os2_use_typo_metrics = True
108 f.os2_typolinegap = lineheight - (f.os2_typoascent - f.os2_typodescent)
109 # glyph height is 800 (hhea ascender - descender)
110 f.hhea_linegap = lineheight - 800
112 f.generate("markA-lineheight" + str(lineheight) + ".ttf")