Coverage Report

Created: 2026-12-01 06:30

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/rust/registry/src/index.crates.io-1949cf8c6b5b557f/read-fonts-0.47.0/generated/generated_varc.rs
Line
Count
Source
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
impl<'a> MinByteRange<'a> for Varc<'a> {
9
0
    fn min_byte_range(&self) -> Range<usize> {
10
0
        0..self.var_composite_glyphs_offset_byte_range().end
11
0
    }
12
0
    fn min_table_bytes(&self) -> &'a [u8] {
13
0
        let range = self.min_byte_range();
14
0
        self.offset_data().as_bytes().get(range).unwrap_or_default()
15
0
    }
16
}
17
18
impl TopLevelTable for Varc<'_> {
19
    /// `VARC`
20
    const TAG: Tag = Tag::new(b"VARC");
21
}
22
23
impl ReadArgs for Varc<'_> {
24
    type Args = ();
25
}
26
27
impl<'a> FontRead<'a> for Varc<'a> {
28
176
    fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
29
        #[allow(clippy::absurd_extreme_comparisons)]
30
176
        if data.len() < Self::MIN_SIZE {
31
1
            return Err(ReadError::OutOfBounds);
32
175
        }
33
175
        let Some(data) = TableDataRef::new(data.as_bytes()) else {
34
0
            return Err(ReadError::OutOfBounds);
35
        };
36
175
        Ok(Self { data })
37
176
    }
38
}
39
40
/// The fields at the start of the table, which are read directly.
41
#[derive(Clone, Copy, bytemuck :: AnyBitPattern)]
42
#[repr(C, packed)]
43
#[doc(hidden)]
44
pub struct VarcFixedHeader {
45
    pub version: BigEndian<MajorMinor>,
46
    pub coverage_offset: BigEndian<Offset32>,
47
    pub multi_var_store_offset: BigEndian<Nullable<Offset32>>,
48
    pub condition_list_offset: BigEndian<Nullable<Offset32>>,
49
    pub axis_indices_list_offset: BigEndian<Nullable<Offset32>>,
50
    pub var_composite_glyphs_offset: BigEndian<Offset32>,
51
}
52
53
#[allow(clippy::absurd_extreme_comparisons)]
54
const _: () = assert!(std::mem::size_of::<VarcFixedHeader>() <= Varc::MIN_SIZE);
55
56
/// [VARC](https://github.com/harfbuzz/boring-expansion-spec/blob/main/VARC.md) (Variable Composites / Components Table)
57
///
58
/// [FontTools VARC](https://github.com/fonttools/fonttools/blob/5e6b12d12fa08abafbeb7570f47707fbedf69a45/Lib/fontTools/ttLib/tables/otData.py#L3459-L3476)
59
#[derive(Clone)]
60
pub struct Varc<'a> {
61
    data: TableDataRef<'a, VarcFixedHeader>,
62
}
63
64
#[allow(clippy::needless_lifetimes)]
65
impl<'a> Varc<'a> {
66
    pub const MIN_SIZE: usize = (MajorMinor::RAW_BYTE_LEN
67
        + Offset32::RAW_BYTE_LEN
68
        + Offset32::RAW_BYTE_LEN
69
        + Offset32::RAW_BYTE_LEN
70
        + Offset32::RAW_BYTE_LEN
71
        + Offset32::RAW_BYTE_LEN);
72
    basic_table_impls!(impl_the_methods);
73
74
    /// Major/minor version number. Set to 1.0.
75
0
    pub fn version(&self) -> MajorMinor {
76
0
        self.data.header().version.get()
77
0
    }
78
79
175
    pub fn coverage_offset(&self) -> Offset32 {
80
175
        self.data.header().coverage_offset.get()
81
175
    }
82
83
    /// Attempt to resolve [`coverage_offset`][Self::coverage_offset].
84
175
    pub fn coverage(&self) -> Result<CoverageTable<'a>, ReadError> {
85
175
        let data = self.offset_data();
86
175
        self.coverage_offset().resolve(data)
87
175
    }
88
89
118
    pub fn multi_var_store_offset(&self) -> Nullable<Offset32> {
90
118
        self.data.header().multi_var_store_offset.get()
91
118
    }
92
93
    /// Attempt to resolve [`multi_var_store_offset`][Self::multi_var_store_offset].
94
118
    pub fn multi_var_store(&self) -> Option<Result<MultiItemVariationStore<'a>, ReadError>> {
95
118
        let data = self.offset_data();
96
118
        self.multi_var_store_offset().resolve(data)
97
118
    }
98
99
0
    pub fn condition_list_offset(&self) -> Nullable<Offset32> {
100
0
        self.data.header().condition_list_offset.get()
101
0
    }
102
103
    /// Attempt to resolve [`condition_list_offset`][Self::condition_list_offset].
104
0
    pub fn condition_list(&self) -> Option<Result<ConditionList<'a>, ReadError>> {
105
0
        let data = self.offset_data();
106
0
        self.condition_list_offset().resolve(data)
107
0
    }
108
109
454
    pub fn axis_indices_list_offset(&self) -> Nullable<Offset32> {
110
454
        self.data.header().axis_indices_list_offset.get()
111
454
    }
112
113
    /// Attempt to resolve [`axis_indices_list_offset`][Self::axis_indices_list_offset].
114
454
    pub fn axis_indices_list(&self) -> Option<Result<Index2<'a>, ReadError>> {
115
454
        let data = self.offset_data();
116
454
        self.axis_indices_list_offset().resolve(data)
117
454
    }
118
119
0
    pub fn var_composite_glyphs_offset(&self) -> Offset32 {
120
0
        self.data.header().var_composite_glyphs_offset.get()
121
0
    }
122
123
    /// Attempt to resolve [`var_composite_glyphs_offset`][Self::var_composite_glyphs_offset].
124
0
    pub fn var_composite_glyphs(&self) -> Result<Index2<'a>, ReadError> {
125
0
        let data = self.offset_data();
126
0
        self.var_composite_glyphs_offset().resolve(data)
127
0
    }
128
129
0
    pub fn version_byte_range(&self) -> Range<usize> {
130
0
        let start = 0usize;
131
0
        let end = start.saturating_add(MajorMinor::RAW_BYTE_LEN);
132
0
        start..end
133
0
    }
