Flutter Engine
The Flutter Engine
Functions | Variables
gen_test_font Namespace Reference

Functions

def glyph_program (glyph)
 
def square_glyph (glyph)
 Creating Glyphs Outlines. More...
 
def ascent_flushed_glyph (glyph)
 
def descent_flushed_glyph (glyph)
 
def not_def_glyph (glyph)
 
def unicode_range (fromUnicode, throughUnicode)
 
def create_glyph (name, contour)
 
def create_no_path_glyph (codepoint, advance_percentage)
 
def describe_codepoint_range (codepoints)
 

Variables

string NAME = "FlutterTest"
 
string TRICKY_NAME = "MingLiU"
 
int EM = 1024
 
int DESCENT = -EM // 4
 
int ASCENT = EM + DESCENT
 
int UPOS = -143 * 1000 // EM
 
int UWIDTH = 20 * 1000 // EM
 
 font = fontforge.font()
 Font Metadata and Metrics. More...
 
 familyname
 
 fullname
 
 fontname
 
 ascent
 
 descent
 
 upos
 
 uwidth
 
 hhea_linegap
 
 os2_typolinegap
 
 horizontalBaseline
 
 cvt
 TrueType Hinting. More...
 
 gcd = math.gcd(ASCENT, EM)
 
string prep_program
 
list square_codepoints
 
list no_path_codepoints
 
 altuni
 
 unicode
 
 scripts = set()
 Printing Glyph Map Stats. More...
 
 script_list = list(scripts)
 
dictionary glyph_mapping = {}
 
 script = fontforge.scriptFromUnicode(codepoint)
 
list codepoints_by_script = [glyph_mapping.get(script, []) for script in script_list]
 

Function Documentation

◆ ascent_flushed_glyph()

def gen_test_font.ascent_flushed_glyph (   glyph)

Definition at line 145 of file gen_test_font.py.

145def ascent_flushed_glyph(glyph):
146 pen = glyph.glyphPen()
147 pen.moveTo((0, DESCENT))
148 pen.lineTo((0, 0))
149 pen.lineTo((EM, 0))
150 pen.lineTo((EM, DESCENT))
151 pen.closePath()
152 glyph.ttinstrs = glyph_program(glyph)
153
154
def glyph_program(glyph)
def ascent_flushed_glyph(glyph)

◆ create_glyph()

def gen_test_font.create_glyph (   name,
  contour 
)

Definition at line 238 of file gen_test_font.py.

238def create_glyph(name, contour):
239 glyph = font.createChar(-1, name)
240 contour(glyph)
241 glyph.width = EM
242 return glyph
243
244
def create_glyph(name, contour)

◆ create_no_path_glyph()

def gen_test_font.create_no_path_glyph (   codepoint,
  advance_percentage 
)

Definition at line 252 of file gen_test_font.py.

252def create_no_path_glyph(codepoint, advance_percentage):
253 name = "Zero Advance" if advance_percentage == 0 else (
254 "Full Advance" if advance_percentage == 1 else f"1/{(int)(1/advance_percentage)} Advance"
255 )
256 no_path_glyph = font.createChar(codepoint, name)
257 no_path_glyph.width = (int)(EM * advance_percentage)
258 return no_path_glyph
259
260
def create_no_path_glyph(codepoint, advance_percentage)

◆ descent_flushed_glyph()

def gen_test_font.descent_flushed_glyph (   glyph)

Definition at line 155 of file gen_test_font.py.

155def descent_flushed_glyph(glyph):
156 pen = glyph.glyphPen()
157 pen.moveTo((0, 0))
158 pen.lineTo((0, ASCENT))
159 pen.lineTo((EM, ASCENT))
160 pen.lineTo((EM, 0))
161 pen.closePath()
162 glyph.ttinstrs = glyph_program(glyph)
163
164
def descent_flushed_glyph(glyph)

◆ describe_codepoint_range()

def gen_test_font.describe_codepoint_range (   codepoints)

Definition at line 297 of file gen_test_font.py.

