@@ -21,280 +21,8 @@ pub const CFF2_FONT_CHARSTRINGS_OFFSET: u32 = 0x8f;
2121pub const RELATIVE_URL_TEMPLATE : & [ u8 ] = b"\x04 foo/\x80 " ;
2222pub const ABSOLUTE_URL_TEMPLATE : & [ u8 ] = b"\x0a //foo.bar/\x80 " ;
2323
24- // Format specification: https://w3c.github.io/IFT/Overview.html#patch-map-format-1
25- pub fn simple_format1 ( ) -> BeBuffer {
26- let mut buffer = be_buffer ! {
27- /* ### Header ### */
28- { 1u8 : "format" } , // format
29- 0u32 , // reserved
30- [ 1u32 , 2 , 3 , 4 ] , // compat id
31- 2u16 , // max entry id
32- { 2u16 : "max_glyph_map_entry_id" } ,
33- ( Uint24 :: new( 7 ) ) , // glyph count
34- { 0u32 : "glyph_map_offset" } ,
35- 0u32 , // feature map offset
36- 0b00000010u8 , // applied entry bitmap (entry 1)
37-
38- 6u16 , // url template length
39- 4u8 ,
40- { b'f' : "url_template[1]" } ,
41- { b'o' : "url_template[2]" } ,
42- [ b'o' , b'/' , 128u8 ] , // url_template[3..6]
43-
44- { 3u8 : "patch_format" } , // = glyph keyed
45-
46- /* ### Glyph Map ### */
47- { 1u16 : "glyph_map" } , // first mapped glyph
48- { 2u8 : "entry_index[1]" } ,
49- [ 1u8 , 0 , 1 , 0 , 0 ] // entry index[2..6]
50- } ;
51-
52- let offset = buffer. offset_for ( "glyph_map" ) as u32 ;
53- buffer. write_at ( "glyph_map_offset" , offset) ;
54-
55- buffer
56- }
57-
58- pub fn format1_with_dup_urls ( ) -> BeBuffer {
59- let mut buffer = be_buffer ! {
60- /* ### Header ### */
61- 1u8 , // format
62- 0u32 , // reserved
63- [ 1u32 , 2 , 3 , 4 ] , // compat id
64- 4u16 , // max entry id
65- { 4u16 : "max_glyph_map_entry_id" } ,
66- ( Uint24 :: new( 7 ) ) , // glyph count
67- { 0u32 : "glyph_map_offset" } ,
68- 0u32 , // feature map offset
69- 0b00000010u8 , // applied entry bitmap (entry 1)
70-
71- 9u16 , // url template length
72- [ 8u8 , b'f' , b'o' , b'o' , b'/' , b'b' , b'a' , b'a' , b'r' ] , // url_template[9]
73-
74- { 3u8 : "patch_format" } , // = glyph keyed
75-
76- /* ### Glyph Map ### */
77- { 1u16 : "glyph_map" } , // first mapped glyph
78- { 2u8 : "entry_index[1]" } ,
79- [ 3u8 , 4 , 0 , 0 , 0 ] // entry index[2..6]
80- } ;
81-
82- let offset = buffer. offset_for ( "glyph_map" ) as u32 ;
83- buffer. write_at ( "glyph_map_offset" , offset) ;
84-
85- buffer
86- }
87-
88- pub fn simple_format1_with_one_charstrings_offset ( ) -> BeBuffer {
89- let mut buffer = be_buffer ! {
90- /* ### Header ### */
91- 1u8 , // format
92- 0u8 , 0u8 , 0u8 , // reserved
93- 0b00000001u8 , // has charstrings offset
94- [ 1u32 , 2 , 3 , 4 ] , // compat id
95- 2u16 , // max entry id
96- { 2u16 : "max_glyph_map_entry_id" } ,
97- ( Uint24 :: new( 7 ) ) , // glyph count
98- { 0u32 : "glyph_map_offset" } ,
99- 0u32 , // feature map offset
100- 0b00000010u8 , // applied entry bitmap (entry 1)
101-
102- 8u16 , // url template length
103- { b'A' : "url_template[0]" } ,
104- { b'B' : "url_template[1]" } ,
105- [ b'C' , b'D' , b'E' , b'F' , 0xc9 , 0xa4 ] , // url_template[2..7]
106-
107- { 3u8 : "patch_format" } , // = glyph keyed
108-
109- 456u32 , // charstrings offset [0]
110-
111- /* ### Glyph Map ### */
112- { 1u16 : "glyph_map" } , // first mapped glyph
113- { 2u8 : "entry_index[1]" } ,
114- [ 1u8 , 0 , 1 , 0 , 0 ] // entry index[2..6]
115- } ;
116-
117- let offset = buffer. offset_for ( "glyph_map" ) as u32 ;
118- buffer. write_at ( "glyph_map_offset" , offset) ;
119-
120- buffer
121- }
122-
123- pub fn simple_format1_with_two_charstrings_offsets ( ) -> BeBuffer {
124- let mut buffer = be_buffer ! {
125- /* ### Header ### */
126- 1u8 , // format
127- 0u8 , 0u8 , 0u8 , // reserved
128- 0b00000011u8 , // has cff and cff2 charstrings offset
129- [ 1u32 , 2 , 3 , 4 ] , // compat id
130- 2u16 , // max entry id
131- { 2u16 : "max_glyph_map_entry_id" } ,
132- ( Uint24 :: new( 7 ) ) , // glyph count
133- { 0u32 : "glyph_map_offset" } ,
134- 0u32 , // feature map offset
135- 0b00000010u8 , // applied entry bitmap (entry 1)
136-
137- 8u16 , // url template length
138- { b'A' : "url_template[0]" } ,
139- { b'B' : "url_template[1]" } ,
140- [ b'C' , b'D' , b'E' , b'F' , 0xc9 , 0xa4 ] , // url_template[2..7]
141-
142- { 3u8 : "patch_format" } , // = glyph keyed
143-
144- 456u32 , // charstrings offset [0]
145- 789u32 , // charstrings offset [1]
146-
147- /* ### Glyph Map ### */
148- { 1u16 : "glyph_map" } , // first mapped glyph
149- { 2u8 : "entry_index[1]" } ,
150- [ 1u8 , 0 , 1 , 0 , 0 ] // entry index[2..6]
151- } ;
152-
153- let offset = buffer. offset_for ( "glyph_map" ) as u32 ;
154- buffer. write_at ( "glyph_map_offset" , offset) ;
155-
156- buffer
157- }
158-
159- pub fn u16_entries_format1 ( ) -> BeBuffer {
160- let mut buffer = be_buffer ! {
161- 1u8 , // format
162- 0u32 , // reserved
163- [ 1 , 2 , 3 , 4u32 ] , // compat id
164-
165- 300u16 , // max entry id
166- 300u16 , // max glyph map entry id
167-
168- ( Uint24 :: new( 7 ) ) , // glyph count
169-
170- { 0u32 : "glyph_map_offset" } ,
171- { 0u32 : "feature_map_offset" } ,
172-
173- // applied entry bitmap (38 bytes)
174- { 0u8 : "applied_entry_bitmap" } ,
175- [
176- 0 , 0 , 0 , 0 , 0 ,
177- 0 , 0 , 0 , 0 , 0 , 0 ,
178- 0 , 0 , 0 , 0 , 0 , 0 ,
179- 0 , 0 , 0 , 0 , 0 , 0 ,
180- 0 , 0 , 0 , 0 , 0 , 0 ,
181- 0 , 0 , 0 , 0 , 0 , 0 ,
182- 0 , 0u8
183- ] ,
184-
185- 6u16 , // urlTemplateLength
186- [ 4 , b'f' , b'o' , b'o' , b'/' , 128u8 ] , // urlTemplate[6]
187-
188- 3u8 , // patch encoding = glyph keyed
189-
190- /* ### Glyph Map ### */
191- { 2u16 : "glyph_map" } , // first mapped glyph
192-
193- // entryIndex[2..6]
194- [ 80 , 81 , 300 , 300 , 80u16 ]
195- } ;
196-
197- let offset = buffer. offset_for ( "glyph_map" ) as u32 ;
198- buffer. write_at ( "glyph_map_offset" , offset) ;
199-
200- buffer
201- }
202-
203- pub fn feature_map_format1 ( ) -> BeBuffer {
204- let mut buffer = be_buffer ! {
205- /* ### Header ### */
206- 1u8 , // format
207-
208- 0u32 , // reserved
209-
210- [ 1u32 , 2u32 , 3u32 , 4u32 ] , // compat id
211-
212- 400u16 , // max entry id
213- 300u16 , // max glyph map entry id
214- ( Uint24 :: new( 7 ) ) , // glyph count
215-
216- { 0u32 : "glyph_map_offset" } ,
217- { 0u32 : "feature_map_offset" } ,
218-
219- // applied entry bitmap (51 bytes) - 299 is applied
220- { 0u8 : "applied_entries" } ,
221- [
222- 0 , 0 , 0 , 0 , 0 , 0 , 0 , // [0, 64)
223- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // [64, 128)
224- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // [128, 192)
225- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // [192, 256)
226- 0 , 0 , 0 , 0 , 0u8
227- ] ,
228- { 0b00001000u8 : "applied_entries_296" } ,
229- [
230- 0 , 0 , // [256, 320)
231- 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , // [320, 384)
232- 0 , 0 , 0u8 // [384, 400)
233- ] ,
234-
235- 6u16 , // urlTemplateLength
236- [ 4 , b'f' , b'o' , b'o' , b'/' , 128u8 ] , // urlTemplate[6]
237-
238- { 3u8 : "patch_format" } , // patch encoding = glyph keyed
239-
240- /* ### Glyph Map ### */
241- { 2u16 : "glyph_map" } , // first mapped glyph
242-
243- // entryIndex[2..6]
244- [
245- 80 , // gid 2
246- 81 , // gid 3
247- 300u16 // gid 4
248- ] ,
249- { 299u16 : "gid5_entry" } , // gid 5
250- { 80u16 : "gid6_entry" } , // gid 6
251-
252- // ## Feature Map ##
253- { 3u16 : "feature_map" } , // feature count
254-
255- // FeatureRecord[0]
256- { ( Tag :: new( b"dlig" ) ) : "FeatureRecord[0]" } , // feature tag
257- 400u16 , // first new entry index
258- 1u16 , // entry map count
259-
260- // FeatureRecord[1]
261- { ( Tag :: new( b"liga" ) ) : "FeatureRecord[1]" } , // feature tag
262- 384u16 , // first new entry index
263- 2u16 , // entry map count
264-
265- // FeatureRecord[2]
266- [ b'n' , b'u' , b'l' , b'l' ] , // feature tag
267- 301u16 , // first new entry index
268- 1u16 , // entry map count
269-
270- // EntryMapRecord[0]: "dlig" + entry 81 => entry 400
271- 81u16 , // first_entry_index
272- 81u16 , // last_entry_index
273-
274- // EntryMapRecord[1]: "liga" + entry [80, 81] => entry 384
275- 80u16 , // first_entry_index
276- 81u16 , // last_entry_index
277-
278- // EntryMapRecord[2]: "liga" + entry [299, 300] => entry 385
279- 299u16 , // first_entry_index
280- 300u16 , // last_entry_index
281-
282- // EntryMapRecord[3]: "null" + entry 0 => entry 301
283- 0u16 , // first_entry_index
284- 0u16 // last_entry_index
285- } ;
286-
287- let offset = buffer. offset_for ( "glyph_map" ) as u32 ;
288- buffer. write_at ( "glyph_map_offset" , offset) ;
289-
290- let offset = buffer. offset_for ( "feature_map" ) as u32 ;
291- buffer. write_at ( "feature_map_offset" , offset) ;
292-
293- buffer
294- }
295-
29624// Format specification: https://w3c.github.io/IFT/Overview.html#patch-map-format-2
297- pub fn codepoints_only_format2 ( ) -> BeBuffer {
25+ pub fn codepoints_only ( ) -> BeBuffer {
29826 let mut buffer = be_buffer ! {
29927 { 2u8 : "format" } , // format
30028
@@ -340,7 +68,7 @@ pub fn codepoints_only_format2() -> BeBuffer {
34068 buffer
34169}
34270
343- pub fn format2_with_one_charstrings_offset ( ) -> BeBuffer {
71+ pub fn with_one_charstrings_offset ( ) -> BeBuffer {
34472 let mut buffer = be_buffer ! {
34573 2u8 , // format
34674
@@ -374,7 +102,7 @@ pub fn format2_with_one_charstrings_offset() -> BeBuffer {
374102 buffer
375103}
376104
377- pub fn format2_with_two_charstrings_offset ( ) -> BeBuffer {
105+ pub fn with_two_charstrings_offset ( ) -> BeBuffer {
378106 let mut buffer = be_buffer ! {
379107 2u8 , // format
380108
@@ -409,7 +137,7 @@ pub fn format2_with_two_charstrings_offset() -> BeBuffer {
409137 buffer
410138}
411139
412- pub fn features_and_design_space_format2 ( ) -> BeBuffer {
140+ pub fn features_and_design_space ( ) -> BeBuffer {
413141 let mut buffer = be_buffer ! {
414142 2u8 , // format
415143
@@ -479,7 +207,7 @@ pub fn features_and_design_space_format2() -> BeBuffer {
479207 buffer
480208}
481209
482- pub fn child_indices_format2 ( ) -> BeBuffer {
210+ pub fn child_indices ( ) -> BeBuffer {
483211 let mut buffer = be_buffer ! {
484212 2u8 , // format
485213
@@ -568,7 +296,7 @@ pub fn child_indices_format2() -> BeBuffer {
568296}
569297
570298// Format specification: https://w3c.github.io/IFT/Overview.html#patch-map-format-2
571- pub fn custom_ids_format2 ( ) -> BeBuffer {
299+ pub fn custom_ids ( ) -> BeBuffer {
572300 let mut buffer = be_buffer ! {
573301 2u8 , // format
574302
@@ -617,7 +345,7 @@ pub fn custom_ids_format2() -> BeBuffer {
617345}
618346
619347// Format specification: https://w3c.github.io/IFT/Overview.html#patch-map-format-2
620- pub fn string_ids_format2 ( ) -> BeBuffer {
348+ pub fn string_ids ( ) -> BeBuffer {
621349 let mut buffer = be_buffer ! {
622350 2u8 , // format
623351
@@ -671,7 +399,7 @@ pub fn string_ids_format2() -> BeBuffer {
671399 buffer
672400}
673401
674- pub fn string_ids_format2_with_preloads ( ) -> BeBuffer {
402+ pub fn string_ids_with_preloads ( ) -> BeBuffer {
675403 const CONTINUE_MASK : u32 = 1 << 23 ;
676404 let mut buffer = be_buffer ! {
677405 2u8 , // format
@@ -725,7 +453,7 @@ pub fn string_ids_format2_with_preloads() -> BeBuffer {
725453}
726454
727455// Format specification: https://w3c.github.io/IFT/Overview.html#patch-map-format-2
728- pub fn table_keyed_format2 ( ) -> BeBuffer {
456+ pub fn table_keyed ( ) -> BeBuffer {
729457 let mut buffer = be_buffer ! {
730458 2u8 , // format
731459
@@ -759,7 +487,7 @@ pub fn table_keyed_format2() -> BeBuffer {
759487 buffer
760488}
761489
762- pub fn table_keyed_format2_with_preload_urls ( ) -> BeBuffer {
490+ pub fn table_keyed_with_preload_urls ( ) -> BeBuffer {
763491 let mut buffer = be_buffer ! {
764492 2u8 , // format
765493
0 commit comments