134
135
0
    pub fn coverage_offset_byte_range(&self) -> Range<usize> {
136
0
        let start = self.version_byte_range().end;
137
0
        let end = start.saturating_add(Offset32::RAW_BYTE_LEN);
138
0
        start..end
139
0
    }
140
141
0
    pub fn multi_var_store_offset_byte_range(&self) -> Range<usize> {
142
0
        let start = self.coverage_offset_byte_range().end;
143
0
        let end = start.saturating_add(Offset32::RAW_BYTE_LEN);
144
0
        start..end
145
0
    }
146
147
0
    pub fn condition_list_offset_byte_range(&self) -> Range<usize> {
148
0
        let start = self.multi_var_store_offset_byte_range().end;
149
0
        let end = start.saturating_add(Offset32::RAW_BYTE_LEN);
150
0
        start..end
151
0
    }
152
153
0
    pub fn axis_indices_list_offset_byte_range(&self) -> Range<usize> {
154
0
        let start = self.condition_list_offset_byte_range().end;
155
0
        let end = start.saturating_add(Offset32::RAW_BYTE_LEN);
156
0
        start..end
157
0
    }
158
159
0
    pub fn var_composite_glyphs_offset_byte_range(&self) -> Range<usize> {
160
0
        let start = self.axis_indices_list_offset_byte_range().end;
161
0
        let end = start.saturating_add(Offset32::RAW_BYTE_LEN);
162
0
        start..end
163
0
    }
164
}
165
166
const _: () = assert!(FontData::default_data_long_enough(Varc::MIN_SIZE));
167
168
impl Default for Varc<'_> {
169
0
    fn default() -> Self {
170
        Self {
171
0
            data: TableDataRef::new(FontData::default_table_data().as_bytes())
172
0
                .unwrap_or_else(|| unreachable!("the default data covers MIN_SIZE")),
173
        }
174
0
    }
175
}
176
177
impl Format<u16> for MultiItemVariationStore<'_> {
178
    const FORMAT: u16 = 1;
179
}
180
181
impl<'a> MinByteRange<'a> for MultiItemVariationStore<'a> {
182
0
    fn min_byte_range(&self) -> Range<usize> {
183
0
        0..self.variation_data_offsets_byte_range().end
184
0
    }
185
0
    fn min_table_bytes(&self) -> &'a [u8] {
186
0
        let range = self.min_byte_range();
187
0
        self.offset_data().as_bytes().get(range).unwrap_or_default()
188
0
    }
189
}
190
191
impl ReadArgs for MultiItemVariationStore<'_> {
192
    type Args = ();
193
}
194
195
impl<'a> FontRead<'a> for MultiItemVariationStore<'a> {
196
23
    fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
197
        #[allow(clippy::absurd_extreme_comparisons)]
198
23
        if data.len() < Self::MIN_SIZE {
199
1
            return Err(ReadError::OutOfBounds);
200
22
        }
201
22
        let Some(data) = TableDataRef::new(data.as_bytes()) else {
202
0
            return Err(ReadError::OutOfBounds);
203
        };
204
22
        Ok(Self { data })
205
23
    }
206
}
207
208
/// The fields at the start of the table, which are read directly.
209
#[derive(Clone, Copy, bytemuck :: AnyBitPattern)]
210
#[repr(C, packed)]
211
#[doc(hidden)]
212
pub struct MultiItemVariationStoreFixedHeader {
213
    pub format: BigEndian<u16>,
214
    pub region_list_offset: BigEndian<Offset32>,
215
    pub variation_data_count: BigEndian<u16>,
216
}
217
218
#[allow(clippy::absurd_extreme_comparisons)]
219
const _: () = assert!(
220
    std::mem::size_of::<MultiItemVariationStoreFixedHeader>() <= MultiItemVariationStore::MIN_SIZE
221
);
222
223
/// * <https://github.com/fonttools/fonttools/blob/5e6b12d12fa08abafbeb7570f47707fbedf69a45/Lib/fontTools/ttLib/tables/otData.py#L3451-L3457>
224
/// * <https://github.com/harfbuzz/harfbuzz/blob/7be12b33e3f07067c159d8f516eb31df58c75876/src/hb-ot-layout-common.hh#L3517-L3520C3>
225
#[derive(Clone)]
226
pub struct MultiItemVariationStore<'a> {
227
    data: TableDataRef<'a, MultiItemVariationStoreFixedHeader>,
228
}
229
230
#[allow(clippy::needless_lifetimes)]
231
impl<'a> MultiItemVariationStore<'a> {
232
    pub const MIN_SIZE: usize = (u16::RAW_BYTE_LEN + Offset32::RAW_BYTE_LEN + u16::RAW_BYTE_LEN);
233
    basic_table_impls!(impl_the_methods);
234
235
0
    pub fn format(&self) -> u16 {
236
0
        self.data.header().format.get()
237
0
    }
238
239
22
    pub fn region_list_offset(&self) -> Offset32 {
240
22
        self.data.header().region_list_offset.get()
241
22
    }
242
243
    /// Attempt to resolve [`region_list_offset`][Self::region_list_offset].
244
22
    pub fn region_list(&self) -> Result<SparseVariationRegionList<'a>, ReadError> {
245
22
        let data = self.offset_data();
246
22
        self.region_list_offset().resolve(data)
247
22
    }
248
249
0
    pub fn variation_data_count(&self) -> u16 {
250
0
        self.data.header().variation_data_count.get()
251
0
    }
252
253
0
    pub fn variation_data_offsets(&self) -> &'a [BigEndian<Offset32>] {
254
0
        let range = self.variation_data_offsets_byte_range();
255
0
        self.offset_data()
256
0
            .read_array(range)
257
0
            .ok()
258
0
            .unwrap_or_default()
259
0
    }
260
261
    /// A dynamically resolving wrapper for [`variation_data_offsets`][Self::variation_data_offsets].
262
0
    pub fn variation_data(&self) -> ArrayOfOffsets<'a, MultiItemVariationData<'a>, Offset32> {
263
0
        let data = self.offset_data();
264
0
        let offsets = self.variation_data_offsets();
265
0
        ArrayOfOffsets::new(offsets, data, ())
266
0
    }
267
268
0
    pub fn format_byte_range(&self) -> Range<usize> {
269
0
        let start = 0usize;
270
0
        let end = start.saturating_add(u16::RAW_BYTE_LEN);
271
0
        start..end
272
0
    }
