font_test_data/
lib.rs

1//! test data shared between various fontations crates.
2
3pub mod bebuffer;
4pub mod cmap;
5pub mod gdef;
6pub mod gpos;
7pub mod gsub;
8pub mod ift;
9pub mod layout;
10
11pub static CMAP12_FONT1: &[u8] = include_bytes!("../test_data/ttf/cmap12_font1.ttf");
12
13pub static CMAP14_FONT1: &[u8] = include_bytes!("../test_data/ttf/cmap14_font1.ttf");
14
15pub static CMAP4_SYMBOL_PUA: &[u8] = include_bytes!("../test_data/ttf/cmap4_symbol_pua.ttf");
16
17pub static COLR_GRADIENT_RECT: &[u8] =
18    include_bytes!("../test_data/ttf/linear_gradient_rect_colr_1.ttf");
19
20pub static VAZIRMATN_VAR: &[u8] = include_bytes!("../test_data/ttf/vazirmatn_var_trimmed.ttf");
21
22pub static NAMES_ONLY: &[u8] = include_bytes!("../test_data/ttf/names_only.ttf");
23
24pub static VAZIRMATN_VAR_GLYPHS: &str =
25    include_str!("../test_data/extracted/vazirmatn_var_trimmed-glyphs.txt");
26
27pub static SIMPLE_GLYF: &[u8] = include_bytes!("../test_data/ttf/simple_glyf.ttf");
28
29pub static CUBIC_GLYF: &[u8] = include_bytes!("../test_data/ttf/cubic_glyf.ttf");
30
31pub static NOTO_SERIF_DISPLAY_TRIMMED: &[u8] =
32    include_bytes!("../test_data/ttf/noto_serif_display_trimmed.ttf");
33
34pub static NOTO_SERIF_DISPLAY_TRIMMED_GLYPHS: &str =
35    include_str!("../test_data/extracted/noto_serif_display_trimmed-glyphs.txt");
36
37pub static NOTO_SANS_JP_CFF: &[u8] =
38    include_bytes!("../test_data/ttf/NotoSansJP-Regular.subset.otf");
39
40pub static CANTARELL_VF_TRIMMED: &[u8] =
41    include_bytes!("../test_data/ttf/cantarell_vf_trimmed.ttf");
42
43pub static CANTARELL_VF_TRIMMED_GLYPHS: &str =
44    include_str!("../test_data/extracted/cantarell_vf_trimmed-glyphs.txt");
45
46pub static CHARSTRING_PATH_OPS: &[u8] = include_bytes!("../test_data/ttf/charstring_path_ops.ttf");
47
48pub static EMBEDDED_BITMAPS: &[u8] = include_bytes!("../test_data/ttf/embedded_bitmaps.ttf");
49pub static CBDT: &[u8] = include_bytes!("../test_data/ttf/cbdt.ttf");
50
51pub static HVAR_WITH_TRUNCATED_ADVANCE_INDEX_MAP: &[u8] =
52    include_bytes!("../test_data/ttf/hvar_with_truncated_adv_index_map.ttf");
53
54pub static COLRV0V1: &[u8] = include_bytes!("../test_data/ttf/test_glyphs-glyf_colr_1.ttf");
55
56pub static COLRV0V1_VARIABLE: &[u8] =
57    include_bytes!("../test_data/ttf/test_glyphs-glyf_colr_1_variable.ttf");
58
59pub static COLRV1_NO_CLIPLIST: &[u8] =
60    include_bytes!("../test_data/ttf/test_glyphs-glyf_colr_1_no_cliplist.subset.ttf");
61
62pub static CVAR: &[u8] = include_bytes!("../test_data/ttf/cvar.ttf");
63
64pub static STARTING_OFF_CURVE: &[u8] = include_bytes!("../test_data/ttf/starts_off_curve.ttf");
65
66pub static MOSTLY_OFF_CURVE: &[u8] = include_bytes!("../test_data/ttf/mostly_off_curve.ttf");
67
68pub static INTERPOLATE_THIS: &[u8] = include_bytes!("../test_data/ttf/interpolate_this.ttf");
69
70pub static MATERIAL_SYMBOLS_SUBSET: &[u8] =
71    include_bytes!("../test_data/ttf/material_symbols_subset.ttf");
72
73pub static GLYF_COMPONENTS: &[u8] = include_bytes!("../test_data/ttf/glyf_components.ttf");
74
75pub static AUTOHINT_CMAP: &[u8] = include_bytes!("../test_data/ttf/autohint_cmap.ttf");
76
77pub static NOTOSERIFHEBREW_AUTOHINT_METRICS: &[u8] =
78    include_bytes!("../test_data/ttf/notoserifhebrew_autohint_metrics.ttf");
79
80pub static NOTOSERIFTC_AUTOHINT_METRICS: &[u8] =
81    include_bytes!("../test_data/ttf/notoseriftc_autohint_metrics.ttf");
82
83pub static NOTOSERIF_AUTOHINT_SHAPING: &[u8] =
84    include_bytes!("../test_data/ttf/notoserif_autohint_shaping.ttf");
85
86pub static TTHINT_SUBSET: &[u8] = include_bytes!("../test_data/ttf/tthint_subset.ttf");
87
88pub static VORG: &[u8] = include_bytes!("../test_data/ttf/vorg.ttf");
89
90pub static AHEM: &[u8] = include_bytes!("../test_data/ttf/ahem.ttf");
91
92pub static AVAR2_CHECKER: &[u8] = include_bytes!("../test_data/ttf/avar2checker.ttf");
93
94pub static MATERIAL_ICONS_SUBSET: &[u8] =
95    include_bytes!("../test_data/ttf/material_icons_subset.ttf");
96
97pub static TINOS_SUBSET: &[u8] = include_bytes!("../test_data/ttf/tinos_subset.ttf");
98
99pub static NOTO_HANDWRITING_SBIX: &[u8] =
100    include_bytes!("../test_data/ttf/noto_handwriting-sbix.ttf");
101
102pub static COUSINE_HINT_SUBSET: &[u8] = include_bytes!("../test_data/ttf/cousine_hint_subset.ttf");
103
104pub mod morx {
105    // The following taken from the Unicode text rendering test fonts:
106    // <https://github.com/unicode-org/text-rendering-tests/tree/main/fonts>
107    pub static ONE: &[u8] = include_bytes!("../test_data/ttf/TestMORXOne.ttf");
108    pub static FOUR: &[u8] = include_bytes!("../test_data/ttf/TestMORXFour.ttf");
109    pub static EIGHTEEN: &[u8] = include_bytes!("../test_data/ttf/TestMORXEighteen.ttf");
110    pub static THIRTY_FOUR: &[u8] = include_bytes!("../test_data/ttf/TestMORXThirtyfour.ttf");
111    pub static FORTY_ONE: &[u8] = include_bytes!("../test_data/ttf/TestMORXFourtyone.ttf");
112}
113
114pub mod varc {
115    pub static CJK_6868: &[u8] = include_bytes!("../test_data/ttf/varc-6868.ttf");
116    pub static CONDITIONALS: &[u8] = include_bytes!("../test_data/ttf/varc-ac01-conditional.ttf");
117}
118
119pub mod closure {
120    pub static SIMPLE: &[u8] = include_bytes!("../test_data/ttf/simple_closure.ttf");
121    pub static SIMPLE_GLYPHS: &str = include_str!("../test_data/fea/simple_closure_glyphs.txt");
122    pub static RECURSIVE: &[u8] = include_bytes!("../test_data/ttf/recursive_closure.ttf");
123    pub static RECURSIVE_GLYPHS: &str =
124        include_str!("../test_data/fea/recursive_closure_glyphs.txt");
125    pub static CONTEXTUAL: &[u8] = include_bytes!("../test_data/ttf/context_closure.ttf");
126    pub static CONTEXTUAL_GLYPHS: &str =
127        include_str!("../test_data/fea/context_closure_glyphs.txt");
128    pub static RECURSIVE_CONTEXTUAL: &[u8] =
129        include_bytes!("../test_data/ttf/recursive_context_closure.ttf");
130    pub static RECURSIVE_CONTEXTUAL_GLYPHS: &str =
131        include_str!("../test_data/fea/recursive_context_closure_glyphs.txt");
132    // reuses glyph set from above
133    pub static CYCLIC_CONTEXTUAL: &[u8] =
134        include_bytes!("../test_data/ttf/cyclic_context_closure.ttf");
135    pub static CHAIN_CONTEXT_FORMAT3_BITS: &[u8] =
136        include_bytes!("../test_data/ttf/context_closure_unreachable_rule.ttf");
137    pub static CHAIN_CONTEXT_FORMAT3_BITS_GLYPHS: &str =
138        include_str!("../test_data/fea/context_closure_unreachable_rule_glyphs.txt");
139    pub static VARIATIONS_CLOSURE: &[u8] =
140        include_bytes!("../test_data/ttf/variations_closure.ttf");
141    pub static VARIATIONS_GLYPHS: &str =
142        include_str!("../test_data/fea/variations_closure_glyphs.txt");
143}
144
145pub mod post {
146
147    #[rustfmt::skip]
148    pub static SIMPLE: &[u8] = &[
149        0x00, 0x02, 0x00, 0x00, // version 2.0
150        0x00, 0x00, 0x00, 0x00, // italic angle
151        0xFF, 0xb5,             // underlinePosition -75
152        0x00, 0x32,             // underlineThickness 50
153        0x00, 0x00, 0x00, 0x00, // fixedpitch
154        0x00, 0x00, 0x00, 0x00, // min/max mem:
155        0x00, 0x00, 0x00, 0x00,
156        0x00, 0x00, 0x00, 0x00,
157        0x00, 0x00, 0x00, 0x00,
158        0x00, 0x0A,             // numGlyphs 10
159                                // glyph name index:
160        0x00, 0x00,              // glyph 0 -> name 0
161        0x00, 0x00,             // glyph 1 -> name 0
162        0x00, 0x03,              // glyph 2 -> name 3 ('space')
163        0x00, 0x04,              // glyph 3 -> name 4 ('exclam')
164        0x00, 0x06,
165        0x00, 0x07,
166        0x00, 0x08,
167        0x01, 0x02,             // glyph 7 -> name 258 first custom
168        0x01, 0x03,             // glyph 8 -> name 258 first custom
169        0x01, 0x04,             // glyph 9 -> name 258 first custom
170        0x05, 0x68, 0x65, 0x6c, 0x6c, 0x6f, // 5, h e l l o
171        0x02, 0x68, 0x69, // 2, h i
172        0x4, 0x68, 0x6f, 0x6c, 0x61, // 4, h o l a
173    ];
174}
175
176pub mod cff2 {
177    /// CFF2 example table
178    /// <https://learn.microsoft.com/en-us/typography/opentype/spec/cff2#appendix-a-example-cff2-font>
179    pub static EXAMPLE: &[u8] = &[
180        0x02, 0x00, 0x05, 0x00, 0x07, 0xCF, 0x0C, 0x24, 0xC3, 0x11, 0x9B, 0x18, 0x00, 0x00, 0x00,
181        0x00, 0x00, 0x26, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x01, 0x00, 0x00, 0x00, 0x1C,
182        0x00, 0x01, 0x00, 0x02, 0xC0, 0x00, 0xE0, 0x00, 0x00, 0x00, 0xC0, 0x00, 0xC0, 0x00, 0xE0,
183        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02,
184        0x01, 0x01, 0x03, 0x05, 0x20, 0x0A, 0x20, 0x0A, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x05,
185        0xF7, 0x06, 0xDA, 0x12, 0x77, 0x9F, 0xF8, 0x6C, 0x9D, 0xAE, 0x9A, 0xF4, 0x9A, 0x95, 0x9F,
186        0xB3, 0x9F, 0x8B, 0x8B, 0x8B, 0x8B, 0x85, 0x9A, 0x8B, 0x8B, 0x97, 0x73, 0x8B, 0x8B, 0x8C,
187        0x80, 0x8B, 0x8B, 0x8B, 0x8D, 0x8B, 0x8B, 0x8C, 0x8A, 0x8B, 0x8B, 0x97, 0x17, 0x06, 0xFB,
188        0x8E, 0x95, 0x86, 0x9D, 0x8B, 0x8B, 0x8D, 0x17, 0x07, 0x77, 0x9F, 0xF8, 0x6D, 0x9D, 0xAD,
189        0x9A, 0xF3, 0x9A, 0x95, 0x9F, 0xB3, 0x9F, 0x08, 0xFB, 0x8D, 0x95, 0x09, 0x1E, 0xA0, 0x37,
190        0x5F, 0x0C, 0x09, 0x8B, 0x0C, 0x0B, 0xC2, 0x6E, 0x9E, 0x8C, 0x17, 0x0A, 0xDB, 0x57, 0xF7,
191        0x02, 0x8C, 0x17, 0x0B, 0xB3, 0x9A, 0x77, 0x9F, 0x82, 0x8A, 0x8D, 0x17, 0x0C, 0x0C, 0xDB,
192        0x95, 0x57, 0xF7, 0x02, 0x85, 0x8B, 0x8D, 0x17, 0x0C, 0x0D, 0xF7, 0x06, 0x13, 0x00, 0x00,
193        0x00, 0x01, 0x01, 0x01, 0x1B, 0xBD, 0xBD, 0xEF, 0x8C, 0x10, 0x8B, 0x15, 0xF8, 0x88, 0x27,
194        0xFB, 0x5C, 0x8C, 0x10, 0x06, 0xF8, 0x88, 0x07, 0xFC, 0x88, 0xEF, 0xF7, 0x5C, 0x8C, 0x10,
195        0x06,
196    ];
197}
198
199/// This setup to avoid cross-crate path construction and build.rs because both caused problems for google3
200pub mod colrv1_json {
201    /// Gets the expected value for a colrv1 json test
202    pub fn expected(set_name: &str, settings: &[(&str, f32)]) -> &'static str {
203        let mut key = Vec::with_capacity(1 + settings.len());
204        key.push("colrv1_".to_string() + &set_name.to_ascii_lowercase());
205        key.extend(settings.iter().map(|(t, v)| format!("{t}_{v}")));
206        let key = key.join("_");
207        // you could generate the cases in bash using something like:
208        // for f in $(ls font-test-data/test_data/colrv1_json); do echo "\"$f\" => include_str!(\"../test_data/colrv1_json/$f\"),"; done
209        match key.as_str() {
210            "colrv1_clipbox" => include_str!("../test_data/colrv1_json/colrv1_clipbox"),
211            "colrv1_clipbox_CLIO_200" => include_str!("../test_data/colrv1_json/colrv1_clipbox_CLIO_200"),
212            "colrv1_colored_circles_v0" => include_str!("../test_data/colrv1_json/colrv1_colored_circles_v0"),
213            "colrv1_composite_mode" => include_str!("../test_data/colrv1_json/colrv1_composite_mode"),
214            "colrv1_extend_mode" => include_str!("../test_data/colrv1_json/colrv1_extend_mode"),
215            "colrv1_extend_mode_COL1_-0.25_COL3_0.25" => include_str!("../test_data/colrv1_json/colrv1_extend_mode_COL1_-0.25_COL3_0.25"),
216            "colrv1_extend_mode_COL1_0.5_COL3_-0.5" => include_str!("../test_data/colrv1_json/colrv1_extend_mode_COL1_0.5_COL3_-0.5"),
217            "colrv1_extend_mode_COL1_-1.5" => include_str!("../test_data/colrv1_json/colrv1_extend_mode_COL1_-1.5"),
218            "colrv1_extend_mode_COL2_-0.3" => include_str!("../test_data/colrv1_json/colrv1_extend_mode_COL2_-0.3"),
219            "colrv1_extend_mode_COL3_0.5" => include_str!("../test_data/colrv1_json/colrv1_extend_mode_COL3_0.5"),
220            "colrv1_extend_mode_COL3_1" => include_str!("../test_data/colrv1_json/colrv1_extend_mode_COL3_1"),
221            "colrv1_extend_mode_COL3_1_COL2_1.5_COL1_2" => include_str!("../test_data/colrv1_json/colrv1_extend_mode_COL3_1_COL2_1.5_COL1_2"),
222            "colrv1_extend_mode_GRR0_-200_GRR1_-300" => include_str!("../test_data/colrv1_json/colrv1_extend_mode_GRR0_-200_GRR1_-300"),
223            "colrv1_extend_mode_GRR0_430_GRR1_40" => include_str!("../test_data/colrv1_json/colrv1_extend_mode_GRR0_430_GRR1_40"),
224            "colrv1_extend_mode_GRR0_-50_COL3_-2_COL2_-2_COL1_-0.9" => include_str!("../test_data/colrv1_json/colrv1_extend_mode_GRR0_-50_COL3_-2_COL2_-2_COL1_-0.9"),
225            "colrv1_extend_mode_GRR0_-50_COL3_-2_COL2_-2_COL1_-1.1" => include_str!("../test_data/colrv1_json/colrv1_extend_mode_GRR0_-50_COL3_-2_COL2_-2_COL1_-1.1"),
226            "colrv1_extend_mode_GRX0_1000_GRX1_-1000_GRR0_-1000_GRR1_200" => include_str!("../test_data/colrv1_json/colrv1_extend_mode_GRX0_1000_GRX1_-1000_GRR0_-1000_GRR1_200"),
227            "colrv1_extend_mode_GRX0_-1000_GRX1_-1000_GRR0_-1000_GRR1_-900" => include_str!("../test_data/colrv1_json/colrv1_extend_mode_GRX0_-1000_GRX1_-1000_GRR0_-1000_GRR1_-900"),
228            "colrv1_foreground_color" => include_str!("../test_data/colrv1_json/colrv1_foreground_color"),
229            "colrv1_gradient_p2_skewed" => include_str!("../test_data/colrv1_json/colrv1_gradient_p2_skewed"),
230            "colrv1_gradient_stops_repeat" => include_str!("../test_data/colrv1_json/colrv1_gradient_stops_repeat"),
231            "colrv1_no_cycle_multi_colrglyph" => include_str!("../test_data/colrv1_json/colrv1_no_cycle_multi_colrglyph"),
232            "colrv1_paint_glyph_nested" => include_str!("../test_data/colrv1_json/colrv1_paint_glyph_nested"),
233            "colrv1_paint_rotate" => include_str!("../test_data/colrv1_json/colrv1_paint_rotate"),
234            "colrv1_paint_rotate_ROTA_40" => include_str!("../test_data/colrv1_json/colrv1_paint_rotate_ROTA_40"),
235            "colrv1_paint_rotate_ROTX_-250_ROTY_-250" => include_str!("../test_data/colrv1_json/colrv1_paint_rotate_ROTX_-250_ROTY_-250"),
236            "colrv1_paint_scale" => include_str!("../test_data/colrv1_json/colrv1_paint_scale"),
237            "colrv1_paint_scale_SCOX_200_SCOY_200" => include_str!("../test_data/colrv1_json/colrv1_paint_scale_SCOX_200_SCOY_200"),
238            "colrv1_paint_scale_SCSX_0.25_SCOY_0.25" => include_str!("../test_data/colrv1_json/colrv1_paint_scale_SCSX_0.25_SCOY_0.25"),
239            "colrv1_paint_scale_SCSX_-1_SCOY_-1" => include_str!("../test_data/colrv1_json/colrv1_paint_scale_SCSX_-1_SCOY_-1"),
240            "colrv1_paint_skew" => include_str!("../test_data/colrv1_json/colrv1_paint_skew"),
241            "colrv1_paint_skew_SKCX_200_SKCY_200" => include_str!("../test_data/colrv1_json/colrv1_paint_skew_SKCX_200_SKCY_200"),
242            "colrv1_paint_skew_SKXA_20" => include_str!("../test_data/colrv1_json/colrv1_paint_skew_SKXA_20"),
243            "colrv1_paint_skew_SKYA_20" => include_str!("../test_data/colrv1_json/colrv1_paint_skew_SKYA_20"),
244            "colrv1_paint_transform" => include_str!("../test_data/colrv1_json/colrv1_paint_transform"),
245            "colrv1_paint_translate" => include_str!("../test_data/colrv1_json/colrv1_paint_translate"),
246            "colrv1_paint_translate_TLDX_100_TLDY_100" => include_str!("../test_data/colrv1_json/colrv1_paint_translate_TLDX_100_TLDY_100"),
247            "colrv1_sweep_coincident" => include_str!("../test_data/colrv1_json/colrv1_sweep_coincident"),
248            "colrv1_sweep_varsweep" => include_str!("../test_data/colrv1_json/colrv1_sweep_varsweep"),
249            "colrv1_sweep_varsweep_SWC1_-0.25_SWC2_0.083333336_SWC3_0.083333336_SWC4_0.25" => include_str!("../test_data/colrv1_json/colrv1_sweep_varsweep_SWC1_-0.25_SWC2_0.083333336_SWC3_0.083333336_SWC4_0.25"),
250            "colrv1_sweep_varsweep_SWPE_-45" => include_str!("../test_data/colrv1_json/colrv1_sweep_varsweep_SWPE_-45"),
251            "colrv1_sweep_varsweep_SWPE_-90" => include_str!("../test_data/colrv1_json/colrv1_sweep_varsweep_SWPE_-90"),
252            "colrv1_sweep_varsweep_SWPS_0" => include_str!("../test_data/colrv1_json/colrv1_sweep_varsweep_SWPS_0"),
253            "colrv1_sweep_varsweep_SWPS_-45_SWPE_45" => include_str!("../test_data/colrv1_json/colrv1_sweep_varsweep_SWPS_-45_SWPE_45"),
254            "colrv1_sweep_varsweep_SWPS_45_SWPE_-45_SWC1_-0.25_SWC2_-0.416687_SWC3_-0.583313_SWC4_-0.75" => include_str!("../test_data/colrv1_json/colrv1_sweep_varsweep_SWPS_45_SWPE_-45_SWC1_-0.25_SWC2_-0.416687_SWC3_-0.583313_SWC4_-0.75"),
255            "colrv1_sweep_varsweep_SWPS_90" => include_str!("../test_data/colrv1_json/colrv1_sweep_varsweep_SWPS_90"),
256            "colrv1_variable_alpha" => include_str!("../test_data/colrv1_json/colrv1_variable_alpha"),
257            "colrv1_variable_alpha_APH1_-0.7" => include_str!("../test_data/colrv1_json/colrv1_variable_alpha_APH1_-0.7"),
258            "colrv1_variable_alpha_APH2_-0.7_APH3_-0.2" => include_str!("../test_data/colrv1_json/colrv1_variable_alpha_APH2_-0.7_APH3_-0.2"),
259            _ => panic!("No entry for {key}, if this is a new test you might need to add a case"),
260        }
261    }
262}
263
264pub mod ttc {
265    pub static TTC: &[u8] = include_bytes!("../test_data/ttc/TTC.ttc");
266}
267
268pub mod meta {
269    // the table from the binary for 'Sankofa'
270    #[rustfmt::skip]
271    pub static SIMPLE_META_TABLE: &[u8] = &[
272        0x00, 0x00, 0x00, 0x01, // version 1
273        0x00, 0x00, 0x00, 0x00, // flags 0
274        0x00, 0x00, 0x00, 0x28, // reserved (?)
275        0x00, 0x00, 0x00, 0x02, // data_maps_count 2
276        0x64, 0x6c, 0x6e, 0x67, // tag: dlng
277        0x00, 0x00, 0x00, 0x28, // data offset
278        0x00, 0x00, 0x00, 0x0d, // data length
279        0x73, 0x6c, 0x6e, 0x67, // tag: slng
280        0x00, 0x00, 0x00, 0x35, // data offset
281        0x00, 0x00, 0x00, 0x04, // length
282        0x65, 0x6e, 0x2d, 0x6c,
283        0x61, 0x74, 0x6e, 0x2c,
284        0x20, 0x6c, 0x61, 0x74,
285        0x6e, 0x6c, 0x61, 0x74,
286        0x6e, 0x00, 0x00, 0x00,
287    ];
288}
289
290pub mod gvar {
291    pub static USE_MY_METRICS: &[u8] = include_bytes!("../test_data/ttf/gvar_use_my_metrics.ttf");
292}