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_cpal.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 Cpal<'a> {
9
0
    fn min_byte_range(&self) -> Range<usize> {
10
0
        0..self.color_record_indices_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 Cpal<'_> {
19
    /// `CPAL`
20
    const TAG: Tag = Tag::new(b"CPAL");
21
}
22
23
impl ReadArgs for Cpal<'_> {
24
    type Args = ();
25
}
26
27
impl<'a> FontRead<'a> for Cpal<'a> {
28
0
    fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
29
        #[allow(clippy::absurd_extreme_comparisons)]
30
0
        if data.len() < Self::MIN_SIZE {
31
0
            return Err(ReadError::OutOfBounds);
32
0
        }
33
0
        let Some(data) = TableDataRef::new(data.as_bytes()) else {
34
0
            return Err(ReadError::OutOfBounds);
35
        };
36
0
        Ok(Self { data })
37
0
    }
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 CpalFixedHeader {
45
    pub version: BigEndian<u16>,
46
    pub num_palette_entries: BigEndian<u16>,
47
    pub num_palettes: BigEndian<u16>,
48
    pub num_color_records: BigEndian<u16>,
49
    pub color_records_array_offset: BigEndian<Nullable<Offset32>>,
50
}
51
52
#[allow(clippy::absurd_extreme_comparisons)]
53
const _: () = assert!(std::mem::size_of::<CpalFixedHeader>() <= Cpal::MIN_SIZE);
54
55
/// [CPAL (Color Palette Table)](https://learn.microsoft.com/en-us/typography/opentype/spec/cpal#palette-table-header) table
56
#[derive(Clone)]
57
pub struct Cpal<'a> {
58
    data: TableDataRef<'a, CpalFixedHeader>,
59
}
60
61
#[allow(clippy::needless_lifetimes)]
62
impl<'a> Cpal<'a> {
63
    pub const MIN_SIZE: usize = (u16::RAW_BYTE_LEN
64
        + u16::RAW_BYTE_LEN
65
        + u16::RAW_BYTE_LEN
66
        + u16::RAW_BYTE_LEN
67
        + Offset32::RAW_BYTE_LEN);
68
    basic_table_impls!(impl_the_methods);
69
70
    /// Table version number (=0).
71
0
    pub fn version(&self) -> u16 {
72
0
        self.data.header().version.get()
73
0
    }
74
75
    /// Number of palette entries in each palette.
76
0
    pub fn num_palette_entries(&self) -> u16 {
77
0
        self.data.header().num_palette_entries.get()
78
0
    }
79
80
    /// Number of palettes in the table.
81
0
    pub fn num_palettes(&self) -> u16 {
82
0
        self.data.header().num_palettes.get()
83
0
    }
84
85
    /// Total number of color records, combined for all palettes.
86
0
    pub fn num_color_records(&self) -> u16 {
87
0
        self.data.header().num_color_records.get()
88
0
    }
89
90
    /// Offset from the beginning of CPAL table to the first
91
    /// ColorRecord.
92
0
    pub fn color_records_array_offset(&self) -> Nullable<Offset32> {
93
0
        self.data.header().color_records_array_offset.get()
94
0
    }
95
96
    /// Attempt to resolve [`color_records_array_offset`][Self::color_records_array_offset].
97
0
    pub fn color_records_array(&self) -> Option<Result<&'a [ColorRecord], ReadError>> {
98
0
        let data = self.offset_data();
99
0
        let args = self.num_color_records();
100
0
        self.color_records_array_offset()
101
0
            .resolve_with_args(data, args)
102
0
    }
103
104
    /// Index of each palette’s first color record in the combined
105
    /// color record array.
106
0
    pub fn color_record_indices(&self) -> &'a [BigEndian<u16>] {
107
0
        let range = self.color_record_indices_byte_range();
108
0
        self.offset_data()
109
0
            .read_array(range)
110
0
            .ok()
111
0
            .unwrap_or_default()
112
0
    }
113
114
    /// Offset from the beginning of CPAL table to the [Palette Types Array][].
115
    ///
116
    /// This is an array of 32-bit flag fields that describe properties of each palette.
