1 ------------------------------------------------------------------------------
2 ot-sanitise - TTF/OTF font validator/transcoder
5 ot-sanitise is a program which validates and/or transcodes a truetype or
6 opentype font file using the OTS library:
8 transcoded_font = ValidateAndTranscode(original_font);
11 OutputToStdout(transcoded_font);
14 $ ./ot-sanitise ttf_or_otf_file [transcoded_file]
17 $ ./ot-sanitise sample.otf transcoded_sample.otf
18 $ ./ot-sanitise malformed.ttf
19 WARNING at ots/src/ots.cc:158: bad range shift
20 ERROR at ots/src/ots.cc:199 (bool<unnamed>::do_ots_process(ots::OpenTypeFile*, ots::OTSStream*, const uint8_t*, size_t))
21 Failed to sanitise file!
24 ------------------------------------------------------------------------------
25 idempotent - TTF/OTF font transcoder (for OTS debugging)
28 idempotent is a program which validates and transcodes a truetype or opentype
29 font file using OTS. This tool transcodes the original font twice and then
30 verifies that the two transcoded fonts are identical:
32 t1 = ValidateAndTranscode(original_font);
35 t2 = ValidateAndTranscode(t1);
41 This tool is basically for OTS developers.
44 $ ./idempotent ttf_or_otf_file
47 $ ./idempotent sample.otf
48 $ ./idempotent malformed.ttf
49 WARNING at ots/src/ots.cc:158: bad range shift
50 ERROR at ots/src/ots.cc:199 (bool<unnamed>::do_ots_process(ots::OpenTypeFile*, ots::OTSStream*, const uint8_t*, size_t))
51 Failed to sanitise file!
54 ------------------------------------------------------------------------------
55 validator_checker - font validation checker
58 validator_checker is a program which is intended to validate malformed fonts.
59 If the program detects that the font is invalid, it prints "OK" and returns
60 with 0 (success). If it coulndn't detect any errors, the program then opens
61 the transcoded font and renders some characters using FreeType2:
63 transcoded_font = ValidateAndTranscode(malicious_font);
66 OpenAndRenderSomeCharacters(transcoded_font); # may cause SIGSEGV
69 If SEGV doesn't raise inside FreeType2 library, the program prints "OK" and
70 returns with 0 as well. You should run this tool under the catchsegv or
71 valgrind command so that you can easily verify that all transformed fonts
72 don't crash the library (see the example below).
75 $ catchsegv ./validator_checker malicous_ttf_or_otf_file
78 $ for f in malformed/*.ttf ; do catchsegv ./validator-checker "$f" ; done
79 OK: the malicious font was filtered: malformed/1.ttf
80 OK: the malicious font was filtered: malformed/2.ttf
81 OK: FreeType2 didn't crash: malformed/3.ttf
82 OK: the malicious font was filtered: malformed/4.ttf
85 ------------------------------------------------------------------------------
86 perf - performance checker
89 perf is a program which validates and transcodes a truetype or opentype font
90 file N times using OTS, then prints the elapsed time:
93 ValidateAndTranscode(original_font);
94 Print(elapsed_time_in_us / N);
97 $ ./perf ttf_or_otf_file
101 903 [us] sample.ttf (139332 bytes, 154 [byte/us])
102 $ ./perf sample-bold.otf
103 291 [us] sample-bold.otf (150652 bytes, 517 [byte/us])
105 ------------------------------------------------------------------------------
106 side-by-side - font quality checker
109 side-by-side is a program which renders some characters (ASCII, Latin-1, CJK)
110 using both original font and transcoded font and checks that the two rendering
111 results are exactly equal.
113 The following Unicode characters are used during the test:
114 0x0020 - 0x007E // Basic Latin
115 0x00A1 - 0x017F // Latin-1
116 0x1100 - 0x11FF // Hangul
117 0x3040 - 0x309F // Japanese HIRAGANA letters
118 0x3130 - 0x318F // Hangul
119 0x4E00 - 0x4F00 // CJK Kanji/Hanja
120 0xAC00 - 0xAD00 // Hangul
122 This tool uses FreeType2 library.
123 Note: This tool doesn't check kerning (GPOS/kern) nor font substitution
124 (GSUB). These should be tested in Layout tests if necessary.
127 $ ./side-by-side ttf_or_otf_file
130 $ ./side-by-side linux/kochi-gothic.ttf # no problem
131 $ ./side-by-side free/kredit1.ttf # this is known issue of OTS.
132 bitmap metrics doesn't match! (14, 57), (37, 45)
202 +##############. .##.
204 +###############+ *#+
205 *###############+ .*#+
206 .###############*. +#*.
207 +###############* +#*
208 *###############+ *#+
209 .*###############+ .*#+
210 +###############*. +#*
241 Glyph mismatch! (file: free/kredit1.ttf, U+0021, 100pt)!
243 ------------------------------------------------------------------------------