273
274
0
    pub fn region_list_offset_byte_range(&self) -> Range<usize> {
275
0
        let start = self.format_byte_range().end;
276
0
        let end = start.saturating_add(Offset32::RAW_BYTE_LEN);
277
0
        start..end
278
0
    }
279
280
0
    pub fn variation_data_count_byte_range(&self) -> Range<usize> {
281
0
        let start = self.region_list_offset_byte_range().end;
282
0
        let end = start.saturating_add(u16::RAW_BYTE_LEN);
283
0
        start..end
284
0
    }
285
286
0
    pub fn variation_data_offsets_byte_range(&self) -> Range<usize> {
287
0
        let variation_data_count = self.variation_data_count();
288
0
        let start = self.variation_data_count_byte_range().end;
289
0
        let end = start.saturating_add(
290
0
            (transforms::to_usize(variation_data_count)).saturating_mul(Offset32::RAW_BYTE_LEN),
291
        );
292
0
        start..end
293
0
    }
294
}
295
296
const _: () = assert!(FontData::default_data_long_enough(
297
    MultiItemVariationStore::MIN_SIZE
298
));
299
300
impl Default for MultiItemVariationStore<'_> {
301
0
    fn default() -> Self {
302
        Self {
303
0
            data: TableDataRef::new(FontData::default_format_1_u16_table_data().as_bytes())
304
0
                .unwrap_or_else(|| unreachable!("the default data covers MIN_SIZE")),
305
        }
306
0
    }
307
}
308
309
impl<'a> MinByteRange<'a> for SparseVariationRegionList<'a> {
310
0
    fn min_byte_range(&self) -> Range<usize> {
311
0
        0..self.region_offsets_byte_range().end
312
0
    }
313
0
    fn min_table_bytes(&self) -> &'a [u8] {
314
0
        let range = self.min_byte_range();
315
0
        self.offset_data().as_bytes().get(range).unwrap_or_default()
316
0
    }
317
}
318
319
impl ReadArgs for SparseVariationRegionList<'_> {
320
    type Args = ();
321
}
322
323
impl<'a> FontRead<'a> for SparseVariationRegionList<'a> {
324
7
    fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
325
        #[allow(clippy::absurd_extreme_comparisons)]
326
7
        if data.len() < Self::MIN_SIZE {
327
1
            return Err(ReadError::OutOfBounds);
328
6
        }
329
6
        let Some(data) = TableDataRef::new(data.as_bytes()) else {
330
0
            return Err(ReadError::OutOfBounds);
331
        };
332
6
        Ok(Self { data })
333
7
    }
334
}
335
336
/// The fields at the start of the table, which are read directly.
337
#[derive(Clone, Copy, bytemuck :: AnyBitPattern)]
338
#[repr(C, packed)]
339
#[doc(hidden)]
340
pub struct SparseVariationRegionListFixedHeader {
341
    pub region_count: BigEndian<u32>,
342
}
343
344
#[allow(clippy::absurd_extreme_comparisons)]
345
const _: () = assert!(
346
    std::mem::size_of::<SparseVariationRegionListFixedHeader>()
347
        <= SparseVariationRegionList::MIN_SIZE
348
);
349
350
#[derive(Clone)]
351
pub struct SparseVariationRegionList<'a> {
352
    data: TableDataRef<'a, SparseVariationRegionListFixedHeader>,
353
}
354
355
#[allow(clippy::needless_lifetimes)]
356
impl<'a> SparseVariationRegionList<'a> {
357
    pub const MIN_SIZE: usize = u32::RAW_BYTE_LEN;
358
    basic_table_impls!(impl_the_methods);
359
360
0
    pub fn region_count(&self) -> u32 {
361
0
        self.data.header().region_count.get()
362
0
    }
363
364
0
    pub fn region_offsets(&self) -> &'a [BigEndian<Offset32>] {
365
0
        let range = self.region_offsets_byte_range();
366
0
        self.offset_data()
367
0
            .read_array(range)
368
0
            .ok()
369
0
            .unwrap_or_default()
370
0
    }
371
372
    /// A dynamically resolving wrapper for [`region_offsets`][Self::region_offsets].
373
0
    pub fn regions(&self) -> ArrayOfOffsets<'a, SparseVariationRegion<'a>, Offset32> {
374
0
        let data = self.offset_data();
375
0
        let offsets = self.region_offsets();
376
0
        ArrayOfOffsets::new(offsets, data, ())
377
0
    }
378
379
0
    pub fn region_count_byte_range(&self) -> Range<usize> {
380
0
        let start = 0usize;
381
0
        let end = start.saturating_add(u32::RAW_BYTE_LEN);
382
0
        start..end
383
0
    }
384
385
0
    pub fn region_offsets_byte_range(&self) -> Range<usize> {
386
0
        let region_count = self.region_count();
387
0
        let start = self.region_count_byte_range().end;
388
0
        let end = start.saturating_add(
389
0
            (transforms::to_usize(region_count)).saturating_mul(Offset32::RAW_BYTE_LEN),
390
        );
391
0
        start..end
392
0
    }
393
}
394
395
const _: () = assert!(FontData::default_data_long_enough(
396
    SparseVariationRegionList::MIN_SIZE
397
));
398
399
impl Default for SparseVariationRegionList<'_> {
400
0
    fn default() -> Self {
401
        Self {
402
0
            data: TableDataRef::new(FontData::default_table_data().as_bytes())
403
0
                .unwrap_or_else(|| unreachable!("the default data covers MIN_SIZE")),
404
        }
405
0
    }
406
}
407
408
impl<'a> MinByteRange<'a> for SparseVariationRegion<'a> {
409
0
    fn min_byte_range(&self) -> Range<usize> {
410
0
        0..self.axis_coordinate_offsets_byte_range().end
411
0
    }
412
0
    fn min_table_bytes(&self) -> &'a [u8] {
413
0
        let range = self.min_byte_range();
414
0
        self.offset_data().as_bytes().get(range).unwrap_or_default()
415
0
    }
416
}
417
418
impl ReadArgs for SparseVariationRegion<'_> {
419
    type Args = ();
420
}
421
422
impl<'a> FontRead<'a> for SparseVariationRegion<'a> {
423
0
    fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
424
        #[allow(clippy::absurd_extreme_comparisons)]
425
0
        if data.len() < Self::MIN_SIZE {
426
0
            return Err(ReadError::OutOfBounds);
427
0
        }
428
0
        let Some(data) = TableDataRef::new(data.as_bytes()) else {
429
0
            return Err(ReadError::OutOfBounds);
430
        };