297 def describe_codepoint_range(codepoints):
298 if not codepoints:
299 return ""
300 codepoints.sort()
301 codepoint_ranges = [
302 list(map(itemgetter(1), group))
303 for key, group in groupby(enumerate(codepoints), lambda x: x[0] - x[1])
304 ]
305 characters = [chr(c) for c in codepoints]
306
307 def map_char(c):
308 if c == "`":
309 return "`` ` ``"
310 if c == "|":
311 return "`\\|`"
312 if c.isprintable() and (not c.isspace()):
313 return f"`{c}`"
314 return "`<" + unicodedata.name(c, hex(ord(c))) + ">`"
315
316 full_list = " ".join([map_char(c) for c in characters])
317 return "**codepoint(s):** " + ", ".join([
318 f"{hex(r[0])}-{hex(r[-1])}" if len(r) > 1 else hex(r[0]) for r in codepoint_ranges
319 ]) + "<br />" + "**character(s):** " + full_list
320
def describe_codepoint_range(codepoints)
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>
Definition: SkVx.h:680
static SkString join(const CommandLineFlags::StringArray &)
Definition: skpbench.cpp:741

◆ glyph_program()

def gen_test_font.glyph_program (   glyph)

Definition at line 96 of file gen_test_font.py.

96def glyph_program(glyph):
97 # Shift Zone 1 by CVT[0]. In FreeType SHZ actually shifts the zone zp2
98 # points to, instead of top of the stack. That's probably a bug.
99 instructions = """
100 SVTCA[0]
101 PUSHB_4
102 0
103 0
104 0
105 0
106 SZPS
107 MIRP[0000]
108 SRP2
109 PUSHB_3
110 1
111 1
112 1
113 SZP2
114 SHZ[0]
115 SZPS
116 """
117
118 # Round To Grid every on-curve point, but ignore those who are on the ASCENT
119 # or DESCENT line. This step keeps "p" (ascent flushed) and "É" (descent
120 # flushed)'s y extents from overlapping each other.
121 for index, point in enumerate([p for contour in glyph.foreground for p in contour]):
122 if point.y not in [ASCENT, DESCENT]:
123 instructions += f"""
124 PUSHB_1
125 {index}
126 MDAP[1]
127 """
128 return fontforge.parseTTInstrs(instructions)
129
130

◆ not_def_glyph()

def gen_test_font.not_def_glyph (   glyph)

Definition at line 165 of file gen_test_font.py.