117
    ///
118
    /// [Palette Types Array]: https://learn.microsoft.com/en-us/typography/opentype/spec/cpal#palette-type-array
119
0
    pub fn palette_types_array_offset(&self) -> Option<Nullable<Offset32>> {
120
0
        let range = self.palette_types_array_offset_byte_range();
121
0
        (!range.is_empty())
122
0
            .then(|| self.offset_data().read_at(range.start).ok())
123
0
            .flatten()
124
0
    }
125
126
    /// Attempt to resolve [`palette_types_array_offset`][Self::palette_types_array_offset].
127
0
    pub fn palette_types_array(&self) -> Option<Result<&'a [BigEndian<PaletteType>], ReadError>> {
128
0
        let data = self.offset_data();
129
0
        let args = self.num_palettes();
130
0
        self.palette_types_array_offset()
131
0
            .map(|x| x.resolve_with_args(data, args))?
132
0
    }
133
134
    /// Offset from the beginning of CPAL table to the [Palette Labels Array][].
135
    ///
136
    /// This is an array of 'name' table IDs (typically in the font-specific name
137
    /// ID range) that specify user interface strings associated with  each palette.
138
    /// Use 0xFFFF if no name ID is provided for a palette.
139
    ///
140
    /// [Palette Labels Array]: https://learn.microsoft.com/en-us/typography/opentype/spec/cpal#palette-labels-array
141
0
    pub fn palette_labels_array_offset(&self) -> Option<Nullable<Offset32>> {
142
0
        let range = self.palette_labels_array_offset_byte_range();
143
0
        (!range.is_empty())
144
0
            .then(|| self.offset_data().read_at(range.start).ok())
145
0
            .flatten()
146
0
    }
147
148
    /// Attempt to resolve [`palette_labels_array_offset`][Self::palette_labels_array_offset].
149
0
    pub fn palette_labels_array(&self) -> Option<Result<&'a [BigEndian<NameId>], ReadError>> {
150
0
        let data = self.offset_data();
151
0
        let args = self.num_palettes();
152
0
        self.palette_labels_array_offset()
153
0
            .map(|x| x.resolve_with_args(data, args))?
154
0
    }
155
156
    /// Offset from the beginning of CPAL table to the [Palette Entry Labels Array][].
157
    ///
158
    /// This is an array of 'name' table IDs (typically in the font-specific name
159
    /// ID range) that specify user interface strings associated with  each palette
160
    /// entry, e.g. “Outline”, “Fill”. This set of palette entry labels applies
161
    /// to all palettes in the font. Use  0xFFFF if no name ID is provided for a
162
    /// palette entry.
163
    ///
164
    /// [Palette Entry Labels Array]: https://learn.microsoft.com/en-us/typography/opentype/spec/cpal#palette-entry-label-array
165
0
    pub fn palette_entry_labels_array_offset(&self) -> Option<Nullable<Offset32>> {
166
0
        let range = self.palette_entry_labels_array_offset_byte_range();
167
0
        (!range.is_empty())
168
0
            .then(|| self.offset_data().read_at(range.start).ok())
169
0
            .flatten()
170
0
    }
171
172
    /// Attempt to resolve [`palette_entry_labels_array_offset`][Self::palette_entry_labels_array_offset].
173
0
    pub fn palette_entry_labels_array(&self) -> Option<Result<&'a [BigEndian<NameId>], ReadError>> {
174
0
        let data = self.offset_data();
175
0
        let args = self.num_palette_entries();
176
0
        self.palette_entry_labels_array_offset()
177
0
            .map(|x| x.resolve_with_args(data, args))?
178
0
    }
179
180
0
    pub fn version_byte_range(&self) -> Range<usize> {
181
0
        let start = 0usize;
182
0
        let end = start.saturating_add(u16::RAW_BYTE_LEN);
183
0
        start..end
184
0
    }
185
186
0
    pub fn num_palette_entries_byte_range(&self) -> Range<usize> {
187
0
        let start = self.version_byte_range().end;
188
0
        let end = start.saturating_add(u16::RAW_BYTE_LEN);
189
0
        start..end
190
0
    }