431
0
        Ok(Self { data })
432
0
    }
433
}
434
435
/// The fields at the start of the table, which are read directly.
436
#[derive(Clone, Copy, bytemuck :: AnyBitPattern)]
437
#[repr(C, packed)]
438
#[doc(hidden)]
439
pub struct SparseVariationRegionFixedHeader {
440
    pub region_axis_count: BigEndian<u16>,
441
}
442
443
#[allow(clippy::absurd_extreme_comparisons)]
444
const _: () = assert!(
445
    std::mem::size_of::<SparseVariationRegionFixedHeader>() <= SparseVariationRegion::MIN_SIZE
446
);
447
448
#[derive(Clone)]
449
pub struct SparseVariationRegion<'a> {
450
    data: TableDataRef<'a, SparseVariationRegionFixedHeader>,
451
}
452
453
#[allow(clippy::needless_lifetimes)]
454
impl<'a> SparseVariationRegion<'a> {
455
    pub const MIN_SIZE: usize = u16::RAW_BYTE_LEN;
456
    basic_table_impls!(impl_the_methods);
457
458
0
    pub fn region_axis_count(&self) -> u16 {
459
0
        self.data.header().region_axis_count.get()
460
0
    }
461
462
0
    pub fn axis_coordinate_offsets(&self) -> &'a [BigEndian<Offset32>] {
463
0
        let range = self.axis_coordinate_offsets_byte_range();
464
0
        self.offset_data()
465
0
            .read_array(range)
466
0
            .ok()
467
0
            .unwrap_or_default()
468
0
    }
469
470
    /// A dynamically resolving wrapper for [`axis_coordinate_offsets`][Self::axis_coordinate_offsets].
471
0
    pub fn axis_coordinates(
472
0
        &self,
473
0
    ) -> ArrayOfOffsets<'a, SparseRegionAxisCoordinates<'a>, Offset32> {
474
0
        let data = self.offset_data();
475
0
        let offsets = self.axis_coordinate_offsets();
476
0
        ArrayOfOffsets::new(offsets, data, ())
477
0
    }
478
479
0
    pub fn region_axis_count_byte_range(&self) -> Range<usize> {
480
0
        let start = 0usize;
481
0
        let end = start.saturating_add(u16::RAW_BYTE_LEN);
482
0
        start..end
483
0
    }
484
485
0
    pub fn axis_coordinate_offsets_byte_range(&self) -> Range<usize> {
486
0
        let region_axis_count = self.region_axis_count();
487
0
        let start = self.region_axis_count_byte_range().end;
488
0
        let end = start.saturating_add(
489
0
            (transforms::to_usize(region_axis_count)).saturating_mul(Offset32::RAW_BYTE_LEN),
490
        );
491
0
        start..end
492
0
    }
493
}
494
495
const _: () = assert!(FontData::default_data_long_enough(
496
    SparseVariationRegion::MIN_SIZE
497
));
498
499
impl Default for SparseVariationRegion<'_> {
500
0
    fn default() -> Self {
501
        Self {
502
0
            data: TableDataRef::new(FontData::default_table_data().as_bytes())
503
0
                .unwrap_or_else(|| unreachable!("the default data covers MIN_SIZE")),
504
        }
505
0
    }
506
}
507
508
impl<'a> MinByteRange<'a> for SparseRegionAxisCoordinates<'a> {
509
0
    fn min_byte_range(&self) -> Range<usize> {
510
0
        0..self.end_byte_range().end
511
0
    }
512
0
    fn min_table_bytes(&self) -> &'a [u8] {
513
0
        let range = self.min_byte_range();
514
0
        self.offset_data().as_bytes().get(range).unwrap_or_default()
515
0
    }
516
}
517
518
impl ReadArgs for SparseRegionAxisCoordinates<'_> {
519
    type Args = ();
520
}
521
522
impl<'a> FontRead<'a> for SparseRegionAxisCoordinates<'a> {
523
0
    fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
524
        #[allow(clippy::absurd_extreme_comparisons)]
525
0
        if data.len() < Self::MIN_SIZE {
526
0
            return Err(ReadError::OutOfBounds);
527
0
        }
528
0
        let Some(data) = TableDataRef::new(data.as_bytes()) else {
529
0
            return Err(ReadError::OutOfBounds);
530
        };
531
0
        Ok(Self { data })
532
0
    }
533
}
534
535
/// The fields at the start of the table, which are read directly.
536
#[derive(Clone, Copy, bytemuck :: AnyBitPattern)]
537
#[repr(C, packed)]
538
#[doc(hidden)]
539
pub struct SparseRegionAxisCoordinatesFixedHeader {
540
    pub axis_index: BigEndian<u16>,
541
    pub start: BigEndian<F2Dot14>,
542
    pub peak: BigEndian<F2Dot14>,
543
    pub end: BigEndian<F2Dot14>,
544
}
545
546
#[allow(clippy::absurd_extreme_comparisons)]
547
const _: () = assert!(
548
    std::mem::size_of::<SparseRegionAxisCoordinatesFixedHeader>()
549
        <= SparseRegionAxisCoordinates::MIN_SIZE
550
);
551
552
#[derive(Clone)]
553
pub struct SparseRegionAxisCoordinates<'a> {
554
    data: TableDataRef<'a, SparseRegionAxisCoordinatesFixedHeader>,