165def not_def_glyph(glyph):
166 pen = glyph.glyphPen()
167 # Counter Clockwise for the outer contour.
168 pen.moveTo((EM // 8, 0))
169 pen.lineTo((EM // 8, ASCENT))
170 pen.lineTo((EM - EM // 8, ASCENT))
171 pen.lineTo((EM - EM // 8, 0))
172 pen.closePath()
173 # Clockwise, inner contour.
174 pen.moveTo((EM // 4, EM // 8))
175 pen.lineTo((EM - EM // 4, EM // 8))
176 pen.lineTo((EM - EM // 4, ASCENT - EM // 8))
177 pen.lineTo((EM // 4, ASCENT - EM // 8))
178 pen.closePath()
179 glyph.ttinstrs = glyph_program(glyph)
180
181
def not_def_glyph(glyph)

◆ square_glyph()

def gen_test_font.square_glyph (   glyph)

Creating Glyphs Outlines.

Definition at line 134 of file gen_test_font.py.

134def square_glyph(glyph):
135 pen = glyph.glyphPen()
136 # Counter Clockwise
137 pen.moveTo((0, DESCENT))
138 pen.lineTo((0, ASCENT))
139 pen.lineTo((EM, ASCENT))
140 pen.lineTo((EM, DESCENT))
141 pen.closePath()
142 glyph.ttinstrs = glyph_program(glyph)
143
144
def square_glyph(glyph)
Creating Glyphs Outlines.

◆ unicode_range()

def gen_test_font.unicode_range (   fromUnicode,
  throughUnicode 
)

Definition at line 182 of file gen_test_font.py.

182def unicode_range(fromUnicode, throughUnicode):
183 return range(fromUnicode, throughUnicode + 1)
184
185
def unicode_range(fromUnicode, throughUnicode)

Variable Documentation

◆ altuni

gen_test_font.altuni

Definition at line 246 of file gen_test_font.py.

◆ ASCENT

int gen_test_font.ASCENT = EM + DESCENT

Definition at line 19 of file gen_test_font.py.

◆ ascent

gen_test_font.ascent

Definition at line 32 of file gen_test_font.py.

◆ codepoints_by_script

list gen_test_font.codepoints_by_script = [glyph_mapping.get(script, []) for script in script_list]

Definition at line 295 of file gen_test_font.py.

◆ cvt

gen_test_font.cvt

TrueType Hinting.

Definition at line 71 of file gen_test_font.py.

◆ DESCENT

int gen_test_font.DESCENT = -EM // 4

Definition at line 18 of file gen_test_font.py.

◆ descent

gen_test_font.descent

Definition at line 33 of file gen_test_font.py.

◆ EM

int gen_test_font.EM = 1024

Definition at line 17 of file gen_test_font.py.

◆ familyname

gen_test_font.familyname

Definition at line 27 of file gen_test_font.py.

◆ font

gen_test_font.font = fontforge.font()

Font Metadata and Metrics.

Definition at line 26 of file gen_test_font.py.

◆ fontname

gen_test_font.fontname

Definition at line 29 of file gen_test_font.py.

◆ fullname

gen_test_font.fullname

Definition at line 28 of file gen_test_font.py.

◆ gcd

gen_test_font.gcd = math.gcd(ASCENT, EM)

Definition at line 73 of file gen_test_font.py.

◆ glyph_mapping

dictionary gen_test_font.glyph_mapping = {}

Definition at line 285 of file gen_test_font.py.

◆ hhea_linegap

gen_test_font.hhea_linegap

Definition at line 36 of file gen_test_font.py.

◆ horizontalBaseline

gen_test_font.horizontalBaseline

Definition at line 39 of file gen_test_font.py.

◆ NAME

string gen_test_font.NAME = "FlutterTest"

Definition at line 13 of file gen_test_font.py.

◆ no_path_codepoints

list gen_test_font.no_path_codepoints
Initial value:
1= [
2 #(codepoint, advance %)
3 (0x0020, 1),
4 (0x00A0, 1),
5 (0x2003, 1),
6 (0x3000, 1),
7 (0x2002, 1 / 2),
8 (0x2004, 1 / 3),
9 (0x2005, 1 / 4),
10 (0x2006, 1 / 6),
11 (0x2009, 1 / 5),
12 (0x200A, 1 / 10),
13 (0xFEFF, 0),
14 (0x200B, 0),
15 (0x200C, 0),
16 (0x200D, 0),
17]

Definition at line 219 of file gen_test_font.py.

◆ os2_typolinegap

gen_test_font.os2_typolinegap

Definition at line 37 of file gen_test_font.py.

◆ prep_program

string gen_test_font.prep_program
Initial value:
1= f"""
2 RTG
3 PUSHW_1
4 0
5 MPS
6 PUSHW_1
7 {(ASCENT << 6) // gcd}
8 MUL
9 PUSHW_1
10 {EM // gcd}
11 DIV
12 DUP
13 CEILING
14 SUB
15 WCVTP
16"""

Definition at line 77 of file gen_test_font.py.

◆ script

gen_test_font.script = fontforge.scriptFromUnicode(codepoint)

Definition at line 289 of file gen_test_font.py.

◆ script_list

gen_test_font.script_list = list(scripts)

Definition at line 276 of file gen_test_font.py.

◆ scripts

gen_test_font.scripts = set()

Printing Glyph Map Stats.

Definition at line 270 of file gen_test_font.py.

◆ square_codepoints

list gen_test_font.square_codepoints

Definition at line 186 of file gen_test_font.py.

◆ TRICKY_NAME

string gen_test_font.TRICKY_NAME = "MingLiU"

Definition at line 16 of file gen_test_font.py.

◆ unicode

gen_test_font.unicode

Definition at line 247 of file gen_test_font.py.

◆ UPOS

int gen_test_font.UPOS = -143 * 1000 // EM

Definition at line 21 of file gen_test_font.py.

◆ upos

gen_test_font.upos

Definition at line 34 of file gen_test_font.py.

◆ UWIDTH

int gen_test_font.UWIDTH = 20 * 1000 // EM

Definition at line 22 of file gen_test_font.py.

◆ uwidth

gen_test_font.uwidth

Definition at line 35 of file gen_test_font.py.