191
192
0
    pub fn num_palettes_byte_range(&self) -> Range<usize> {
193
0
        let start = self.num_palette_entries_byte_range().end;
194
0
        let end = start.saturating_add(u16::RAW_BYTE_LEN);
195
0
        start..end
196
0
    }
197
198
0
    pub fn num_color_records_byte_range(&self) -> Range<usize> {
199
0
        let start = self.num_palettes_byte_range().end;
200
0
        let end = start.saturating_add(u16::RAW_BYTE_LEN);
201
0
        start..end
202
0
    }
203
204
0
    pub fn color_records_array_offset_byte_range(&self) -> Range<usize> {
205
0
        let start = self.num_color_records_byte_range().end;
206
0
        let end = start.saturating_add(Offset32::RAW_BYTE_LEN);
207
0
        start..end
208
0
    }
209
210
0
    pub fn color_record_indices_byte_range(&self) -> Range<usize> {
211
0
        let num_palettes = self.num_palettes();
212
0
        let start = self.color_records_array_offset_byte_range().end;
213
0
        let end = start
214
0
            .saturating_add((transforms::to_usize(num_palettes)).saturating_mul(u16::RAW_BYTE_LEN));
215
0
        start..end
216
0
    }
217
218
0
    pub fn palette_types_array_offset_byte_range(&self) -> Range<usize> {
219
0
        let start = self.color_record_indices_byte_range().end;
220
0
        let end = if self.version().compatible(1u16) {
221
0
            start.saturating_add(Offset32::RAW_BYTE_LEN)
222
        } else {
223
0
            start
224
        };
225
0
        start..end
226
0
    }
227
228
0
    pub fn palette_labels_array_offset_byte_range(&self) -> Range<usize> {
229
0
        let start = self.palette_types_array_offset_byte_range().end;
230
0
        let end = if self.version().compatible(1u16) {
231
0
            start.saturating_add(Offset32::RAW_BYTE_LEN)
232
        } else {
233
0
            start
234
        };
235
0
        start..end
236
0
    }
237
238
0
    pub fn palette_entry_labels_array_offset_byte_range(&self) -> Range<usize> {
239
0
        let start = self.palette_labels_array_offset_byte_range().end;
240
0
        let end = if self.version().compatible(1u16) {
241
0
            start.saturating_add(Offset32::RAW_BYTE_LEN)
242
        } else {
243
0
            start
244
        };
245
0
        start..end
246
0
    }
247
}
248
249
const _: () = assert!(FontData::default_data_long_enough(Cpal::MIN_SIZE));
250
251
impl Default for Cpal<'_> {
252
0
    fn default() -> Self {
253
        Self {
254
0
            data: TableDataRef::new(FontData::default_table_data().as_bytes())
255
0
                .unwrap_or_else(|| unreachable!("the default data covers MIN_SIZE")),
256
        }
257
0
    }