555
}
556
557
#[allow(clippy::needless_lifetimes)]
558
impl<'a> SparseRegionAxisCoordinates<'a> {
559
    pub const MIN_SIZE: usize =
560
        (u16::RAW_BYTE_LEN + F2Dot14::RAW_BYTE_LEN + F2Dot14::RAW_BYTE_LEN + F2Dot14::RAW_BYTE_LEN);
561
    basic_table_impls!(impl_the_methods);
562
563
0
    pub fn axis_index(&self) -> u16 {
564
0
        self.data.header().axis_index.get()
565
0
    }
566
567
0
    pub fn start(&self) -> F2Dot14 {
568
0
        self.data.header().start.get()
569
0
    }
570
571
0
    pub fn peak(&self) -> F2Dot14 {
572
0
        self.data.header().peak.get()
573
0
    }
574
575
0
    pub fn end(&self) -> F2Dot14 {
576
0
        self.data.header().end.get()
577
0
    }
578
579
0
    pub fn axis_index_byte_range(&self) -> Range<usize> {
580
0
        let start = 0usize;
581
0
        let end = start.saturating_add(u16::RAW_BYTE_LEN);
582
0
        start..end
583
0
    }
584
585
0
    pub fn start_byte_range(&self) -> Range<usize> {
586
0
        let start = self.axis_index_byte_range().end;
587
0
        let end = start.saturating_add(F2Dot14::RAW_BYTE_LEN);
588
0
        start..end
589
0
    }
590
591
0
    pub fn peak_byte_range(&self) -> Range<usize> {
592
0
        let start = self.start_byte_range().end;
593
0
        let end = start.saturating_add(F2Dot14::RAW_BYTE_LEN);
594
0
        start..end
595
0
    }
596
597
0
    pub fn end_byte_range(&self) -> Range<usize> {
598
0
        let start = self.peak_byte_range().end;
599
0
        let end = start.saturating_add(F2Dot14::RAW_BYTE_LEN);
600
0
        start..end
601
0
    }
602
}
603
604
const _: () = assert!(FontData::default_data_long_enough(
605
    SparseRegionAxisCoordinates::MIN_SIZE
606
));
607
608
impl Default for SparseRegionAxisCoordinates<'_> {
609
0
    fn default() -> Self {
610
        Self {
611
0
            data: TableDataRef::new(FontData::default_table_data().as_bytes())
612
0
                .unwrap_or_else(|| unreachable!("the default data covers MIN_SIZE")),
613
        }
614
0
    }
615
}
616
617
impl Format<u8> for MultiItemVariationData<'_> {
618
    const FORMAT: u8 = 1;
619
}
620
621
impl<'a> MinByteRange<'a> for MultiItemVariationData<'a> {
622
0
    fn min_byte_range(&self) -> Range<usize> {
623
0
        0..self.delta_sets_offset_byte_range().end
624
0
    }
625
0
    fn min_table_bytes(&self) -> &'a [u8] {
626
0
        let range = self.min_byte_range();
627
0
        self.offset_data().as_bytes().get(range).unwrap_or_default()
628
0
    }
629
}
630
631
impl ReadArgs for MultiItemVariationData<'_> {
632
    type Args = ();
633
}
634
635
impl<'a> FontRead<'a> for MultiItemVariationData<'a> {
636
0
    fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
637
        #[allow(clippy::absurd_extreme_comparisons)]
638
0
        if data.len() < Self::MIN_SIZE {
639
0
            return Err(ReadError::OutOfBounds);
640
0
        }
641
0
        let Some(data) = TableDataRef::new(data.as_bytes()) else {
642
0
            return Err(ReadError::OutOfBounds);
643
        };
644
0
        Ok(Self { data })
645
0
    }
646
}
647
648
/// The fields at the start of the table, which are read directly.
649
#[derive(Clone, Copy, bytemuck :: AnyBitPattern)]
650
#[repr(C, packed)]
651
#[doc(hidden)]
652
pub struct MultiItemVariationDataFixedHeader {
653
    pub format: u8,
654
    pub region_index_count: BigEndian<u16>,
655
}
656
657
#[allow(clippy::absurd_extreme_comparisons)]
658
const _: () = assert!(
659
    std::mem::size_of::<MultiItemVariationDataFixedHeader>() <= MultiItemVariationData::MIN_SIZE
660
);
661
662
#[derive(Clone)]
663
pub struct MultiItemVariationData<'a> {
664
    data: TableDataRef<'a, MultiItemVariationDataFixedHeader>,
665
}
666
667
#[allow(clippy::needless_lifetimes)]
668
impl<'a> MultiItemVariationData<'a> {
669
    pub const MIN_SIZE: usize = (u8::RAW_BYTE_LEN + u16::RAW_BYTE_LEN + Offset32::RAW_BYTE_LEN);
670
    basic_table_impls!(impl_the_methods);
671
672
0
    pub fn format(&self) -> u8 {
673
0
        self.data.header().format
674
0
    }
675
676
0
    pub fn region_index_count(&self) -> u16 {
677
0
        self.data.header().region_index_count.get()
678
0
    }
679
680
0
    pub fn region_indices(&self) -> &'a [BigEndian<u16>] {
681
0
        let range = self.region_indices_byte_range();
682
0
        self.offset_data()
683
0
            .read_array(range)
684
0
            .ok()
685
0
            .unwrap_or_default()
686
0
    }
687
688
0
    pub fn delta_sets_offset(&self) -> Offset32 {
689
0
        let range = self.delta_sets_offset_byte_range();
690
0
        self.offset_data()
691
0
            .read_at(range.start)
692
0
            .ok()
693
0
            .unwrap_or(Offset32::new(Default::default()))
694
0
    }
695
696
    /// Attempt to resolve [`delta_sets_offset`][Self::delta_sets_offset].
697
0
    pub fn delta_sets(&self) -> Result<Index2<'a>, ReadError> {
698
0
        let data = self.offset_data();
699
0
        self.delta_sets_offset().resolve(data)
700
0
    }
701
702
0
    pub fn format_byte_range(&self) -> Range<usize> {
703
0
        let start = 0usize;
704
0
        let end = start.saturating_add(u8::RAW_BYTE_LEN);
705
0
        start..end
706
0
    }
707
708
0
    pub fn region_index_count_byte_range(&self) -> Range<usize> {
709
0
        let start = self.format_byte_range().end;
710
0
        let end = start.saturating_add(u16::RAW_BYTE_LEN);
711
0
        start..end
712
0
    }
713
714
0
    pub fn region_indices_byte_range(&self) -> Range<usize> {
715
0
        let region_index_count = self.region_index_count();
716
0
        let start = self.region_index_count_byte_range().end;
717
0
        let end = start.saturating_add(
718
0
            (transforms::to_usize(region_index_count)).saturating_mul(u16::RAW_BYTE_LEN),
719
        );
720
0
        start..end
721
0
    }
722
723
0
    pub fn delta_sets_offset_byte_range(&self) -> Range<usize> {
724
0
        let start = self.region_indices_byte_range().end;
725
0
        let end = start.saturating_add(Offset32::RAW_BYTE_LEN);
726
0
        start..end
727
0
    }
728
}
729
730
const _: () = assert!(FontData::default_data_long_enough(
731
    MultiItemVariationData::MIN_SIZE
732
));
733
734
impl Default for MultiItemVariationData<'_> {
735
0
    fn default() -> Self {
736
        Self {
737
0
            data: TableDataRef::new(FontData::default_format_1_u8_table_data().as_bytes())
738
0
                .unwrap_or_else(|| unreachable!("the default data covers MIN_SIZE")),
739
        }
740
0
    }
