1 // THIS FILE IS AUTOGENERATED.
2 // Any changes to this file will be overwritten.
3 // For more information about how codegen works, see font-codegen/README.md
4 
5 #[allow(unused_imports)]
6 use crate::codegen_prelude::*;
7 
8 /// An array of variable-sized objects in a `CFF` table.
9 #[derive(Debug, Clone, Copy)]
10 #[doc(hidden)]
11 pub struct Index1Marker {
12     offsets_byte_len: usize,
13     data_byte_len: usize,
14 }
15 
16 impl Index1Marker {
count_byte_range(&self) -> Range<usize>17     fn count_byte_range(&self) -> Range<usize> {
18         let start = 0;
19         start..start + u16::RAW_BYTE_LEN
20     }
off_size_byte_range(&self) -> Range<usize>21     fn off_size_byte_range(&self) -> Range<usize> {
22         let start = self.count_byte_range().end;
23         start..start + u8::RAW_BYTE_LEN
24     }
offsets_byte_range(&self) -> Range<usize>25     fn offsets_byte_range(&self) -> Range<usize> {
26         let start = self.off_size_byte_range().end;
27         start..start + self.offsets_byte_len
28     }
data_byte_range(&self) -> Range<usize>29     fn data_byte_range(&self) -> Range<usize> {
30         let start = self.offsets_byte_range().end;
31         start..start + self.data_byte_len
32     }
33 }
34 
35 impl<'a> FontRead<'a> for Index1<'a> {
read(data: FontData<'a>) -> Result<Self, ReadError>36     fn read(data: FontData<'a>) -> Result<Self, ReadError> {
37         let mut cursor = data.cursor();
38         let count: u16 = cursor.read()?;
39         let off_size: u8 = cursor.read()?;
40         let offsets_byte_len =
41             transforms::add_multiply(count, 1_usize, off_size) * u8::RAW_BYTE_LEN;
42         cursor.advance_by(offsets_byte_len);
43         let data_byte_len = cursor.remaining_bytes() / u8::RAW_BYTE_LEN * u8::RAW_BYTE_LEN;
44         cursor.advance_by(data_byte_len);
45         cursor.finish(Index1Marker {
46             offsets_byte_len,
47             data_byte_len,
48         })
49     }
50 }
51 
52 /// An array of variable-sized objects in a `CFF` table.
53 pub type Index1<'a> = TableRef<'a, Index1Marker>;
54 
55 impl<'a> Index1<'a> {
56     /// Number of objects stored in INDEX.
count(&self) -> u1657     pub fn count(&self) -> u16 {
58         let range = self.shape.count_byte_range();
59         self.data.read_at(range.start).unwrap()
60     }
61 
62     /// Object array element size.
off_size(&self) -> u863     pub fn off_size(&self) -> u8 {
64         let range = self.shape.off_size_byte_range();
65         self.data.read_at(range.start).unwrap()
66     }
67 
68     /// Bytes containing `count + 1` offsets each of `off_size`.
offsets(&self) -> &'a [u8]69     pub fn offsets(&self) -> &'a [u8] {
70         let range = self.shape.offsets_byte_range();
71         self.data.read_array(range).unwrap()
72     }
73 
74     /// Array containing the object data.
data(&self) -> &'a [u8]75     pub fn data(&self) -> &'a [u8] {
76         let range = self.shape.data_byte_range();
77         self.data.read_array(range).unwrap()
78     }
79 }
80 
81 #[cfg(feature = "traversal")]
82 impl<'a> SomeTable<'a> for Index1<'a> {
type_name(&self) -> &str83     fn type_name(&self) -> &str {
84         "Index1"
85     }
get_field(&self, idx: usize) -> Option<Field<'a>>86     fn get_field(&self, idx: usize) -> Option<Field<'a>> {
87         match idx {
88             0usize => Some(Field::new("count", self.count())),
89             1usize => Some(Field::new("off_size", self.off_size())),
90             2usize => Some(Field::new("offsets", self.offsets())),
91             3usize => Some(Field::new("data", self.data())),
92             _ => None,
93         }
94     }
95 }
96 
97 #[cfg(feature = "traversal")]
98 impl<'a> std::fmt::Debug for Index1<'a> {
fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result99     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
100         (self as &dyn SomeTable<'a>).fmt(f)
101     }
102 }
103 
104 /// An array of variable-sized objects in a `CFF2` table.
105 #[derive(Debug, Clone, Copy)]
106 #[doc(hidden)]
107 pub struct Index2Marker {
108     offsets_byte_len: usize,
109     data_byte_len: usize,
110 }
111 
112 impl Index2Marker {
count_byte_range(&self) -> Range<usize>113     fn count_byte_range(&self) -> Range<usize> {
114         let start = 0;
115         start..start + u32::RAW_BYTE_LEN
116     }
off_size_byte_range(&self) -> Range<usize>117     fn off_size_byte_range(&self) -> Range<usize> {
118         let start = self.count_byte_range().end;
119         start..start + u8::RAW_BYTE_LEN
120     }
offsets_byte_range(&self) -> Range<usize>121     fn offsets_byte_range(&self) -> Range<usize> {
122         let start = self.off_size_byte_range().end;
123         start..start + self.offsets_byte_len
124     }
data_byte_range(&self) -> Range<usize>125     fn data_byte_range(&self) -> Range<usize> {
126         let start = self.offsets_byte_range().end;
127         start..start + self.data_byte_len
128     }
129 }
130 
131 impl<'a> FontRead<'a> for Index2<'a> {
read(data: FontData<'a>) -> Result<Self, ReadError>132     fn read(data: FontData<'a>) -> Result<Self, ReadError> {
133         let mut cursor = data.cursor();
134         let count: u32 = cursor.read()?;
135         let off_size: u8 = cursor.read()?;
136         let offsets_byte_len =
137             transforms::add_multiply(count, 1_usize, off_size) * u8::RAW_BYTE_LEN;
138         cursor.advance_by(offsets_byte_len);
139         let data_byte_len = cursor.remaining_bytes() / u8::RAW_BYTE_LEN * u8::RAW_BYTE_LEN;
140         cursor.advance_by(data_byte_len);
141         cursor.finish(Index2Marker {
142             offsets_byte_len,
143             data_byte_len,
144         })
145     }
146 }
147 
148 /// An array of variable-sized objects in a `CFF2` table.
149 pub type Index2<'a> = TableRef<'a, Index2Marker>;
150 
151 impl<'a> Index2<'a> {
152     /// Number of objects stored in INDEX.
count(&self) -> u32153     pub fn count(&self) -> u32 {
154         let range = self.shape.count_byte_range();
155         self.data.read_at(range.start).unwrap()
156     }
157 
158     /// Object array element size.
off_size(&self) -> u8159     pub fn off_size(&self) -> u8 {
160         let range = self.shape.off_size_byte_range();
161         self.data.read_at(range.start).unwrap()
162     }
163 
164     /// Bytes containing `count + 1` offsets each of `off_size`.
offsets(&self) -> &'a [u8]165     pub fn offsets(&self) -> &'a [u8] {
166         let range = self.shape.offsets_byte_range();
167         self.data.read_array(range).unwrap()
168     }
169 
170     /// Array containing the object data.
data(&self) -> &'a [u8]171     pub fn data(&self) -> &'a [u8] {
172         let range = self.shape.data_byte_range();
173         self.data.read_array(range).unwrap()
174     }
175 }
176 
177 #[cfg(feature = "traversal")]
178 impl<'a> SomeTable<'a> for Index2<'a> {
type_name(&self) -> &str179     fn type_name(&self) -> &str {
180         "Index2"
181     }
get_field(&self, idx: usize) -> Option<Field<'a>>182     fn get_field(&self, idx: usize) -> Option<Field<'a>> {
183         match idx {
184             0usize => Some(Field::new("count", self.count())),
185             1usize => Some(Field::new("off_size", self.off_size())),
186             2usize => Some(Field::new("offsets", self.offsets())),
187             3usize => Some(Field::new("data", self.data())),
188             _ => None,
189         }
190     }
191 }
192 
193 #[cfg(feature = "traversal")]
194 impl<'a> std::fmt::Debug for Index2<'a> {
fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result195     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
196         (self as &dyn SomeTable<'a>).fmt(f)
197     }
198 }
199 
200 /// Associates a glyph identifier with a Font DICT.
201 #[derive(Clone)]
202 pub enum FdSelect<'a> {
203     Format0(FdSelectFormat0<'a>),
204     Format3(FdSelectFormat3<'a>),
205     Format4(FdSelectFormat4<'a>),
206 }
207 
208 impl<'a> FdSelect<'a> {
209     /// Format = 0.
format(&self) -> u8210     pub fn format(&self) -> u8 {
211         match self {
212             Self::Format0(item) => item.format(),
213             Self::Format3(item) => item.format(),
214             Self::Format4(item) => item.format(),
215         }
216     }
217 }
218 
219 impl<'a> FontRead<'a> for FdSelect<'a> {
read(data: FontData<'a>) -> Result<Self, ReadError>220     fn read(data: FontData<'a>) -> Result<Self, ReadError> {
221         let format: u8 = data.read_at(0usize)?;
222         match format {
223             FdSelectFormat0Marker::FORMAT => Ok(Self::Format0(FontRead::read(data)?)),
224             FdSelectFormat3Marker::FORMAT => Ok(Self::Format3(FontRead::read(data)?)),
225             FdSelectFormat4Marker::FORMAT => Ok(Self::Format4(FontRead::read(data)?)),
226             other => Err(ReadError::InvalidFormat(other.into())),
227         }
228     }
229 }
230 
231 #[cfg(feature = "traversal")]
232 impl<'a> FdSelect<'a> {
dyn_inner<'b>(&'b self) -> &'b dyn SomeTable<'a>233     fn dyn_inner<'b>(&'b self) -> &'b dyn SomeTable<'a> {
234         match self {
235             Self::Format0(table) => table,
236             Self::Format3(table) => table,
237             Self::Format4(table) => table,
238         }
239     }
240 }
241 
242 #[cfg(feature = "traversal")]
243 impl<'a> std::fmt::Debug for FdSelect<'a> {
fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result244     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
245         self.dyn_inner().fmt(f)
246     }
247 }
248 
249 #[cfg(feature = "traversal")]
250 impl<'a> SomeTable<'a> for FdSelect<'a> {
type_name(&self) -> &str251     fn type_name(&self) -> &str {
252         self.dyn_inner().type_name()
253     }
get_field(&self, idx: usize) -> Option<Field<'a>>254     fn get_field(&self, idx: usize) -> Option<Field<'a>> {
255         self.dyn_inner().get_field(idx)
256     }
257 }
258 
259 impl Format<u8> for FdSelectFormat0Marker {
260     const FORMAT: u8 = 0;
261 }
262 
263 /// FdSelect format 0.
264 #[derive(Debug, Clone, Copy)]
265 #[doc(hidden)]
266 pub struct FdSelectFormat0Marker {
267     fds_byte_len: usize,
268 }
269 
270 impl FdSelectFormat0Marker {
format_byte_range(&self) -> Range<usize>271     fn format_byte_range(&self) -> Range<usize> {
272         let start = 0;
273         start..start + u8::RAW_BYTE_LEN
274     }
fds_byte_range(&self) -> Range<usize>275     fn fds_byte_range(&self) -> Range<usize> {
276         let start = self.format_byte_range().end;
277         start..start + self.fds_byte_len
278     }
279 }
280 
281 impl<'a> FontRead<'a> for FdSelectFormat0<'a> {
read(data: FontData<'a>) -> Result<Self, ReadError>282     fn read(data: FontData<'a>) -> Result<Self, ReadError> {
283         let mut cursor = data.cursor();
284         cursor.advance::<u8>();
285         let fds_byte_len = cursor.remaining_bytes() / u8::RAW_BYTE_LEN * u8::RAW_BYTE_LEN;
286         cursor.advance_by(fds_byte_len);
287         cursor.finish(FdSelectFormat0Marker { fds_byte_len })
288     }
289 }
290 
291 /// FdSelect format 0.
292 pub type FdSelectFormat0<'a> = TableRef<'a, FdSelectFormat0Marker>;
293 
294 impl<'a> FdSelectFormat0<'a> {
295     /// Format = 0.
format(&self) -> u8296     pub fn format(&self) -> u8 {
297         let range = self.shape.format_byte_range();
298         self.data.read_at(range.start).unwrap()
299     }
300 
301     /// FD selector array (one entry for each glyph).
fds(&self) -> &'a [u8]302     pub fn fds(&self) -> &'a [u8] {
303         let range = self.shape.fds_byte_range();
304         self.data.read_array(range).unwrap()
305     }
306 }
307 
308 #[cfg(feature = "traversal")]
309 impl<'a> SomeTable<'a> for FdSelectFormat0<'a> {
type_name(&self) -> &str310     fn type_name(&self) -> &str {
311         "FdSelectFormat0"
312     }
get_field(&self, idx: usize) -> Option<Field<'a>>313     fn get_field(&self, idx: usize) -> Option<Field<'a>> {
314         match idx {
315             0usize => Some(Field::new("format", self.format())),
316             1usize => Some(Field::new("fds", self.fds())),
317             _ => None,
318         }
319     }
320 }
321 
322 #[cfg(feature = "traversal")]
323 impl<'a> std::fmt::Debug for FdSelectFormat0<'a> {
fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result324     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
325         (self as &dyn SomeTable<'a>).fmt(f)
326     }
327 }
328 
329 impl Format<u8> for FdSelectFormat3Marker {
330     const FORMAT: u8 = 3;
331 }
332 
333 /// FdSelect format 3.
334 #[derive(Debug, Clone, Copy)]
335 #[doc(hidden)]
336 pub struct FdSelectFormat3Marker {
337     ranges_byte_len: usize,
338 }
339 
340 impl FdSelectFormat3Marker {
format_byte_range(&self) -> Range<usize>341     fn format_byte_range(&self) -> Range<usize> {
342         let start = 0;
343         start..start + u8::RAW_BYTE_LEN
344     }
n_ranges_byte_range(&self) -> Range<usize>345     fn n_ranges_byte_range(&self) -> Range<usize> {
346         let start = self.format_byte_range().end;
347         start..start + u16::RAW_BYTE_LEN
348     }
ranges_byte_range(&self) -> Range<usize>349     fn ranges_byte_range(&self) -> Range<usize> {
350         let start = self.n_ranges_byte_range().end;
351         start..start + self.ranges_byte_len
352     }
sentinel_byte_range(&self) -> Range<usize>353     fn sentinel_byte_range(&self) -> Range<usize> {
354         let start = self.ranges_byte_range().end;
355         start..start + u16::RAW_BYTE_LEN
356     }
357 }
358 
359 impl<'a> FontRead<'a> for FdSelectFormat3<'a> {
read(data: FontData<'a>) -> Result<Self, ReadError>360     fn read(data: FontData<'a>) -> Result<Self, ReadError> {
361         let mut cursor = data.cursor();
362         cursor.advance::<u8>();
363         let n_ranges: u16 = cursor.read()?;
364         let ranges_byte_len = n_ranges as usize * FdSelectRange3::RAW_BYTE_LEN;
365         cursor.advance_by(ranges_byte_len);
366         cursor.advance::<u16>();
367         cursor.finish(FdSelectFormat3Marker { ranges_byte_len })
368     }
369 }
370 
371 /// FdSelect format 3.
372 pub type FdSelectFormat3<'a> = TableRef<'a, FdSelectFormat3Marker>;
373 
374 impl<'a> FdSelectFormat3<'a> {
375     /// Format = 3.
format(&self) -> u8376     pub fn format(&self) -> u8 {
377         let range = self.shape.format_byte_range();
378         self.data.read_at(range.start).unwrap()
379     }
380 
381     /// Number of ranges.
n_ranges(&self) -> u16382     pub fn n_ranges(&self) -> u16 {
383         let range = self.shape.n_ranges_byte_range();
384         self.data.read_at(range.start).unwrap()
385     }
386 
387     /// Range3 array.
ranges(&self) -> &'a [FdSelectRange3]388     pub fn ranges(&self) -> &'a [FdSelectRange3] {
389         let range = self.shape.ranges_byte_range();
390         self.data.read_array(range).unwrap()
391     }
392 
393     /// Sentinel GID. Set equal to the number of glyphs in the font.
sentinel(&self) -> u16394     pub fn sentinel(&self) -> u16 {
395         let range = self.shape.sentinel_byte_range();
396         self.data.read_at(range.start).unwrap()
397     }
398 }
399 
400 #[cfg(feature = "traversal")]
401 impl<'a> SomeTable<'a> for FdSelectFormat3<'a> {
type_name(&self) -> &str402     fn type_name(&self) -> &str {
403         "FdSelectFormat3"
404     }
get_field(&self, idx: usize) -> Option<Field<'a>>405     fn get_field(&self, idx: usize) -> Option<Field<'a>> {
406         match idx {
407             0usize => Some(Field::new("format", self.format())),
408             1usize => Some(Field::new("n_ranges", self.n_ranges())),
409             2usize => Some(Field::new(
410                 "ranges",
411                 traversal::FieldType::array_of_records(
412                     stringify!(FdSelectRange3),
413                     self.ranges(),
414                     self.offset_data(),
415                 ),
416             )),
417             3usize => Some(Field::new("sentinel", self.sentinel())),
418             _ => None,
419         }
420     }
421 }
422 
423 #[cfg(feature = "traversal")]
424 impl<'a> std::fmt::Debug for FdSelectFormat3<'a> {
fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result425     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
426         (self as &dyn SomeTable<'a>).fmt(f)
427     }
428 }
429 
430 /// Range struct for FdSelect format 3.
431 #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
432 #[repr(C)]
433 #[repr(packed)]
434 pub struct FdSelectRange3 {
435     /// First glyph index in range.
436     pub first: BigEndian<u16>,
437     /// FD index for all glyphs in range.
438     pub fd: u8,
439 }
440 
441 impl FdSelectRange3 {
442     /// First glyph index in range.
first(&self) -> u16443     pub fn first(&self) -> u16 {
444         self.first.get()
445     }
446 
447     /// FD index for all glyphs in range.
fd(&self) -> u8448     pub fn fd(&self) -> u8 {
449         self.fd
450     }
451 }
452 
453 impl FixedSize for FdSelectRange3 {
454     const RAW_BYTE_LEN: usize = u16::RAW_BYTE_LEN + u8::RAW_BYTE_LEN;
455 }
456 
457 impl sealed::Sealed for FdSelectRange3 {}
458 
459 /// SAFETY: see the [`FromBytes`] trait documentation.
460 unsafe impl FromBytes for FdSelectRange3 {
this_trait_should_only_be_implemented_in_generated_code()461     fn this_trait_should_only_be_implemented_in_generated_code() {}
462 }
463 
464 #[cfg(feature = "traversal")]
465 impl<'a> SomeRecord<'a> for FdSelectRange3 {
traverse(self, data: FontData<'a>) -> RecordResolver<'a>466     fn traverse(self, data: FontData<'a>) -> RecordResolver<'a> {
467         RecordResolver {
468             name: "FdSelectRange3",
469             get_field: Box::new(move |idx, _data| match idx {
470                 0usize => Some(Field::new("first", self.first())),
471                 1usize => Some(Field::new("fd", self.fd())),
472                 _ => None,
473             }),
474             data,
475         }
476     }
477 }
478 
479 impl Format<u8> for FdSelectFormat4Marker {
480     const FORMAT: u8 = 4;
481 }
482 
483 /// FdSelect format 4.
484 #[derive(Debug, Clone, Copy)]
485 #[doc(hidden)]
486 pub struct FdSelectFormat4Marker {
487     ranges_byte_len: usize,
488 }
489 
490 impl FdSelectFormat4Marker {
format_byte_range(&self) -> Range<usize>491     fn format_byte_range(&self) -> Range<usize> {
492         let start = 0;
493         start..start + u8::RAW_BYTE_LEN
494     }
n_ranges_byte_range(&self) -> Range<usize>495     fn n_ranges_byte_range(&self) -> Range<usize> {
496         let start = self.format_byte_range().end;
497         start..start + u32::RAW_BYTE_LEN
498     }
ranges_byte_range(&self) -> Range<usize>499     fn ranges_byte_range(&self) -> Range<usize> {
500         let start = self.n_ranges_byte_range().end;
501         start..start + self.ranges_byte_len
502     }
sentinel_byte_range(&self) -> Range<usize>503     fn sentinel_byte_range(&self) -> Range<usize> {
504         let start = self.ranges_byte_range().end;
505         start..start + u32::RAW_BYTE_LEN
506     }
507 }
508 
509 impl<'a> FontRead<'a> for FdSelectFormat4<'a> {
read(data: FontData<'a>) -> Result<Self, ReadError>510     fn read(data: FontData<'a>) -> Result<Self, ReadError> {
511         let mut cursor = data.cursor();
512         cursor.advance::<u8>();
513         let n_ranges: u32 = cursor.read()?;
514         let ranges_byte_len = n_ranges as usize * FdSelectRange4::RAW_BYTE_LEN;
515         cursor.advance_by(ranges_byte_len);
516         cursor.advance::<u32>();
517         cursor.finish(FdSelectFormat4Marker { ranges_byte_len })
518     }
519 }
520 
521 /// FdSelect format 4.
522 pub type FdSelectFormat4<'a> = TableRef<'a, FdSelectFormat4Marker>;
523 
524 impl<'a> FdSelectFormat4<'a> {
525     /// Format = 4.
format(&self) -> u8526     pub fn format(&self) -> u8 {
527         let range = self.shape.format_byte_range();
528         self.data.read_at(range.start).unwrap()
529     }
530 
531     /// Number of ranges.
n_ranges(&self) -> u32532     pub fn n_ranges(&self) -> u32 {
533         let range = self.shape.n_ranges_byte_range();
534         self.data.read_at(range.start).unwrap()
535     }
536 
537     /// Range4 array.
ranges(&self) -> &'a [FdSelectRange4]538     pub fn ranges(&self) -> &'a [FdSelectRange4] {
539         let range = self.shape.ranges_byte_range();
540         self.data.read_array(range).unwrap()
541     }
542 
543     /// Sentinel GID. Set equal to the number of glyphs in the font.
sentinel(&self) -> u32544     pub fn sentinel(&self) -> u32 {
545         let range = self.shape.sentinel_byte_range();
546         self.data.read_at(range.start).unwrap()
547     }
548 }
549 
550 #[cfg(feature = "traversal")]
551 impl<'a> SomeTable<'a> for FdSelectFormat4<'a> {
type_name(&self) -> &str552     fn type_name(&self) -> &str {
553         "FdSelectFormat4"
554     }
get_field(&self, idx: usize) -> Option<Field<'a>>555     fn get_field(&self, idx: usize) -> Option<Field<'a>> {
556         match idx {
557             0usize => Some(Field::new("format", self.format())),
558             1usize => Some(Field::new("n_ranges", self.n_ranges())),
559             2usize => Some(Field::new(
560                 "ranges",
561                 traversal::FieldType::array_of_records(
562                     stringify!(FdSelectRange4),
563                     self.ranges(),
564                     self.offset_data(),
565                 ),
566             )),
567             3usize => Some(Field::new("sentinel", self.sentinel())),
568             _ => None,
569         }
570     }
571 }
572 
573 #[cfg(feature = "traversal")]
574 impl<'a> std::fmt::Debug for FdSelectFormat4<'a> {
fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result575     fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
576         (self as &dyn SomeTable<'a>).fmt(f)
577     }
578 }
579 
580 /// Range struct for FdSelect format 4.
581 #[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
582 #[repr(C)]
583 #[repr(packed)]
584 pub struct FdSelectRange4 {
585     /// First glyph index in range.
586     pub first: BigEndian<u32>,
587     /// FD index for all glyphs in range.
588     pub fd: BigEndian<u16>,
589 }
590 
591 impl FdSelectRange4 {
592     /// First glyph index in range.
first(&self) -> u32593     pub fn first(&self) -> u32 {
594         self.first.get()
595     }
596 
597     /// FD index for all glyphs in range.
fd(&self) -> u16598     pub fn fd(&self) -> u16 {
599         self.fd.get()
600     }
601 }
602 
603 impl FixedSize for FdSelectRange4 {
604     const RAW_BYTE_LEN: usize = u32::RAW_BYTE_LEN + u16::RAW_BYTE_LEN;
605 }
606 
607 impl sealed::Sealed for FdSelectRange4 {}
608 
609 /// SAFETY: see the [`FromBytes`] trait documentation.
610 unsafe impl FromBytes for FdSelectRange4 {
this_trait_should_only_be_implemented_in_generated_code()611     fn this_trait_should_only_be_implemented_in_generated_code() {}
612 }
613 
614 #[cfg(feature = "traversal")]
615 impl<'a> SomeRecord<'a> for FdSelectRange4 {
traverse(self, data: FontData<'a>) -> RecordResolver<'a>616     fn traverse(self, data: FontData<'a>) -> RecordResolver<'a> {
617         RecordResolver {
618             name: "FdSelectRange4",
619             get_field: Box::new(move |idx, _data| match idx {
620                 0usize => Some(Field::new("first", self.first())),
621                 1usize => Some(Field::new("fd", self.fd())),
622                 _ => None,
623             }),
624             data,
625         }
626     }
627 }
628