258
}
259
260
/// Flags describing the backgrounds for which a palette is suitable.
261
///
262
/// These flags help applications select a palette for the intended background.
263
/// Both flags may be set when a palette is suitable for both light and dark
264
/// backgrounds. All other bits are reserved and must be zero.
265
///
266
/// Palette type information is optional and is available in CPAL version 1.
267
/// See the [CPAL palette type specification](https://learn.microsoft.com/en-us/typography/opentype/spec/cpal#palette-type-array).
268
#[derive(Clone, Copy, Default, PartialEq, Eq, PartialOrd, Ord, Hash, bytemuck :: AnyBitPattern)]
269
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
270
#[repr(transparent)]
271
pub struct PaletteType {
272
    bits: u32,
273
}
274
275
impl PaletteType {
276
    /// The palette is suitable for displaying text on a light background, such as white.
277
    pub const USABLE_WITH_LIGHT_BACKGROUND: Self = Self { bits: 0x0001 };
278
279
    /// The palette is suitable for displaying text on a dark background, such as black.
280
    pub const USABLE_WITH_DARK_BACKGROUND: Self = Self { bits: 0x0002 };
281
}
282
283
impl PaletteType {
284
    ///  Returns an empty set of flags.
285
    #[inline]
286
0
    pub const fn empty() -> Self {
287
0
        Self { bits: 0 }
288
0
    }
289
290
    /// Returns the set containing all flags.
291
    #[inline]
292
0
    pub const fn all() -> Self {
293
0
        Self {
294
0
            bits: Self::USABLE_WITH_LIGHT_BACKGROUND.bits | Self::USABLE_WITH_DARK_BACKGROUND.bits,
295
0
        }
296
0
    }
297
298
    /// Returns the raw value of the flags currently stored.
299
    #[inline]
300
0
    pub const fn bits(&self) -> u32 {
301
0
        self.bits
302
0
    }
303
304
    /// Convert from underlying bit representation, unless that
305
    /// representation contains bits that do not correspond to a flag.
306
    #[inline]
307
0
    pub const fn from_bits(bits: u32) -> Option<Self> {
308
0
        if (bits & !Self::all().bits()) == 0 {
309
0
            Some(Self { bits })
310
        } else {
311
0
            None
312
        }
313
0
    }
314
315
    /// Convert from underlying bit representation, dropping any bits
316
    /// that do not correspond to flags.
317
    #[inline]
318
0
    pub const fn from_bits_truncate(bits: u32) -> Self {
319
0
        Self {
320
0
            bits: bits & Self::all().bits,
321
0
        }
322
0
    }
323
324
    /// Returns `true` if no flags are currently stored.
325
    #[inline]
326
0
    pub const fn is_empty(&self) -> bool {
327
0
        self.bits() == Self::empty().bits()
328
0
    }
329
330
    /// Returns `true` if there are flags common to both `self` and `other`.
331
    #[inline]
332
0
    pub const fn intersects(&self, other: Self) -> bool {
333
0
        !(Self {
334
0
            bits: self.bits & other.bits,
335
0
        })
336
0
        .is_empty()
337
0
    }
338
339
    /// Returns `true` if all of the flags in `other` are contained within `self`.
340
    #[inline]
341
0
    pub const fn contains(&self, other: Self) -> bool {
342
0
        (self.bits & other.bits) == other.bits
343
0
    }
344
345
    /// Inserts the specified flags in-place.
346
    #[inline]
347
0
    pub fn insert(&mut self, other: Self) {
348
0
        self.bits |= other.bits;
349
0
    }
350
351
    /// Removes the specified flags in-place.
352
    #[inline]
353
0
    pub fn remove(&mut self, other: Self) {
354
0
        self.bits &= !other.bits;
355
0
    }
356
357
    /// Toggles the specified flags in-place.
358
    #[inline]
359
0
    pub fn toggle(&mut self, other: Self) {
360
0
        self.bits ^= other.bits;
361
0
    }
362
363
    /// Returns the intersection between the flags in `self` and
364
    /// `other`.
365
    ///
366
    /// Specifically, the returned set contains only the flags which are
367
    /// present in *both* `self` *and* `other`.
368
    ///
369
    /// This is equivalent to using the `&` operator (e.g.
370
    /// [`ops::BitAnd`]), as in `flags & other`.
371
    ///
372
    /// [`ops::BitAnd`]: https://doc.rust-lang.org/std/ops/trait.BitAnd.html
373
    #[inline]
374
    #[must_use]
375
0
    pub const fn intersection(self, other: Self) -> Self {
376
0
        Self {
377
0
            bits: self.bits & other.bits,
378
0
        }
379
0
    }
380
381
    /// Returns the union of between the flags in `self` and `other`.
382
    ///
383
    /// Specifically, the returned set contains all flags which are
384
    /// present in *either* `self` *or* `other`, including any which are
385
    /// present in both.
386
    ///
387
    /// This is equivalent to using the `|` operator (e.g.
388
    /// [`ops::BitOr`]), as in `flags | other`.
389
    ///
390
    /// [`ops::BitOr`]: https://doc.rust-lang.org/std/ops/trait.BitOr.html
391
    #[inline]
392
    #[must_use]
393
0
    pub const fn union(self, other: Self) -> Self {
394
0
        Self {
395
0
            bits: self.bits | other.bits,
396
0
        }
397
0
    }
398
399
    /// Returns the difference between the flags in `self` and `other`.
400
    ///
401
    /// Specifically, the returned set contains all flags present in
402
    /// `self`, except for the ones present in `other`.
403
    ///
404
    /// It is also conceptually equivalent to the "bit-clear" operation:
405
    /// `flags & !other` (and this syntax is also supported).
406
    ///
407
    /// This is equivalent to using the `-` operator (e.g.
408
    /// [`ops::Sub`]), as in `flags - other`.
409
    ///
410
    /// [`ops::Sub`]: https://doc.rust-lang.org/std/ops/trait.Sub.html
411
    #[inline]
412
    #[must_use]
413
0
    pub const fn difference(self, other: Self) -> Self {
414
0
        Self {
415
0
            bits: self.bits & !other.bits,
416
0
        }
417
0
    }
418
}
419
420
impl std::ops::BitOr for PaletteType {
421
    type Output = Self;
422
423
    /// Returns the union of the two sets of flags.
424
    #[inline]
425
0
    fn bitor(self, other: PaletteType) -> Self {
426
0
        Self {
427
0
            bits: self.bits | other.bits,
428
0
        }
429
0
    }
430
}
431
432
impl std::ops::BitOrAssign for PaletteType {
433
    /// Adds the set of flags.
434
    #[inline]
435
0
    fn bitor_assign(&mut self, other: Self) {
436
0
        self.bits |= other.bits;
437
0
    }
438
}
439
440
impl std::ops::BitXor for PaletteType {
441
    type Output = Self;
442
443
    /// Returns the left flags, but with all the right flags toggled.
444
    #[inline]
445
0
    fn bitxor(self, other: Self) -> Self {
446
0
        Self {
447
0
            bits: self.bits ^ other.bits,
448
0
        }
449
0
    }
450
}
451
452
impl std::ops::BitXorAssign for PaletteType {
453
    /// Toggles the set of flags.
454
    #[inline]
455
0
    fn bitxor_assign(&mut self, other: Self) {
456
0
        self.bits ^= other.bits;
457
0
    }
458
}
459
460
impl std::ops::BitAnd for PaletteType {
461
    type Output = Self;
462
463
    /// Returns the intersection between the two sets of flags.
464
    #[inline]
465
0
    fn bitand(self, other: Self) -> Self {
466
0
        Self {
467
0
            bits: self.bits & other.bits,
468
0
        }
469
0
    }
470
}
471
472
impl std::ops::BitAndAssign for PaletteType {
473
    /// Disables all flags disabled in the set.
474
    #[inline]
475
0
    fn bitand_assign(&mut self, other: Self) {
476
0
        self.bits &= other.bits;
477
0
    }
478
}
479
480
impl std::ops::Sub for PaletteType {
481
    type Output = Self;
482
483
    /// Returns the set difference of the two sets of flags.
484
    #[inline]
485
0
    fn sub(self, other: Self) -> Self {
486
0
        Self {
487
0
            bits: self.bits & !other.bits,
488
0
        }
489
0
    }
490
}
491
492
impl std::ops::SubAssign for PaletteType {
493
    /// Disables all flags enabled in the set.
494
    #[inline]
495
0
    fn sub_assign(&mut self, other: Self) {
496
0
        self.bits &= !other.bits;
497
0
    }
498
}
499
500
impl std::ops::Not for PaletteType {
501
    type Output = Self;
502
503
    /// Returns the complement of this set of flags.
504
    #[inline]
505
0
    fn not(self) -> Self {
506
0
        Self { bits: !self.bits } & Self::all()
507
0
    }
508
}
509
510
impl std::fmt::Debug for PaletteType {
511
0
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
512
0
        let members: &[(&str, Self)] = &[
513
0
            (
514
0
                "USABLE_WITH_LIGHT_BACKGROUND",
515
0
                Self::USABLE_WITH_LIGHT_BACKGROUND,
516
0
            ),
517
0
            (
518
0
                "USABLE_WITH_DARK_BACKGROUND",
519
0
                Self::USABLE_WITH_DARK_BACKGROUND,
520
0
            ),
521
0
        ];
522
0
        let mut first = true;
523
0
        for (name, value) in members {
524
0
            if self.contains(*value) {
525
0
                if !first {
526
0
                    f.write_str(" | ")?;
527
0
                }
528
0
                first = false;
529
0
                f.write_str(name)?;
530
0
            }
531
        }
532
0
        if first {
533
0
            f.write_str("(empty)")?;
534
0
        }
535
0
        Ok(())
536
0
    }