741
}
742
743
impl<'a> MinByteRange<'a> for ConditionList<'a> {
744
0
    fn min_byte_range(&self) -> Range<usize> {
745
0
        0..self.condition_offsets_byte_range().end
746
0
    }
747
0
    fn min_table_bytes(&self) -> &'a [u8] {
748
0
        let range = self.min_byte_range();
749
0
        self.offset_data().as_bytes().get(range).unwrap_or_default()
750
0
    }
751
}
752
753
impl ReadArgs for ConditionList<'_> {
754
    type Args = ();
755
}
756
757
impl<'a> FontRead<'a> for ConditionList<'a> {
758
0
    fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
759
        #[allow(clippy::absurd_extreme_comparisons)]
760
0
        if data.len() < Self::MIN_SIZE {
761
0
            return Err(ReadError::OutOfBounds);
762
0
        }
763
0
        let Some(data) = TableDataRef::new(data.as_bytes()) else {
764
0
            return Err(ReadError::OutOfBounds);
765
        };
766
0
        Ok(Self { data })
767
0
    }
768
}
769
770
/// The fields at the start of the table, which are read directly.
771
#[derive(Clone, Copy, bytemuck :: AnyBitPattern)]
772
#[repr(C, packed)]
773
#[doc(hidden)]
774
pub struct ConditionListFixedHeader {
775
    pub condition_count: BigEndian<u32>,
776
}
777
778
#[allow(clippy::absurd_extreme_comparisons)]
779
const _: () = assert!(std::mem::size_of::<ConditionListFixedHeader>() <= ConditionList::MIN_SIZE);
780
781
#[derive(Clone)]
782
pub struct ConditionList<'a> {
783
    data: TableDataRef<'a, ConditionListFixedHeader>,
784
}
785
786
#[allow(clippy::needless_lifetimes)]
787
impl<'a> ConditionList<'a> {
788
    pub const MIN_SIZE: usize = u32::RAW_BYTE_LEN;
789
    basic_table_impls!(impl_the_methods);
790
791
0
    pub fn condition_count(&self) -> u32 {
792
0
        self.data.header().condition_count.get()
793
0
    }
794
795
0
    pub fn condition_offsets(&self) -> &'a [BigEndian<Offset32>] {
796
0
        let range = self.condition_offsets_byte_range();
797
0
        self.offset_data()
798
0
            .read_array(range)
799
0
            .ok()
800
0
            .unwrap_or_default()
801
0
    }
802
803
    /// A dynamically resolving wrapper for [`condition_offsets`][Self::condition_offsets].
804
0
    pub fn conditions(&self) -> ArrayOfOffsets<'a, Condition<'a>, Offset32> {
805
0
        let data = self.offset_data();
806
0
        let offsets = self.condition_offsets();
807
0
        ArrayOfOffsets::new(offsets, data, ())
808
0
    }
809
810
0
    pub fn condition_count_byte_range(&self) -> Range<usize> {
811
0
        let start = 0usize;
812
0
        let end = start.saturating_add(u32::RAW_BYTE_LEN);
813
0
        start..end
814
0
    }
815
816
0
    pub fn condition_offsets_byte_range(&self) -> Range<usize> {
817
0
        let condition_count = self.condition_count();
818
0
        let start = self.condition_count_byte_range().end;
819
0
        let end = start.saturating_add(
820
0
            (transforms::to_usize(condition_count)).saturating_mul(Offset32::RAW_BYTE_LEN),
821
        );
822
0
        start..end
823
0
    }
824
}
825
826
const _: () = assert!(FontData::default_data_long_enough(ConditionList::MIN_SIZE));
827
828
impl Default for ConditionList<'_> {
829
0
    fn default() -> Self {
830
        Self {
831
0
            data: TableDataRef::new(FontData::default_table_data().as_bytes())
832
0
                .unwrap_or_else(|| unreachable!("the default data covers MIN_SIZE")),
833
        }
834
0
    }
