Coverage Report

Created: 2026-10-24 07:19

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