537
}
538
539
impl std::fmt::Binary for PaletteType {
540
0
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
541
0
        std::fmt::Binary::fmt(&self.bits, f)
542
0
    }
543
}
544
545
impl std::fmt::Octal for PaletteType {
546
0
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
547
0
        std::fmt::Octal::fmt(&self.bits, f)
548
0
    }
549
}
550
551
impl std::fmt::LowerHex for PaletteType {
552
0
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
553
0
        std::fmt::LowerHex::fmt(&self.bits, f)
554
0
    }
555
}
556
557
impl std::fmt::UpperHex for PaletteType {
558
0
    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
559
0
        std::fmt::UpperHex::fmt(&self.bits, f)
560
0
    }
561
}
562
563
impl font_types::Scalar for PaletteType {
564
    type Raw = <u32 as font_types::Scalar>::Raw;
565
0
    fn to_raw(self) -> Self::Raw {
566
0
        self.bits().to_raw()
567
0
    }
568
0
    fn from_raw(raw: Self::Raw) -> Self {
569
0
        let t = <u32>::from_raw(raw);
570
0
        Self::from_bits_truncate(t)
571
0
    }
572
}
573
574
/// A palette color stored as four 8-bit components.
575
///
576
/// The RGB components use the non-linear sRGB encoding and are not premultiplied
577
/// by alpha. Alpha represents opacity on a linear scale: 0 is fully transparent
578
/// and 255 is fully opaque.
579
///
580
/// See the [CPAL color record specification](https://learn.microsoft.com/en-us/typography/opentype/spec/cpal#palette-entries-and-color-records).
581
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Copy, bytemuck :: AnyBitPattern)]
582
#[repr(C)]
583
#[repr(packed)]
584
pub struct ColorRecord {
585
    /// Blue component in non-linear sRGB, from 0 to 255.
586
    pub blue: u8,
587
    /// Green component in non-linear sRGB, from 0 to 255.
588
    pub green: u8,
589
    /// Red component in non-linear sRGB, from 0 to 255.
590
    pub red: u8,
591
    /// Opacity, from 0 (fully transparent) to 255 (fully opaque).
592
    ///
593
    /// This may be combined with additional opacity specified by the paint
594
    /// using this color, such as the alpha value in a COLR paint table.
595
    pub alpha: u8,
596
}
597
598
impl ColorRecord {
599
    /// Blue component in non-linear sRGB, from 0 to 255.
600
0
    pub fn blue(&self) -> u8 {
601
0
        self.blue
602
0
    }
603
604
    /// Green component in non-linear sRGB, from 0 to 255.
605
0
    pub fn green(&self) -> u8 {
606
0
        self.green
607
0
    }
608
609
    /// Red component in non-linear sRGB, from 0 to 255.
610
0
    pub fn red(&self) -> u8 {
611
0
        self.red
612
0
    }
613
614
    /// Opacity, from 0 (fully transparent) to 255 (fully opaque).
615
    ///
616
    /// This may be combined with additional opacity specified by the paint
617
    /// using this color, such as the alpha value in a COLR paint table.
618
0
    pub fn alpha(&self) -> u8 {
619
0
        self.alpha
620
0
    }
621
}
622
623
impl FixedSize for ColorRecord {
624
    const RAW_BYTE_LEN: usize =
625
        u8::RAW_BYTE_LEN + u8::RAW_BYTE_LEN + u8::RAW_BYTE_LEN + u8::RAW_BYTE_LEN;
626
}