835
}
836
837
/// Flags used in the [VarcComponent] byte stream
838
///
839
/// <https://github.com/harfbuzz/boring-expansion-spec/blob/main/VARC.md#variable-component-flags>
840
#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, bytemuck :: AnyBitPattern)]
841
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
842
#[repr(transparent)]
843
pub struct VarcFlags {
844
    bits: u32,
845
}
846
847
impl VarcFlags {
848
    pub const RESET_UNSPECIFIED_AXES: Self = Self {
849
        bits: 0b0000_0000_0000_0001,
850
    };
851
852
    pub const HAVE_AXES: Self = Self {
853
        bits: 0b0000_0000_0000_0010,
854
    };
855
856
    pub const AXIS_VALUES_HAVE_VARIATION: Self = Self {
857
        bits: 0b0000_0000_0000_0100,
858
    };
859
860
    pub const TRANSFORM_HAS_VARIATION: Self = Self {
861
        bits: 0b0000_0000_0000_1000,
862
    };
863
864
    pub const HAVE_TRANSLATE_X: Self = Self {
865
        bits: 0b0000_0000_0001_0000,
866
    };
867
868
    pub const HAVE_TRANSLATE_Y: Self = Self {
869
        bits: 0b0000_0000_0010_0000,
870
    };
871
872
    pub const HAVE_ROTATION: Self = Self {
873
        bits: 0b0000_0000_0100_0000,
874
    };
875
876
    pub const HAVE_CONDITION: Self = Self {
877
        bits: 0b0000_0000_1000_0000,
878
    };
879
880
    pub const HAVE_SCALE_X: Self = Self {
881
        bits: 0b0000_0001_0000_0000,
882
    };
883
884
    pub const HAVE_SCALE_Y: Self = Self {
885
        bits: 0b0000_0010_0000_0000,
886
    };
887
888
    pub const HAVE_TCENTER_X: Self = Self {
889
        bits: 0b0000_0100_0000_0000,
890
    };
891
892
    pub const HAVE_TCENTER_Y: Self = Self {
893
        bits: 0b0000_1000_0000_0000,
894
    };
895
896
    pub const GID_IS_24BIT: Self = Self {
897
        bits: 0b0001_0000_0000_0000,
898
    };
899
900
    pub const HAVE_SKEW_X: Self = Self {
901
        bits: 0b0010_0000_0000_0000,
902
    };
903
904
    pub const HAVE_SKEW_Y: Self = Self {
905
        bits: 0b0100_0000_0000_0000,
906
    };
907
908
    pub const RESERVED_MASK: Self = Self { bits: 0xFFFF8000 };
909
}
910
911
impl VarcFlags {
912
    ///  Returns an empty set of flags.
913
    #[inline]
914
0
    pub const fn empty() -> Self {
915
0
        Self { bits: 0 }
916
0
    }
917
918
    /// Returns the set containing all flags.
919
    #[inline]
920
0
    pub const fn all() -> Self {
921
0
        Self {
922
0
            bits: Self::RESET_UNSPECIFIED_AXES.bits
923
0
                | Self::HAVE_AXES.bits
924
0
                | Self::AXIS_VALUES_HAVE_VARIATION.bits
925
0
                | Self::TRANSFORM_HAS_VARIATION.bits
926
0
                | Self::HAVE_TRANSLATE_X.bits
927
0
                | Self::HAVE_TRANSLATE_Y.bits
928
0
                | Self::HAVE_ROTATION.bits
929
0
                | Self::HAVE_CONDITION.bits
930
0
                | Self::HAVE_SCALE_X.bits
931
0
                | Self::HAVE_SCALE_Y.bits
932
0
                | Self::HAVE_TCENTER_X.bits
933
0
                | Self::HAVE_TCENTER_Y.bits
934
0
                | Self::GID_IS_24BIT.bits
935
0
                | Self::HAVE_SKEW_X.bits
936
0
                | Self::HAVE_SKEW_Y.bits
937
0
                | Self::RESERVED_MASK.bits,
938
0
        }
939
0
    }
940
941
    /// Returns the raw value of the flags currently stored.
942
    #[inline]
943
0
    pub const fn bits(&self) -> u32 {
944
0
        self.bits
945
0
    }
946
947
    /// Convert from underlying bit representation, unless that
948
    /// representation contains bits that do not correspond to a flag.
949
    #[inline]
950
0
    pub const fn from_bits(bits: u32) -> Option<Self> {
951
0
        if (bits & !Self::all().bits()) == 0 {
952
0
            Some(Self { bits })
953
        } else {
954
0
            None
955
        }
956
0
    }
957
958
    /// Convert from underlying bit representation, dropping any bits
959
    /// that do not correspond to flags.
960
    #[inline]
961
0
    pub const fn from_bits_truncate(bits: u32) -> Self {
962
0
        Self {
963
0
            bits: bits & Self::all().bits,
964
0
        }
965
0
    }
966
967
    /// Returns `true` if no flags are currently stored.
968
    #[inline]
969
0
    pub const fn is_empty(&self) -> bool {
970
0
        self.bits() == Self::empty().bits()
971
0
    }
972
973
    /// Returns `true` if there are flags common to both `self` and `other`.
974
    #[inline]
975
0
    pub const fn intersects(&self, other: Self) -> bool {
976
0
        !(Self {
977
0
            bits: self.bits & other.bits,
978
0
        })
979
0
        .is_empty()
980
0
    }
981
982
    /// Returns `true` if all of the flags in `other` are contained within `self`.
983
    #[inline]
984
0
    pub const fn contains(&self, other: Self) -> bool {
985
0
        (self.bits & other.bits) == other.bits
986
0
    }
987
988
    /// Inserts the specified flags in-place.
989
    #[inline]
990
0
    pub fn insert(&mut self, other: Self) {
991
0
        self.bits |= other.bits;
992
0
    }
993
994
    /// Removes the specified flags in-place.
995
    #[inline]
996
0
    pub fn remove(&mut self, other: Self) {
997
0
        self.bits &= !other.bits;
998
0
    }
999
1000
    /// Toggles the specified flags in-place.
1001
    #[inline]
1002
0
    pub fn toggle(&mut self, other: Self) {
1003
0
        self.bits ^= other.bits;
1004
0
    }
1005
1006
    /// Returns the intersection between the flags in `self` and
1007
    /// `other`.
1008
    ///
1009
    /// Specifically, the returned set contains only the flags which are
1010
    /// present in *both* `self` *and* `other`.
1011
    ///
1012
    /// This is equivalent to using the `&` operator (e.g.
1013
    /// [`ops::BitAnd`]), as in `flags & other`.
1014
    ///
1015
    /// [`ops::BitAnd`]: https://doc.rust-lang.org/std/ops/trait.BitAnd.html
1016
    #[inline]
1017
    #[must_use]
1018
0
    pub const fn intersection(self, other: Self) -> Self {
1019
0
        Self {
1020
0
            bits: self.bits & other.bits,
1021
0
        }
1022
0
    }
1023
1024
    /// Returns the union of between the flags in `self` and `other`.
1025
    ///
1026
    /// Specifically, the returned set contains all flags which are
1027
    /// present in *either* `self` *or* `other`, including any which are
1028
    /// present in both.
1029
    ///
1030
    /// This is equivalent to using the `|` operator (e.g.
1031
    /// [`ops::BitOr`]), as in `flags | other`.
1032
    ///
1033
    /// [`ops::BitOr`]: https://doc.rust-lang.org/std/ops/trait.BitOr.html
1034
    #[inline]
1035
    #[must_use]
1036
0
    pub const fn union(self, other: Self) -> Self {
1037
0
        Self {
1038
0
            bits: self.bits | other.bits,
1039
0
        }
1040
0
    }
1041
1042
    /// Returns the difference between the flags in `self` and `other`.
1043
    ///
1044
    /// Specifically, the returned set contains all flags present in
1045
    /// `self`, except for the ones present in `other`.
1046
    ///
1047
    /// It is also conceptually equivalent to the "bit-clear" operation:
1048
    /// `flags & !other` (and this syntax is also supported).
1049
    ///
1050
    /// This is equivalent to using the `-` operator (e.g.
1051
    /// [`ops::Sub`]), as in `flags - other`.
1052
    ///
1053
    /// [`ops::Sub`]: https://doc.rust-lang.org/std/ops/trait.Sub.html
1054
    #[inline]
1055
    #[must_use]
1056
0
    pub const fn difference(self, other: Self) -> Self {
1057
0
        Self {
1058
0
            bits: self.bits & !other.bits,
1059
0
        }
1060
0
    }
1061
}
1062
1063
impl std::ops::BitOr for VarcFlags {
1064
    type Output = Self;
1065
1066
    /// Returns the union of the two sets of flags.
1067
    #[inline]
1068
0
    fn bitor(self, other: VarcFlags) -> Self {
1069
0
        Self {
1070
0
            bits: self.bits | other.bits,
1071
0
        }
1072
0
    }
1073
}
1074
1075
impl std::ops::BitOrAssign for VarcFlags {
1076
    /// Adds the set of flags.
1077
    #[inline]
1078
0
    fn bitor_assign(&mut self, other: Self) {
1079
0
        self.bits |= other.bits;
1080
0
    }
1081
}
1082
1083
impl std::ops::BitXor for VarcFlags {
1084
    type Output = Self;
1085
1086
    /// Returns the left flags, but with all the right flags toggled.
1087
    #[inline]
1088
0
    fn bitxor(self, other: Self) -> Self {
1089
0
        Self {
1090
0
            bits: self.bits ^ other.bits,
1091
0
        }
1092
0
    }
1093
}
1094
1095
impl std::ops::BitXorAssign for VarcFlags {
1096
    /// Toggles the set of flags.
1097
    #[inline]
1098
0
    fn bitxor_assign(&mut self, other: Self) {
1099
0
        self.bits ^= other.bits;
1100
0
    }
1101
}
1102
1103
impl std::ops::BitAnd for VarcFlags {
1104
    type Output = Self;
1105
1106
    /// Returns the intersection between the two sets of flags.
1107
    #[inline]
1108
0
    fn bitand(self, other: Self) -> Self {
1109
0
        Self {
1110
0
            bits: self.bits & other.bits,
1111
0
        }
1112
0
    }
1113
}
1114
1115
impl std::ops::BitAndAssign for VarcFlags {
1116
    /// Disables all flags disabled in the set.
1117
    #[inline]
1118
0
    fn bitand_assign(&mut self, other: Self) {
1119
0
        self.bits &= other.bits;
1120
0
    }
1121
}
1122
1123
impl std::ops::Sub for VarcFlags {
1124
    type Output = Self;
1125
1126
    /// Returns the set difference of the two sets of flags.
1127
    #[inline]
1128
0
    fn sub(self, other: Self) -> Self {
1129
0
        Self {
1130
0
            bits: self.bits & !other.bits,
1131
0
        }
1132
0
    }
1133
}
1134
1135
impl std::ops::SubAssign for VarcFlags {
1136
    /// Disables all flags enabled in the set.
1137
    #[inline]
1138
0
    fn sub_assign(&mut self, other: Self) {
1139
0
        self.bits &= !other.bits;
1140
0
    }
1141
}
1142
1143
impl std::ops::Not for VarcFlags {
1144
    type Output = Self;
1145
1146
    /// Returns the complement of this set of flags.
1147
    #[inline]
1148
0
    fn not(self) -> Self {
1149
0
        Self { bits: !self.bits } & Self::all()
1150
0
    }
1151
}
1152
1153
impl std::fmt::Debug for VarcFlags {
1154
0
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1155
0
        let members: &[(&str, Self)] = &[
1156
0
            ("RESET_UNSPECIFIED_AXES", Self::RESET_UNSPECIFIED_AXES),
1157
0
            ("HAVE_AXES", Self::HAVE_AXES),
1158
0
            (
1159
0
                "AXIS_VALUES_HAVE_VARIATION",
1160
0
                Self::AXIS_VALUES_HAVE_VARIATION,
1161
0
            ),
1162
0
            ("TRANSFORM_HAS_VARIATION", Self::TRANSFORM_HAS_VARIATION),
1163
0
            ("HAVE_TRANSLATE_X", Self::HAVE_TRANSLATE_X),
1164
0
            ("HAVE_TRANSLATE_Y", Self::HAVE_TRANSLATE_Y),
1165
0
            ("HAVE_ROTATION", Self::HAVE_ROTATION),
1166
0
            ("HAVE_CONDITION", Self::HAVE_CONDITION),
1167
0
            ("HAVE_SCALE_X", Self::HAVE_SCALE_X),
1168
0
            ("HAVE_SCALE_Y", Self::HAVE_SCALE_Y),
1169
0
            ("HAVE_TCENTER_X", Self::HAVE_TCENTER_X),
1170
0
            ("HAVE_TCENTER_Y", Self::HAVE_TCENTER_Y),
1171
0
            ("GID_IS_24BIT", Self::GID_IS_24BIT),
1172
0
            ("HAVE_SKEW_X", Self::HAVE_SKEW_X),
1173
0
            ("HAVE_SKEW_Y", Self::HAVE_SKEW_Y),
1174
0
            ("RESERVED_MASK", Self::RESERVED_MASK),
1175
0
        ];
1176
0
        let mut first = true;
1177
0
        for (name, value) in members {
1178
0
            if self.contains(*value) {
1179
0
                if !first {
1180
0
                    f.write_str(" | ")?;
1181
0
                }
1182
0
                first = false;
1183
0
                f.write_str(name)?;
1184
0
            }
1185
        }
1186
0
        if first {
1187
0
            f.write_str("(empty)")?;
1188
0
        }
1189
0
        Ok(())
1190
0
    }
1191
}
1192
1193
impl std::fmt::Binary for VarcFlags {
1194
0
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1195
0
        std::fmt::Binary::fmt(&self.bits, f)
1196
0
    }
1197
}
1198
1199
impl std::fmt::Octal for VarcFlags {
1200
0
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1201
0
        std::fmt::Octal::fmt(&self.bits, f)
1202
0
    }
1203
}
1204
1205
impl std::fmt::LowerHex for VarcFlags {
1206
0
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1207
0
        std::fmt::LowerHex::fmt(&self.bits, f)
1208
0
    }
1209
}
1210
1211
impl std::fmt::UpperHex for VarcFlags {
1212
0
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1213
0
        std::fmt::UpperHex::fmt(&self.bits, f)
1214
0
    }
1215
}
1216
1217
impl font_types::Scalar for VarcFlags {
1218
    type Raw = <u32 as font_types::Scalar>::Raw;
1219
0
    fn to_raw(self) -> Self::Raw {
1220
0
        self.bits().to_raw()
1221
0
    }
1222
0
    fn from_raw(raw: Self::Raw) -> Self {
1223
0
        let t = <u32>::from_raw(raw);
1224
0
        Self::from_bits_truncate(t)
1225
0
    }
1226
}