forked from khaledhosny/ots
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME
243 lines (205 loc) · 7.4 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
------------------------------------------------------------------------------
ot-sanitise - TTF/OTF font validator/transcoder
Description:
ot-sanitise is a program which validates and/or transcodes a truetype or
opentype font file using the OTS library:
transcoded_font = ValidateAndTranscode(original_font);
if (validation_error)
PrintErrorAndExit;
OutputToStdout(transcoded_font);
Usage:
$ ./ot-sanitise ttf_or_otf_file [transcoded_file]
Example:
$ ./ot-sanitise sample.otf transcoded_sample.otf
$ ./ot-sanitise malformed.ttf
WARNING at ots/src/ots.cc:158: bad range shift
ERROR at ots/src/ots.cc:199 (bool<unnamed>::do_ots_process(ots::OpenTypeFile*, ots::OTSStream*, const uint8_t*, size_t))
Failed to sanitise file!
$
------------------------------------------------------------------------------
idempotent - TTF/OTF font transcoder (for OTS debugging)
Description:
idempotent is a program which validates and transcodes a truetype or opentype
font file using OTS. This tool transcodes the original font twice and then
verifies that the two transcoded fonts are identical:
t1 = ValidateAndTranscode(original_font);
if (validation_error)
PrintErrorAndExit;
t2 = ValidateAndTranscode(t1);
if (validation_error)
PrintErrorAndExit;
if (t1 != t2)
PrintErrorAndExit;
This tool is basically for OTS developers.
Usage:
$ ./idempotent ttf_or_otf_file
Example:
$ ./idempotent sample.otf
$ ./idempotent malformed.ttf
WARNING at ots/src/ots.cc:158: bad range shift
ERROR at ots/src/ots.cc:199 (bool<unnamed>::do_ots_process(ots::OpenTypeFile*, ots::OTSStream*, const uint8_t*, size_t))
Failed to sanitise file!
$
------------------------------------------------------------------------------
validator_checker - font validation checker
Description:
validator_checker is a program which is intended to validate malformed fonts.
If the program detects that the font is invalid, it prints "OK" and returns
with 0 (success). If it coulndn't detect any errors, the program then opens
the transcoded font and renders some characters using FreeType2:
transcoded_font = ValidateAndTranscode(malicious_font);
if (validation_error)
Print("OK");
OpenAndRenderSomeCharacters(transcoded_font); # may cause SIGSEGV
Print("OK");
If SEGV doesn't raise inside FreeType2 library, the program prints "OK" and
returns with 0 as well. You should run this tool under the catchsegv or
valgrind command so that you can easily verify that all transformed fonts
don't crash the library (see the example below).
Usage:
$ catchsegv ./validator_checker malicous_ttf_or_otf_file
Example:
$ for f in malformed/*.ttf ; do catchsegv ./validator-checker "$f" ; done
OK: the malicious font was filtered: malformed/1.ttf
OK: the malicious font was filtered: malformed/2.ttf
OK: FreeType2 didn't crash: malformed/3.ttf
OK: the malicious font was filtered: malformed/4.ttf
$
------------------------------------------------------------------------------
perf - performance checker
Description:
perf is a program which validates and transcodes a truetype or opentype font
file N times using OTS, then prints the elapsed time:
for (N times)
ValidateAndTranscode(original_font);
Print(elapsed_time_in_us / N);
Usage:
$ ./perf ttf_or_otf_file
Example:
$ ./perf sample.ttf
903 [us] sample.ttf (139332 bytes, 154 [byte/us])
$ ./perf sample-bold.otf
291 [us] sample-bold.otf (150652 bytes, 517 [byte/us])
------------------------------------------------------------------------------
side-by-side - font quality checker
Description:
side-by-side is a program which renders some characters (ASCII, Latin-1, CJK)
using both original font and transcoded font and checks that the two rendering
results are exactly equal.
The following Unicode characters are used during the test:
0x0020 - 0x007E // Basic Latin
0x00A1 - 0x017F // Latin-1
0x1100 - 0x11FF // Hangul
0x3040 - 0x309F // Japanese HIRAGANA letters
0x3130 - 0x318F // Hangul
0x4E00 - 0x4F00 // CJK Kanji/Hanja
0xAC00 - 0xAD00 // Hangul
This tool uses FreeType2 library.
Note: This tool doesn't check kerning (GPOS/kern) nor font substitution
(GSUB). These should be tested in Layout tests if necessary.
Usage:
$ ./side-by-side ttf_or_otf_file
Example:
$ ./side-by-side linux/kochi-gothic.ttf # no problem
$ ./side-by-side free/kredit1.ttf # this is known issue of OTS.
bitmap metrics doesn't match! (14, 57), (37, 45)
EXPECTED:
+#######*.
+##########+
.###+.#. .#.
*#* # #*
##. # ##
## # ##
## # ##
## #. ##
##. #. .##
##. #. .##
*#+ *+ +#*
*#+ *+ +#*
*#+ *+ +#*
*#+ *+ +#*
*#+ *+ *#*
*#+ ++ *#+
+#* +* *#+
+#* +* *#+
+#* +* *#+
+#* +* ##.
+#* +* ##.
.## .# ##
.## .# ##
.## .# ##
## # ##
## # ##
## # .##
## # .##
## .#+ +#*
## +######*
##.+#######*
*##########*
+##########+
#########*
.########
+####+
.*######*
+##*.*#####
.##+.#+ +#
*#* ## #+
##*### ##
###### ##
##+.##+ +##
## ##########
## +#########
## +########
*#. .########*
.#* #########.
+##########+
+*######*
ACTUAL:
.*##*+
+##+.##*.
.#* .##.+#*
*# ### *#+
#*######+ .*#+
#########*. +#*.
###########* +#*
*############+ *#+
+##############. .##.
*##############* +#*
+###############+ *#+
*###############+ .*#+
.###############*. +#*.
+###############* +#*
*###############+ *#+
.*###############+ .*#+
+###############*. +#*
+###############* **
*###############+ #+
.###############* ##
+############+ ##
+########* .##
.######. +###
+#####+ .*#..#
+#####* *###..#
*#####. +#######*
+#####+ .*########.
+#####* +#########*
*#####. +##########+
+#####+ *#########*.
.#####* +##########+
*#####. +##########*
+#####+ *#########*.
.#####* +##########+
*#####+ +##########*
.#*++#+ *#########*.
.#+ ## +##########+
****###+.##########*
##################.
###+ *#########+
## +########*
*#+ *########.
##.#######+
+#######*
*###*.
Glyph mismatch! (file: free/kredit1.ttf, U+0021, 100pt)!
$
------------------------------------------------------------------------------