write_fonts/generated/
generated_colr.rs

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)]
6use crate::codegen_prelude::*;
7
8pub use read_fonts::tables::colr::{CompositeMode, Extend};
9
10/// [COLR (Color)](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#colr-header) table
11#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
12#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
13pub struct Colr {
14    /// Number of BaseGlyph records; may be 0 in a version 1 table.
15    pub num_base_glyph_records: u16,
16    /// Offset to baseGlyphRecords array (may be NULL).
17    pub base_glyph_records: NullableOffsetMarker<Vec<BaseGlyph>, WIDTH_32>,
18    /// Offset to layerRecords array (may be NULL).
19    pub layer_records: NullableOffsetMarker<Vec<Layer>, WIDTH_32>,
20    /// Number of Layer records; may be 0 in a version 1 table.
21    pub num_layer_records: u16,
22    /// Offset to BaseGlyphList table.
23    pub base_glyph_list: NullableOffsetMarker<BaseGlyphList, WIDTH_32>,
24    /// Offset to LayerList table (may be NULL).
25    pub layer_list: NullableOffsetMarker<LayerList, WIDTH_32>,
26    /// Offset to ClipList table (may be NULL).
27    pub clip_list: NullableOffsetMarker<ClipList, WIDTH_32>,
28    /// Offset to DeltaSetIndexMap table (may be NULL).
29    pub var_index_map: NullableOffsetMarker<DeltaSetIndexMap, WIDTH_32>,
30    /// Offset to ItemVariationStore (may be NULL).
31    pub item_variation_store: NullableOffsetMarker<ItemVariationStore, WIDTH_32>,
32}
33
34impl Colr {
35    /// Construct a new `Colr`
36    pub fn new(
37        num_base_glyph_records: u16,
38        base_glyph_records: Option<Vec<BaseGlyph>>,
39        layer_records: Option<Vec<Layer>>,
40        num_layer_records: u16,
41    ) -> Self {
42        Self {
43            num_base_glyph_records,
44            base_glyph_records: base_glyph_records.into(),
45            layer_records: layer_records.into(),
46            num_layer_records,
47            ..Default::default()
48        }
49    }
50}
51
52impl FontWrite for Colr {
53    #[allow(clippy::unnecessary_cast)]
54    fn write_into(&self, writer: &mut TableWriter) {
55        let version = self.compute_version() as u16;
56        version.write_into(writer);
57        self.num_base_glyph_records.write_into(writer);
58        self.base_glyph_records.write_into(writer);
59        self.layer_records.write_into(writer);
60        self.num_layer_records.write_into(writer);
61        version
62            .compatible(1u16)
63            .then(|| self.base_glyph_list.write_into(writer));
64        version
65            .compatible(1u16)
66            .then(|| self.layer_list.write_into(writer));
67        version
68            .compatible(1u16)
69            .then(|| self.clip_list.write_into(writer));
70        version
71            .compatible(1u16)
72            .then(|| self.var_index_map.write_into(writer));
73        version
74            .compatible(1u16)
75            .then(|| self.item_variation_store.write_into(writer));
76    }
77    fn table_type(&self) -> TableType {
78        TableType::TopLevel(Colr::TAG)
79    }
80}
81
82impl Validate for Colr {
83    fn validate_impl(&self, ctx: &mut ValidationCtx) {
84        ctx.in_table("Colr", |ctx| {
85            ctx.in_field("base_glyph_records", |ctx| {
86                self.base_glyph_records.validate_impl(ctx);
87            });
88            ctx.in_field("layer_records", |ctx| {
89                self.layer_records.validate_impl(ctx);
90            });
91            ctx.in_field("base_glyph_list", |ctx| {
92                self.base_glyph_list.validate_impl(ctx);
93            });
94            ctx.in_field("layer_list", |ctx| {
95                self.layer_list.validate_impl(ctx);
96            });
97            ctx.in_field("clip_list", |ctx| {
98                self.clip_list.validate_impl(ctx);
99            });
100            ctx.in_field("var_index_map", |ctx| {
101                self.var_index_map.validate_impl(ctx);
102            });
103            ctx.in_field("item_variation_store", |ctx| {
104                self.item_variation_store.validate_impl(ctx);
105            });
106        })
107    }
108}
109
110impl TopLevelTable for Colr {
111    const TAG: Tag = Tag::new(b"COLR");
112}
113
114impl<'a> FromObjRef<read_fonts::tables::colr::Colr<'a>> for Colr {
115    fn from_obj_ref(obj: &read_fonts::tables::colr::Colr<'a>, _: FontData) -> Self {
116        let offset_data = obj.offset_data();
117        Colr {
118            num_base_glyph_records: obj.num_base_glyph_records(),
119            base_glyph_records: obj.base_glyph_records().to_owned_obj(offset_data),
120            layer_records: obj.layer_records().to_owned_obj(offset_data),
121            num_layer_records: obj.num_layer_records(),
122            base_glyph_list: obj.base_glyph_list().to_owned_table(),
123            layer_list: obj.layer_list().to_owned_table(),
124            clip_list: obj.clip_list().to_owned_table(),
125            var_index_map: obj.var_index_map().to_owned_table(),
126            item_variation_store: obj.item_variation_store().to_owned_table(),
127        }
128    }
129}
130
131#[allow(clippy::needless_lifetimes)]
132impl<'a> FromTableRef<read_fonts::tables::colr::Colr<'a>> for Colr {}
133
134impl<'a> FontRead<'a> for Colr {
135    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
136        <read_fonts::tables::colr::Colr as FontRead>::read(data).map(|x| x.to_owned_table())
137    }
138}
139
140/// [BaseGlyph](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#baseglyph-and-layer-records) record
141#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
142#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
143pub struct BaseGlyph {
144    /// Glyph ID of the base glyph.
145    pub glyph_id: GlyphId16,
146    /// Index (base 0) into the layerRecords array.
147    pub first_layer_index: u16,
148    /// Number of color layers associated with this glyph.
149    pub num_layers: u16,
150}
151
152impl BaseGlyph {
153    /// Construct a new `BaseGlyph`
154    pub fn new(glyph_id: GlyphId16, first_layer_index: u16, num_layers: u16) -> Self {
155        Self {
156            glyph_id,
157            first_layer_index,
158            num_layers,
159        }
160    }
161}
162
163impl FontWrite for BaseGlyph {
164    fn write_into(&self, writer: &mut TableWriter) {
165        self.glyph_id.write_into(writer);
166        self.first_layer_index.write_into(writer);
167        self.num_layers.write_into(writer);
168    }
169    fn table_type(&self) -> TableType {
170        TableType::Named("BaseGlyph")
171    }
172}
173
174impl Validate for BaseGlyph {
175    fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
176}
177
178impl FromObjRef<read_fonts::tables::colr::BaseGlyph> for BaseGlyph {
179    fn from_obj_ref(obj: &read_fonts::tables::colr::BaseGlyph, _: FontData) -> Self {
180        BaseGlyph {
181            glyph_id: obj.glyph_id(),
182            first_layer_index: obj.first_layer_index(),
183            num_layers: obj.num_layers(),
184        }
185    }
186}
187
188/// [Layer](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#baseglyph-and-layer-records) record
189#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
190#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
191pub struct Layer {
192    /// Glyph ID of the glyph used for a given layer.
193    pub glyph_id: GlyphId16,
194    /// Index (base 0) for a palette entry in the CPAL table.
195    pub palette_index: u16,
196}
197
198impl Layer {
199    /// Construct a new `Layer`
200    pub fn new(glyph_id: GlyphId16, palette_index: u16) -> Self {
201        Self {
202            glyph_id,
203            palette_index,
204        }
205    }
206}
207
208impl FontWrite for Layer {
209    fn write_into(&self, writer: &mut TableWriter) {
210        self.glyph_id.write_into(writer);
211        self.palette_index.write_into(writer);
212    }
213    fn table_type(&self) -> TableType {
214        TableType::Named("Layer")
215    }
216}
217
218impl Validate for Layer {
219    fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
220}
221
222impl FromObjRef<read_fonts::tables::colr::Layer> for Layer {
223    fn from_obj_ref(obj: &read_fonts::tables::colr::Layer, _: FontData) -> Self {
224        Layer {
225            glyph_id: obj.glyph_id(),
226            palette_index: obj.palette_index(),
227        }
228    }
229}
230
231/// [BaseGlyphList](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#baseglyphlist-layerlist-and-cliplist) table
232#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
233#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
234pub struct BaseGlyphList {
235    pub num_base_glyph_paint_records: u32,
236    pub base_glyph_paint_records: Vec<BaseGlyphPaint>,
237}
238
239impl BaseGlyphList {
240    /// Construct a new `BaseGlyphList`
241    pub fn new(
242        num_base_glyph_paint_records: u32,
243        base_glyph_paint_records: Vec<BaseGlyphPaint>,
244    ) -> Self {
245        Self {
246            num_base_glyph_paint_records,
247            base_glyph_paint_records,
248        }
249    }
250}
251
252impl FontWrite for BaseGlyphList {
253    fn write_into(&self, writer: &mut TableWriter) {
254        self.num_base_glyph_paint_records.write_into(writer);
255        self.base_glyph_paint_records.write_into(writer);
256    }
257    fn table_type(&self) -> TableType {
258        TableType::Named("BaseGlyphList")
259    }
260}
261
262impl Validate for BaseGlyphList {
263    fn validate_impl(&self, ctx: &mut ValidationCtx) {
264        ctx.in_table("BaseGlyphList", |ctx| {
265            ctx.in_field("base_glyph_paint_records", |ctx| {
266                if self.base_glyph_paint_records.len() > (u32::MAX as usize) {
267                    ctx.report("array exceeds max length");
268                }
269                self.base_glyph_paint_records.validate_impl(ctx);
270            });
271        })
272    }
273}
274
275impl<'a> FromObjRef<read_fonts::tables::colr::BaseGlyphList<'a>> for BaseGlyphList {
276    fn from_obj_ref(obj: &read_fonts::tables::colr::BaseGlyphList<'a>, _: FontData) -> Self {
277        let offset_data = obj.offset_data();
278        BaseGlyphList {
279            num_base_glyph_paint_records: obj.num_base_glyph_paint_records(),
280            base_glyph_paint_records: obj.base_glyph_paint_records().to_owned_obj(offset_data),
281        }
282    }
283}
284
285#[allow(clippy::needless_lifetimes)]
286impl<'a> FromTableRef<read_fonts::tables::colr::BaseGlyphList<'a>> for BaseGlyphList {}
287
288impl<'a> FontRead<'a> for BaseGlyphList {
289    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
290        <read_fonts::tables::colr::BaseGlyphList as FontRead>::read(data)
291            .map(|x| x.to_owned_table())
292    }
293}
294
295/// [BaseGlyphPaint](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#baseglyphlist-layerlist-and-cliplist) record
296#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
297#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
298pub struct BaseGlyphPaint {
299    /// Glyph ID of the base glyph.
300    pub glyph_id: GlyphId16,
301    /// Offset to a Paint table, from the beginning of the [`BaseGlyphList`] table.
302    pub paint: OffsetMarker<Paint, WIDTH_32>,
303}
304
305impl BaseGlyphPaint {
306    /// Construct a new `BaseGlyphPaint`
307    pub fn new(glyph_id: GlyphId16, paint: Paint) -> Self {
308        Self {
309            glyph_id,
310            paint: paint.into(),
311        }
312    }
313}
314
315impl FontWrite for BaseGlyphPaint {
316    fn write_into(&self, writer: &mut TableWriter) {
317        self.glyph_id.write_into(writer);
318        self.paint.write_into(writer);
319    }
320    fn table_type(&self) -> TableType {
321        TableType::Named("BaseGlyphPaint")
322    }
323}
324
325impl Validate for BaseGlyphPaint {
326    fn validate_impl(&self, ctx: &mut ValidationCtx) {
327        ctx.in_table("BaseGlyphPaint", |ctx| {
328            ctx.in_field("paint", |ctx| {
329                self.paint.validate_impl(ctx);
330            });
331        })
332    }
333}
334
335impl FromObjRef<read_fonts::tables::colr::BaseGlyphPaint> for BaseGlyphPaint {
336    fn from_obj_ref(obj: &read_fonts::tables::colr::BaseGlyphPaint, offset_data: FontData) -> Self {
337        BaseGlyphPaint {
338            glyph_id: obj.glyph_id(),
339            paint: obj.paint(offset_data).to_owned_table(),
340        }
341    }
342}
343
344/// [LayerList](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#baseglyphlist-layerlist-and-cliplist) table
345#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
346#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
347pub struct LayerList {
348    pub num_layers: u32,
349    /// Offsets to Paint tables.
350    pub paints: Vec<OffsetMarker<Paint, WIDTH_32>>,
351}
352
353impl LayerList {
354    /// Construct a new `LayerList`
355    pub fn new(num_layers: u32, paints: Vec<Paint>) -> Self {
356        Self {
357            num_layers,
358            paints: paints.into_iter().map(Into::into).collect(),
359        }
360    }
361}
362
363impl FontWrite for LayerList {
364    fn write_into(&self, writer: &mut TableWriter) {
365        self.num_layers.write_into(writer);
366        self.paints.write_into(writer);
367    }
368    fn table_type(&self) -> TableType {
369        TableType::Named("LayerList")
370    }
371}
372
373impl Validate for LayerList {
374    fn validate_impl(&self, ctx: &mut ValidationCtx) {
375        ctx.in_table("LayerList", |ctx| {
376            ctx.in_field("paints", |ctx| {
377                if self.paints.len() > (u32::MAX as usize) {
378                    ctx.report("array exceeds max length");
379                }
380                self.paints.validate_impl(ctx);
381            });
382        })
383    }
384}
385
386impl<'a> FromObjRef<read_fonts::tables::colr::LayerList<'a>> for LayerList {
387    fn from_obj_ref(obj: &read_fonts::tables::colr::LayerList<'a>, _: FontData) -> Self {
388        LayerList {
389            num_layers: obj.num_layers(),
390            paints: obj.paints().to_owned_table(),
391        }
392    }
393}
394
395#[allow(clippy::needless_lifetimes)]
396impl<'a> FromTableRef<read_fonts::tables::colr::LayerList<'a>> for LayerList {}
397
398impl<'a> FontRead<'a> for LayerList {
399    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
400        <read_fonts::tables::colr::LayerList as FontRead>::read(data).map(|x| x.to_owned_table())
401    }
402}
403
404/// [ClipList](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#baseglyphlist-layerlist-and-cliplist) table
405#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
406#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
407pub struct ClipList {
408    /// Set to 1.
409    pub format: u8,
410    /// Number of Clip records.
411    pub num_clips: u32,
412    /// Clip records. Sorted by startGlyphID.
413    pub clips: Vec<Clip>,
414}
415
416impl ClipList {
417    /// Construct a new `ClipList`
418    pub fn new(format: u8, num_clips: u32, clips: Vec<Clip>) -> Self {
419        Self {
420            format,
421            num_clips,
422            clips,
423        }
424    }
425}
426
427impl FontWrite for ClipList {
428    fn write_into(&self, writer: &mut TableWriter) {
429        self.format.write_into(writer);
430        self.num_clips.write_into(writer);
431        self.clips.write_into(writer);
432    }
433    fn table_type(&self) -> TableType {
434        TableType::Named("ClipList")
435    }
436}
437
438impl Validate for ClipList {
439    fn validate_impl(&self, ctx: &mut ValidationCtx) {
440        ctx.in_table("ClipList", |ctx| {
441            ctx.in_field("clips", |ctx| {
442                if self.clips.len() > (u32::MAX as usize) {
443                    ctx.report("array exceeds max length");
444                }
445                self.clips.validate_impl(ctx);
446            });
447        })
448    }
449}
450
451impl<'a> FromObjRef<read_fonts::tables::colr::ClipList<'a>> for ClipList {
452    fn from_obj_ref(obj: &read_fonts::tables::colr::ClipList<'a>, _: FontData) -> Self {
453        let offset_data = obj.offset_data();
454        ClipList {
455            format: obj.format(),
456            num_clips: obj.num_clips(),
457            clips: obj.clips().to_owned_obj(offset_data),
458        }
459    }
460}
461
462#[allow(clippy::needless_lifetimes)]
463impl<'a> FromTableRef<read_fonts::tables::colr::ClipList<'a>> for ClipList {}
464
465impl<'a> FontRead<'a> for ClipList {
466    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
467        <read_fonts::tables::colr::ClipList as FontRead>::read(data).map(|x| x.to_owned_table())
468    }
469}
470
471/// [Clip](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#baseglyphlist-layerlist-and-cliplist) record
472#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
473#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
474pub struct Clip {
475    /// First glyph ID in the range.
476    pub start_glyph_id: GlyphId16,
477    /// Last glyph ID in the range.
478    pub end_glyph_id: GlyphId16,
479    /// Offset to a ClipBox table, from the beginning of the [`ClipList`] table.
480    pub clip_box: OffsetMarker<ClipBox, WIDTH_24>,
481}
482
483impl Clip {
484    /// Construct a new `Clip`
485    pub fn new(start_glyph_id: GlyphId16, end_glyph_id: GlyphId16, clip_box: ClipBox) -> Self {
486        Self {
487            start_glyph_id,
488            end_glyph_id,
489            clip_box: clip_box.into(),
490        }
491    }
492}
493
494impl FontWrite for Clip {
495    fn write_into(&self, writer: &mut TableWriter) {
496        self.start_glyph_id.write_into(writer);
497        self.end_glyph_id.write_into(writer);
498        self.clip_box.write_into(writer);
499    }
500    fn table_type(&self) -> TableType {
501        TableType::Named("Clip")
502    }
503}
504
505impl Validate for Clip {
506    fn validate_impl(&self, ctx: &mut ValidationCtx) {
507        ctx.in_table("Clip", |ctx| {
508            ctx.in_field("clip_box", |ctx| {
509                self.clip_box.validate_impl(ctx);
510            });
511        })
512    }
513}
514
515impl FromObjRef<read_fonts::tables::colr::Clip> for Clip {
516    fn from_obj_ref(obj: &read_fonts::tables::colr::Clip, offset_data: FontData) -> Self {
517        Clip {
518            start_glyph_id: obj.start_glyph_id(),
519            end_glyph_id: obj.end_glyph_id(),
520            clip_box: obj.clip_box(offset_data).to_owned_table(),
521        }
522    }
523}
524
525/// [ClipBox](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#baseglyphlist-layerlist-and-cliplist) table
526#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
527#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
528pub enum ClipBox {
529    Format1(ClipBoxFormat1),
530    Format2(ClipBoxFormat2),
531}
532
533impl ClipBox {
534    /// Construct a new `ClipBoxFormat1` subtable
535    pub fn format_1(x_min: FWord, y_min: FWord, x_max: FWord, y_max: FWord) -> Self {
536        Self::Format1(ClipBoxFormat1::new(x_min, y_min, x_max, y_max))
537    }
538
539    /// Construct a new `ClipBoxFormat2` subtable
540    pub fn format_2(
541        x_min: FWord,
542        y_min: FWord,
543        x_max: FWord,
544        y_max: FWord,
545        var_index_base: u32,
546    ) -> Self {
547        Self::Format2(ClipBoxFormat2::new(
548            x_min,
549            y_min,
550            x_max,
551            y_max,
552            var_index_base,
553        ))
554    }
555}
556
557impl Default for ClipBox {
558    fn default() -> Self {
559        Self::Format1(Default::default())
560    }
561}
562
563impl FontWrite for ClipBox {
564    fn write_into(&self, writer: &mut TableWriter) {
565        match self {
566            Self::Format1(item) => item.write_into(writer),
567            Self::Format2(item) => item.write_into(writer),
568        }
569    }
570    fn table_type(&self) -> TableType {
571        match self {
572            Self::Format1(item) => item.table_type(),
573            Self::Format2(item) => item.table_type(),
574        }
575    }
576}
577
578impl Validate for ClipBox {
579    fn validate_impl(&self, ctx: &mut ValidationCtx) {
580        match self {
581            Self::Format1(item) => item.validate_impl(ctx),
582            Self::Format2(item) => item.validate_impl(ctx),
583        }
584    }
585}
586
587impl FromObjRef<read_fonts::tables::colr::ClipBox<'_>> for ClipBox {
588    fn from_obj_ref(obj: &read_fonts::tables::colr::ClipBox, _: FontData) -> Self {
589        use read_fonts::tables::colr::ClipBox as ObjRefType;
590        match obj {
591            ObjRefType::Format1(item) => ClipBox::Format1(item.to_owned_table()),
592            ObjRefType::Format2(item) => ClipBox::Format2(item.to_owned_table()),
593        }
594    }
595}
596
597impl FromTableRef<read_fonts::tables::colr::ClipBox<'_>> for ClipBox {}
598
599impl<'a> FontRead<'a> for ClipBox {
600    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
601        <read_fonts::tables::colr::ClipBox as FontRead>::read(data).map(|x| x.to_owned_table())
602    }
603}
604
605impl From<ClipBoxFormat1> for ClipBox {
606    fn from(src: ClipBoxFormat1) -> ClipBox {
607        ClipBox::Format1(src)
608    }
609}
610
611impl From<ClipBoxFormat2> for ClipBox {
612    fn from(src: ClipBoxFormat2) -> ClipBox {
613        ClipBox::Format2(src)
614    }
615}
616
617/// [ClipBoxFormat1](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#baseglyphlist-layerlist-and-cliplist) record
618#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
619#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
620pub struct ClipBoxFormat1 {
621    /// Minimum x of clip box.
622    pub x_min: FWord,
623    /// Minimum y of clip box.
624    pub y_min: FWord,
625    /// Maximum x of clip box.
626    pub x_max: FWord,
627    /// Maximum y of clip box.
628    pub y_max: FWord,
629}
630
631impl ClipBoxFormat1 {
632    /// Construct a new `ClipBoxFormat1`
633    pub fn new(x_min: FWord, y_min: FWord, x_max: FWord, y_max: FWord) -> Self {
634        Self {
635            x_min,
636            y_min,
637            x_max,
638            y_max,
639        }
640    }
641}
642
643impl FontWrite for ClipBoxFormat1 {
644    #[allow(clippy::unnecessary_cast)]
645    fn write_into(&self, writer: &mut TableWriter) {
646        (1 as u8).write_into(writer);
647        self.x_min.write_into(writer);
648        self.y_min.write_into(writer);
649        self.x_max.write_into(writer);
650        self.y_max.write_into(writer);
651    }
652    fn table_type(&self) -> TableType {
653        TableType::Named("ClipBoxFormat1")
654    }
655}
656
657impl Validate for ClipBoxFormat1 {
658    fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
659}
660
661impl<'a> FromObjRef<read_fonts::tables::colr::ClipBoxFormat1<'a>> for ClipBoxFormat1 {
662    fn from_obj_ref(obj: &read_fonts::tables::colr::ClipBoxFormat1<'a>, _: FontData) -> Self {
663        ClipBoxFormat1 {
664            x_min: obj.x_min(),
665            y_min: obj.y_min(),
666            x_max: obj.x_max(),
667            y_max: obj.y_max(),
668        }
669    }
670}
671
672#[allow(clippy::needless_lifetimes)]
673impl<'a> FromTableRef<read_fonts::tables::colr::ClipBoxFormat1<'a>> for ClipBoxFormat1 {}
674
675impl<'a> FontRead<'a> for ClipBoxFormat1 {
676    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
677        <read_fonts::tables::colr::ClipBoxFormat1 as FontRead>::read(data)
678            .map(|x| x.to_owned_table())
679    }
680}
681
682/// [ClipBoxFormat2](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#baseglyphlist-layerlist-and-cliplist) record
683#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
684#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
685pub struct ClipBoxFormat2 {
686    /// Minimum x of clip box. For variation, use varIndexBase + 0.
687    pub x_min: FWord,
688    /// Minimum y of clip box. For variation, use varIndexBase + 1.
689    pub y_min: FWord,
690    /// Maximum x of clip box. For variation, use varIndexBase + 2.
691    pub x_max: FWord,
692    /// Maximum y of clip box. For variation, use varIndexBase + 3.
693    pub y_max: FWord,
694    /// Base index into DeltaSetIndexMap.
695    pub var_index_base: u32,
696}
697
698impl ClipBoxFormat2 {
699    /// Construct a new `ClipBoxFormat2`
700    pub fn new(
701        x_min: FWord,
702        y_min: FWord,
703        x_max: FWord,
704        y_max: FWord,
705        var_index_base: u32,
706    ) -> Self {
707        Self {
708            x_min,
709            y_min,
710            x_max,
711            y_max,
712            var_index_base,
713        }
714    }
715}
716
717impl FontWrite for ClipBoxFormat2 {
718    #[allow(clippy::unnecessary_cast)]
719    fn write_into(&self, writer: &mut TableWriter) {
720        (2 as u8).write_into(writer);
721        self.x_min.write_into(writer);
722        self.y_min.write_into(writer);
723        self.x_max.write_into(writer);
724        self.y_max.write_into(writer);
725        self.var_index_base.write_into(writer);
726    }
727    fn table_type(&self) -> TableType {
728        TableType::Named("ClipBoxFormat2")
729    }
730}
731
732impl Validate for ClipBoxFormat2 {
733    fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
734}
735
736impl<'a> FromObjRef<read_fonts::tables::colr::ClipBoxFormat2<'a>> for ClipBoxFormat2 {
737    fn from_obj_ref(obj: &read_fonts::tables::colr::ClipBoxFormat2<'a>, _: FontData) -> Self {
738        ClipBoxFormat2 {
739            x_min: obj.x_min(),
740            y_min: obj.y_min(),
741            x_max: obj.x_max(),
742            y_max: obj.y_max(),
743            var_index_base: obj.var_index_base(),
744        }
745    }
746}
747
748#[allow(clippy::needless_lifetimes)]
749impl<'a> FromTableRef<read_fonts::tables::colr::ClipBoxFormat2<'a>> for ClipBoxFormat2 {}
750
751impl<'a> FontRead<'a> for ClipBoxFormat2 {
752    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
753        <read_fonts::tables::colr::ClipBoxFormat2 as FontRead>::read(data)
754            .map(|x| x.to_owned_table())
755    }
756}
757
758/// [ColorIndex](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#color-references-colorstop-and-colorline) record
759#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
760#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
761pub struct ColorIndex {
762    /// Index for a CPAL palette entry.
763    pub palette_index: u16,
764    /// Alpha value.
765    pub alpha: F2Dot14,
766}
767
768impl ColorIndex {
769    /// Construct a new `ColorIndex`
770    pub fn new(palette_index: u16, alpha: F2Dot14) -> Self {
771        Self {
772            palette_index,
773            alpha,
774        }
775    }
776}
777
778impl FontWrite for ColorIndex {
779    fn write_into(&self, writer: &mut TableWriter) {
780        self.palette_index.write_into(writer);
781        self.alpha.write_into(writer);
782    }
783    fn table_type(&self) -> TableType {
784        TableType::Named("ColorIndex")
785    }
786}
787
788impl Validate for ColorIndex {
789    fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
790}
791
792impl FromObjRef<read_fonts::tables::colr::ColorIndex> for ColorIndex {
793    fn from_obj_ref(obj: &read_fonts::tables::colr::ColorIndex, _: FontData) -> Self {
794        ColorIndex {
795            palette_index: obj.palette_index(),
796            alpha: obj.alpha(),
797        }
798    }
799}
800
801/// [VarColorIndex](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#color-references-colorstop-and-colorline) record
802#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
803#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
804pub struct VarColorIndex {
805    /// Index for a CPAL palette entry.
806    pub palette_index: u16,
807    /// Alpha value. For variation, use varIndexBase + 0.
808    pub alpha: F2Dot14,
809    /// Base index into DeltaSetIndexMap.
810    pub var_index_base: u32,
811}
812
813impl VarColorIndex {
814    /// Construct a new `VarColorIndex`
815    pub fn new(palette_index: u16, alpha: F2Dot14, var_index_base: u32) -> Self {
816        Self {
817            palette_index,
818            alpha,
819            var_index_base,
820        }
821    }
822}
823
824impl FontWrite for VarColorIndex {
825    fn write_into(&self, writer: &mut TableWriter) {
826        self.palette_index.write_into(writer);
827        self.alpha.write_into(writer);
828        self.var_index_base.write_into(writer);
829    }
830    fn table_type(&self) -> TableType {
831        TableType::Named("VarColorIndex")
832    }
833}
834
835impl Validate for VarColorIndex {
836    fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
837}
838
839impl FromObjRef<read_fonts::tables::colr::VarColorIndex> for VarColorIndex {
840    fn from_obj_ref(obj: &read_fonts::tables::colr::VarColorIndex, _: FontData) -> Self {
841        VarColorIndex {
842            palette_index: obj.palette_index(),
843            alpha: obj.alpha(),
844            var_index_base: obj.var_index_base(),
845        }
846    }
847}
848
849/// [ColorStop](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#color-references-colorstop-and-colorline) record
850#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
851#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
852pub struct ColorStop {
853    /// Position on a color line.
854    pub stop_offset: F2Dot14,
855    /// Index for a CPAL palette entry.
856    pub palette_index: u16,
857    /// Alpha value.
858    pub alpha: F2Dot14,
859}
860
861impl ColorStop {
862    /// Construct a new `ColorStop`
863    pub fn new(stop_offset: F2Dot14, palette_index: u16, alpha: F2Dot14) -> Self {
864        Self {
865            stop_offset,
866            palette_index,
867            alpha,
868        }
869    }
870}
871
872impl FontWrite for ColorStop {
873    fn write_into(&self, writer: &mut TableWriter) {
874        self.stop_offset.write_into(writer);
875        self.palette_index.write_into(writer);
876        self.alpha.write_into(writer);
877    }
878    fn table_type(&self) -> TableType {
879        TableType::Named("ColorStop")
880    }
881}
882
883impl Validate for ColorStop {
884    fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
885}
886
887impl FromObjRef<read_fonts::tables::colr::ColorStop> for ColorStop {
888    fn from_obj_ref(obj: &read_fonts::tables::colr::ColorStop, _: FontData) -> Self {
889        ColorStop {
890            stop_offset: obj.stop_offset(),
891            palette_index: obj.palette_index(),
892            alpha: obj.alpha(),
893        }
894    }
895}
896
897/// [VarColorStop](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#color-references-colorstop-and-colorline) record
898#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
899#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
900pub struct VarColorStop {
901    /// Position on a color line. For variation, use varIndexBase + 0.
902    pub stop_offset: F2Dot14,
903    /// Index for a CPAL palette entry.
904    pub palette_index: u16,
905    /// Alpha value. For variation, use varIndexBase + 1.
906    pub alpha: F2Dot14,
907    /// Base index into DeltaSetIndexMap.
908    pub var_index_base: u32,
909}
910
911impl VarColorStop {
912    /// Construct a new `VarColorStop`
913    pub fn new(
914        stop_offset: F2Dot14,
915        palette_index: u16,
916        alpha: F2Dot14,
917        var_index_base: u32,
918    ) -> Self {
919        Self {
920            stop_offset,
921            palette_index,
922            alpha,
923            var_index_base,
924        }
925    }
926}
927
928impl FontWrite for VarColorStop {
929    fn write_into(&self, writer: &mut TableWriter) {
930        self.stop_offset.write_into(writer);
931        self.palette_index.write_into(writer);
932        self.alpha.write_into(writer);
933        self.var_index_base.write_into(writer);
934    }
935    fn table_type(&self) -> TableType {
936        TableType::Named("VarColorStop")
937    }
938}
939
940impl Validate for VarColorStop {
941    fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
942}
943
944impl FromObjRef<read_fonts::tables::colr::VarColorStop> for VarColorStop {
945    fn from_obj_ref(obj: &read_fonts::tables::colr::VarColorStop, _: FontData) -> Self {
946        VarColorStop {
947            stop_offset: obj.stop_offset(),
948            palette_index: obj.palette_index(),
949            alpha: obj.alpha(),
950            var_index_base: obj.var_index_base(),
951        }
952    }
953}
954
955/// [ColorLine](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#color-references-colorstop-and-colorline) table
956#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
957#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
958pub struct ColorLine {
959    /// An Extend enum value.
960    pub extend: Extend,
961    /// Number of ColorStop records.
962    pub num_stops: u16,
963    pub color_stops: Vec<ColorStop>,
964}
965
966impl ColorLine {
967    /// Construct a new `ColorLine`
968    pub fn new(extend: Extend, num_stops: u16, color_stops: Vec<ColorStop>) -> Self {
969        Self {
970            extend,
971            num_stops,
972            color_stops,
973        }
974    }
975}
976
977impl FontWrite for ColorLine {
978    fn write_into(&self, writer: &mut TableWriter) {
979        self.extend.write_into(writer);
980        self.num_stops.write_into(writer);
981        self.color_stops.write_into(writer);
982    }
983    fn table_type(&self) -> TableType {
984        TableType::Named("ColorLine")
985    }
986}
987
988impl Validate for ColorLine {
989    fn validate_impl(&self, ctx: &mut ValidationCtx) {
990        ctx.in_table("ColorLine", |ctx| {
991            ctx.in_field("color_stops", |ctx| {
992                if self.color_stops.len() > (u16::MAX as usize) {
993                    ctx.report("array exceeds max length");
994                }
995                self.color_stops.validate_impl(ctx);
996            });
997        })
998    }
999}
1000
1001impl<'a> FromObjRef<read_fonts::tables::colr::ColorLine<'a>> for ColorLine {
1002    fn from_obj_ref(obj: &read_fonts::tables::colr::ColorLine<'a>, _: FontData) -> Self {
1003        let offset_data = obj.offset_data();
1004        ColorLine {
1005            extend: obj.extend(),
1006            num_stops: obj.num_stops(),
1007            color_stops: obj.color_stops().to_owned_obj(offset_data),
1008        }
1009    }
1010}
1011
1012#[allow(clippy::needless_lifetimes)]
1013impl<'a> FromTableRef<read_fonts::tables::colr::ColorLine<'a>> for ColorLine {}
1014
1015impl<'a> FontRead<'a> for ColorLine {
1016    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
1017        <read_fonts::tables::colr::ColorLine as FontRead>::read(data).map(|x| x.to_owned_table())
1018    }
1019}
1020
1021/// [VarColorLine](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#color-references-colorstop-and-colorline) table
1022#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
1023#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1024pub struct VarColorLine {
1025    /// An Extend enum value.
1026    pub extend: Extend,
1027    /// Number of ColorStop records.
1028    pub num_stops: u16,
1029    /// Allows for variations.
1030    pub color_stops: Vec<VarColorStop>,
1031}
1032
1033impl VarColorLine {
1034    /// Construct a new `VarColorLine`
1035    pub fn new(extend: Extend, num_stops: u16, color_stops: Vec<VarColorStop>) -> Self {
1036        Self {
1037            extend,
1038            num_stops,
1039            color_stops,
1040        }
1041    }
1042}
1043
1044impl FontWrite for VarColorLine {
1045    fn write_into(&self, writer: &mut TableWriter) {
1046        self.extend.write_into(writer);
1047        self.num_stops.write_into(writer);
1048        self.color_stops.write_into(writer);
1049    }
1050    fn table_type(&self) -> TableType {
1051        TableType::Named("VarColorLine")
1052    }
1053}
1054
1055impl Validate for VarColorLine {
1056    fn validate_impl(&self, ctx: &mut ValidationCtx) {
1057        ctx.in_table("VarColorLine", |ctx| {
1058            ctx.in_field("color_stops", |ctx| {
1059                if self.color_stops.len() > (u16::MAX as usize) {
1060                    ctx.report("array exceeds max length");
1061                }
1062                self.color_stops.validate_impl(ctx);
1063            });
1064        })
1065    }
1066}
1067
1068impl<'a> FromObjRef<read_fonts::tables::colr::VarColorLine<'a>> for VarColorLine {
1069    fn from_obj_ref(obj: &read_fonts::tables::colr::VarColorLine<'a>, _: FontData) -> Self {
1070        let offset_data = obj.offset_data();
1071        VarColorLine {
1072            extend: obj.extend(),
1073            num_stops: obj.num_stops(),
1074            color_stops: obj.color_stops().to_owned_obj(offset_data),
1075        }
1076    }
1077}
1078
1079#[allow(clippy::needless_lifetimes)]
1080impl<'a> FromTableRef<read_fonts::tables::colr::VarColorLine<'a>> for VarColorLine {}
1081
1082impl<'a> FontRead<'a> for VarColorLine {
1083    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
1084        <read_fonts::tables::colr::VarColorLine as FontRead>::read(data).map(|x| x.to_owned_table())
1085    }
1086}
1087
1088impl FontWrite for Extend {
1089    fn write_into(&self, writer: &mut TableWriter) {
1090        let val = *self as u8;
1091        writer.write_slice(&val.to_be_bytes())
1092    }
1093}
1094
1095/// [Paint](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#paint-tables) tables
1096#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
1097#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1098pub enum Paint {
1099    ColrLayers(PaintColrLayers),
1100    Solid(PaintSolid),
1101    VarSolid(PaintVarSolid),
1102    LinearGradient(PaintLinearGradient),
1103    VarLinearGradient(PaintVarLinearGradient),
1104    RadialGradient(PaintRadialGradient),
1105    VarRadialGradient(PaintVarRadialGradient),
1106    SweepGradient(PaintSweepGradient),
1107    VarSweepGradient(PaintVarSweepGradient),
1108    Glyph(PaintGlyph),
1109    ColrGlyph(PaintColrGlyph),
1110    Transform(PaintTransform),
1111    VarTransform(PaintVarTransform),
1112    Translate(PaintTranslate),
1113    VarTranslate(PaintVarTranslate),
1114    Scale(PaintScale),
1115    VarScale(PaintVarScale),
1116    ScaleAroundCenter(PaintScaleAroundCenter),
1117    VarScaleAroundCenter(PaintVarScaleAroundCenter),
1118    ScaleUniform(PaintScaleUniform),
1119    VarScaleUniform(PaintVarScaleUniform),
1120    ScaleUniformAroundCenter(PaintScaleUniformAroundCenter),
1121    VarScaleUniformAroundCenter(PaintVarScaleUniformAroundCenter),
1122    Rotate(PaintRotate),
1123    VarRotate(PaintVarRotate),
1124    RotateAroundCenter(PaintRotateAroundCenter),
1125    VarRotateAroundCenter(PaintVarRotateAroundCenter),
1126    Skew(PaintSkew),
1127    VarSkew(PaintVarSkew),
1128    SkewAroundCenter(PaintSkewAroundCenter),
1129    VarSkewAroundCenter(PaintVarSkewAroundCenter),
1130    Composite(PaintComposite),
1131}
1132
1133impl Paint {
1134    /// Construct a new `PaintColrLayers` subtable
1135    pub fn colr_layers(num_layers: u8, first_layer_index: u32) -> Self {
1136        Self::ColrLayers(PaintColrLayers::new(num_layers, first_layer_index))
1137    }
1138
1139    /// Construct a new `PaintSolid` subtable
1140    pub fn solid(palette_index: u16, alpha: F2Dot14) -> Self {
1141        Self::Solid(PaintSolid::new(palette_index, alpha))
1142    }
1143
1144    /// Construct a new `PaintVarSolid` subtable
1145    pub fn var_solid(palette_index: u16, alpha: F2Dot14, var_index_base: u32) -> Self {
1146        Self::VarSolid(PaintVarSolid::new(palette_index, alpha, var_index_base))
1147    }
1148
1149    /// Construct a new `PaintLinearGradient` subtable
1150    pub fn linear_gradient(
1151        color_line: ColorLine,
1152        x0: FWord,
1153        y0: FWord,
1154        x1: FWord,
1155        y1: FWord,
1156        x2: FWord,
1157        y2: FWord,
1158    ) -> Self {
1159        Self::LinearGradient(PaintLinearGradient::new(color_line, x0, y0, x1, y1, x2, y2))
1160    }
1161
1162    /// Construct a new `PaintVarLinearGradient` subtable
1163    #[allow(clippy::too_many_arguments)]
1164    pub fn var_linear_gradient(
1165        color_line: VarColorLine,
1166        x0: FWord,
1167        y0: FWord,
1168        x1: FWord,
1169        y1: FWord,
1170        x2: FWord,
1171        y2: FWord,
1172        var_index_base: u32,
1173    ) -> Self {
1174        Self::VarLinearGradient(PaintVarLinearGradient::new(
1175            color_line,
1176            x0,
1177            y0,
1178            x1,
1179            y1,
1180            x2,
1181            y2,
1182            var_index_base,
1183        ))
1184    }
1185
1186    /// Construct a new `PaintRadialGradient` subtable
1187    pub fn radial_gradient(
1188        color_line: ColorLine,
1189        x0: FWord,
1190        y0: FWord,
1191        radius0: UfWord,
1192        x1: FWord,
1193        y1: FWord,
1194        radius1: UfWord,
1195    ) -> Self {
1196        Self::RadialGradient(PaintRadialGradient::new(
1197            color_line, x0, y0, radius0, x1, y1, radius1,
1198        ))
1199    }
1200
1201    /// Construct a new `PaintVarRadialGradient` subtable
1202    #[allow(clippy::too_many_arguments)]
1203    pub fn var_radial_gradient(
1204        color_line: VarColorLine,
1205        x0: FWord,
1206        y0: FWord,
1207        radius0: UfWord,
1208        x1: FWord,
1209        y1: FWord,
1210        radius1: UfWord,
1211        var_index_base: u32,
1212    ) -> Self {
1213        Self::VarRadialGradient(PaintVarRadialGradient::new(
1214            color_line,
1215            x0,
1216            y0,
1217            radius0,
1218            x1,
1219            y1,
1220            radius1,
1221            var_index_base,
1222        ))
1223    }
1224
1225    /// Construct a new `PaintSweepGradient` subtable
1226    pub fn sweep_gradient(
1227        color_line: ColorLine,
1228        center_x: FWord,
1229        center_y: FWord,
1230        start_angle: F2Dot14,
1231        end_angle: F2Dot14,
1232    ) -> Self {
1233        Self::SweepGradient(PaintSweepGradient::new(
1234            color_line,
1235            center_x,
1236            center_y,
1237            start_angle,
1238            end_angle,
1239        ))
1240    }
1241
1242    /// Construct a new `PaintVarSweepGradient` subtable
1243    pub fn var_sweep_gradient(
1244        color_line: VarColorLine,
1245        center_x: FWord,
1246        center_y: FWord,
1247        start_angle: F2Dot14,
1248        end_angle: F2Dot14,
1249        var_index_base: u32,
1250    ) -> Self {
1251        Self::VarSweepGradient(PaintVarSweepGradient::new(
1252            color_line,
1253            center_x,
1254            center_y,
1255            start_angle,
1256            end_angle,
1257            var_index_base,
1258        ))
1259    }
1260
1261    /// Construct a new `PaintGlyph` subtable
1262    pub fn glyph(paint: Paint, glyph_id: GlyphId16) -> Self {
1263        Self::Glyph(PaintGlyph::new(paint, glyph_id))
1264    }
1265
1266    /// Construct a new `PaintColrGlyph` subtable
1267    pub fn colr_glyph(glyph_id: GlyphId16) -> Self {
1268        Self::ColrGlyph(PaintColrGlyph::new(glyph_id))
1269    }
1270
1271    /// Construct a new `PaintTransform` subtable
1272    pub fn transform(paint: Paint, transform: Affine2x3) -> Self {
1273        Self::Transform(PaintTransform::new(paint, transform))
1274    }
1275
1276    /// Construct a new `PaintVarTransform` subtable
1277    pub fn var_transform(paint: Paint, transform: VarAffine2x3) -> Self {
1278        Self::VarTransform(PaintVarTransform::new(paint, transform))
1279    }
1280
1281    /// Construct a new `PaintTranslate` subtable
1282    pub fn translate(paint: Paint, dx: FWord, dy: FWord) -> Self {
1283        Self::Translate(PaintTranslate::new(paint, dx, dy))
1284    }
1285
1286    /// Construct a new `PaintVarTranslate` subtable
1287    pub fn var_translate(paint: Paint, dx: FWord, dy: FWord, var_index_base: u32) -> Self {
1288        Self::VarTranslate(PaintVarTranslate::new(paint, dx, dy, var_index_base))
1289    }
1290
1291    /// Construct a new `PaintScale` subtable
1292    pub fn scale(paint: Paint, scale_x: F2Dot14, scale_y: F2Dot14) -> Self {
1293        Self::Scale(PaintScale::new(paint, scale_x, scale_y))
1294    }
1295
1296    /// Construct a new `PaintVarScale` subtable
1297    pub fn var_scale(
1298        paint: Paint,
1299        scale_x: F2Dot14,
1300        scale_y: F2Dot14,
1301        var_index_base: u32,
1302    ) -> Self {
1303        Self::VarScale(PaintVarScale::new(paint, scale_x, scale_y, var_index_base))
1304    }
1305
1306    /// Construct a new `PaintScaleAroundCenter` subtable
1307    pub fn scale_around_center(
1308        paint: Paint,
1309        scale_x: F2Dot14,
1310        scale_y: F2Dot14,
1311        center_x: FWord,
1312        center_y: FWord,
1313    ) -> Self {
1314        Self::ScaleAroundCenter(PaintScaleAroundCenter::new(
1315            paint, scale_x, scale_y, center_x, center_y,
1316        ))
1317    }
1318
1319    /// Construct a new `PaintVarScaleAroundCenter` subtable
1320    pub fn var_scale_around_center(
1321        paint: Paint,
1322        scale_x: F2Dot14,
1323        scale_y: F2Dot14,
1324        center_x: FWord,
1325        center_y: FWord,
1326        var_index_base: u32,
1327    ) -> Self {
1328        Self::VarScaleAroundCenter(PaintVarScaleAroundCenter::new(
1329            paint,
1330            scale_x,
1331            scale_y,
1332            center_x,
1333            center_y,
1334            var_index_base,
1335        ))
1336    }
1337
1338    /// Construct a new `PaintScaleUniform` subtable
1339    pub fn scale_uniform(paint: Paint, scale: F2Dot14) -> Self {
1340        Self::ScaleUniform(PaintScaleUniform::new(paint, scale))
1341    }
1342
1343    /// Construct a new `PaintVarScaleUniform` subtable
1344    pub fn var_scale_uniform(paint: Paint, scale: F2Dot14, var_index_base: u32) -> Self {
1345        Self::VarScaleUniform(PaintVarScaleUniform::new(paint, scale, var_index_base))
1346    }
1347
1348    /// Construct a new `PaintScaleUniformAroundCenter` subtable
1349    pub fn scale_uniform_around_center(
1350        paint: Paint,
1351        scale: F2Dot14,
1352        center_x: FWord,
1353        center_y: FWord,
1354    ) -> Self {
1355        Self::ScaleUniformAroundCenter(PaintScaleUniformAroundCenter::new(
1356            paint, scale, center_x, center_y,
1357        ))
1358    }
1359
1360    /// Construct a new `PaintVarScaleUniformAroundCenter` subtable
1361    pub fn var_scale_uniform_around_center(
1362        paint: Paint,
1363        scale: F2Dot14,
1364        center_x: FWord,
1365        center_y: FWord,
1366        var_index_base: u32,
1367    ) -> Self {
1368        Self::VarScaleUniformAroundCenter(PaintVarScaleUniformAroundCenter::new(
1369            paint,
1370            scale,
1371            center_x,
1372            center_y,
1373            var_index_base,
1374        ))
1375    }
1376
1377    /// Construct a new `PaintRotate` subtable
1378    pub fn rotate(paint: Paint, angle: F2Dot14) -> Self {
1379        Self::Rotate(PaintRotate::new(paint, angle))
1380    }
1381
1382    /// Construct a new `PaintVarRotate` subtable
1383    pub fn var_rotate(paint: Paint, angle: F2Dot14, var_index_base: u32) -> Self {
1384        Self::VarRotate(PaintVarRotate::new(paint, angle, var_index_base))
1385    }
1386
1387    /// Construct a new `PaintRotateAroundCenter` subtable
1388    pub fn rotate_around_center(
1389        paint: Paint,
1390        angle: F2Dot14,
1391        center_x: FWord,
1392        center_y: FWord,
1393    ) -> Self {
1394        Self::RotateAroundCenter(PaintRotateAroundCenter::new(
1395            paint, angle, center_x, center_y,
1396        ))
1397    }
1398
1399    /// Construct a new `PaintVarRotateAroundCenter` subtable
1400    pub fn var_rotate_around_center(
1401        paint: Paint,
1402        angle: F2Dot14,
1403        center_x: FWord,
1404        center_y: FWord,
1405        var_index_base: u32,
1406    ) -> Self {
1407        Self::VarRotateAroundCenter(PaintVarRotateAroundCenter::new(
1408            paint,
1409            angle,
1410            center_x,
1411            center_y,
1412            var_index_base,
1413        ))
1414    }
1415
1416    /// Construct a new `PaintSkew` subtable
1417    pub fn skew(paint: Paint, x_skew_angle: F2Dot14, y_skew_angle: F2Dot14) -> Self {
1418        Self::Skew(PaintSkew::new(paint, x_skew_angle, y_skew_angle))
1419    }
1420
1421    /// Construct a new `PaintVarSkew` subtable
1422    pub fn var_skew(
1423        paint: Paint,
1424        x_skew_angle: F2Dot14,
1425        y_skew_angle: F2Dot14,
1426        var_index_base: u32,
1427    ) -> Self {
1428        Self::VarSkew(PaintVarSkew::new(
1429            paint,
1430            x_skew_angle,
1431            y_skew_angle,
1432            var_index_base,
1433        ))
1434    }
1435
1436    /// Construct a new `PaintSkewAroundCenter` subtable
1437    pub fn skew_around_center(
1438        paint: Paint,
1439        x_skew_angle: F2Dot14,
1440        y_skew_angle: F2Dot14,
1441        center_x: FWord,
1442        center_y: FWord,
1443    ) -> Self {
1444        Self::SkewAroundCenter(PaintSkewAroundCenter::new(
1445            paint,
1446            x_skew_angle,
1447            y_skew_angle,
1448            center_x,
1449            center_y,
1450        ))
1451    }
1452
1453    /// Construct a new `PaintVarSkewAroundCenter` subtable
1454    pub fn var_skew_around_center(
1455        paint: Paint,
1456        x_skew_angle: F2Dot14,
1457        y_skew_angle: F2Dot14,
1458        center_x: FWord,
1459        center_y: FWord,
1460        var_index_base: u32,
1461    ) -> Self {
1462        Self::VarSkewAroundCenter(PaintVarSkewAroundCenter::new(
1463            paint,
1464            x_skew_angle,
1465            y_skew_angle,
1466            center_x,
1467            center_y,
1468            var_index_base,
1469        ))
1470    }
1471
1472    /// Construct a new `PaintComposite` subtable
1473    pub fn composite(
1474        source_paint: Paint,
1475        composite_mode: CompositeMode,
1476        backdrop_paint: Paint,
1477    ) -> Self {
1478        Self::Composite(PaintComposite::new(
1479            source_paint,
1480            composite_mode,
1481            backdrop_paint,
1482        ))
1483    }
1484}
1485
1486impl Default for Paint {
1487    fn default() -> Self {
1488        Self::ColrLayers(Default::default())
1489    }
1490}
1491
1492impl FontWrite for Paint {
1493    fn write_into(&self, writer: &mut TableWriter) {
1494        match self {
1495            Self::ColrLayers(item) => item.write_into(writer),
1496            Self::Solid(item) => item.write_into(writer),
1497            Self::VarSolid(item) => item.write_into(writer),
1498            Self::LinearGradient(item) => item.write_into(writer),
1499            Self::VarLinearGradient(item) => item.write_into(writer),
1500            Self::RadialGradient(item) => item.write_into(writer),
1501            Self::VarRadialGradient(item) => item.write_into(writer),
1502            Self::SweepGradient(item) => item.write_into(writer),
1503            Self::VarSweepGradient(item) => item.write_into(writer),
1504            Self::Glyph(item) => item.write_into(writer),
1505            Self::ColrGlyph(item) => item.write_into(writer),
1506            Self::Transform(item) => item.write_into(writer),
1507            Self::VarTransform(item) => item.write_into(writer),
1508            Self::Translate(item) => item.write_into(writer),
1509            Self::VarTranslate(item) => item.write_into(writer),
1510            Self::Scale(item) => item.write_into(writer),
1511            Self::VarScale(item) => item.write_into(writer),
1512            Self::ScaleAroundCenter(item) => item.write_into(writer),
1513            Self::VarScaleAroundCenter(item) => item.write_into(writer),
1514            Self::ScaleUniform(item) => item.write_into(writer),
1515            Self::VarScaleUniform(item) => item.write_into(writer),
1516            Self::ScaleUniformAroundCenter(item) => item.write_into(writer),
1517            Self::VarScaleUniformAroundCenter(item) => item.write_into(writer),
1518            Self::Rotate(item) => item.write_into(writer),
1519            Self::VarRotate(item) => item.write_into(writer),
1520            Self::RotateAroundCenter(item) => item.write_into(writer),
1521            Self::VarRotateAroundCenter(item) => item.write_into(writer),
1522            Self::Skew(item) => item.write_into(writer),
1523            Self::VarSkew(item) => item.write_into(writer),
1524            Self::SkewAroundCenter(item) => item.write_into(writer),
1525            Self::VarSkewAroundCenter(item) => item.write_into(writer),
1526            Self::Composite(item) => item.write_into(writer),
1527        }
1528    }
1529    fn table_type(&self) -> TableType {
1530        match self {
1531            Self::ColrLayers(item) => item.table_type(),
1532            Self::Solid(item) => item.table_type(),
1533            Self::VarSolid(item) => item.table_type(),
1534            Self::LinearGradient(item) => item.table_type(),
1535            Self::VarLinearGradient(item) => item.table_type(),
1536            Self::RadialGradient(item) => item.table_type(),
1537            Self::VarRadialGradient(item) => item.table_type(),
1538            Self::SweepGradient(item) => item.table_type(),
1539            Self::VarSweepGradient(item) => item.table_type(),
1540            Self::Glyph(item) => item.table_type(),
1541            Self::ColrGlyph(item) => item.table_type(),
1542            Self::Transform(item) => item.table_type(),
1543            Self::VarTransform(item) => item.table_type(),
1544            Self::Translate(item) => item.table_type(),
1545            Self::VarTranslate(item) => item.table_type(),
1546            Self::Scale(item) => item.table_type(),
1547            Self::VarScale(item) => item.table_type(),
1548            Self::ScaleAroundCenter(item) => item.table_type(),
1549            Self::VarScaleAroundCenter(item) => item.table_type(),
1550            Self::ScaleUniform(item) => item.table_type(),
1551            Self::VarScaleUniform(item) => item.table_type(),
1552            Self::ScaleUniformAroundCenter(item) => item.table_type(),
1553            Self::VarScaleUniformAroundCenter(item) => item.table_type(),
1554            Self::Rotate(item) => item.table_type(),
1555            Self::VarRotate(item) => item.table_type(),
1556            Self::RotateAroundCenter(item) => item.table_type(),
1557            Self::VarRotateAroundCenter(item) => item.table_type(),
1558            Self::Skew(item) => item.table_type(),
1559            Self::VarSkew(item) => item.table_type(),
1560            Self::SkewAroundCenter(item) => item.table_type(),
1561            Self::VarSkewAroundCenter(item) => item.table_type(),
1562            Self::Composite(item) => item.table_type(),
1563        }
1564    }
1565}
1566
1567impl Validate for Paint {
1568    fn validate_impl(&self, ctx: &mut ValidationCtx) {
1569        match self {
1570            Self::ColrLayers(item) => item.validate_impl(ctx),
1571            Self::Solid(item) => item.validate_impl(ctx),
1572            Self::VarSolid(item) => item.validate_impl(ctx),
1573            Self::LinearGradient(item) => item.validate_impl(ctx),
1574            Self::VarLinearGradient(item) => item.validate_impl(ctx),
1575            Self::RadialGradient(item) => item.validate_impl(ctx),
1576            Self::VarRadialGradient(item) => item.validate_impl(ctx),
1577            Self::SweepGradient(item) => item.validate_impl(ctx),
1578            Self::VarSweepGradient(item) => item.validate_impl(ctx),
1579            Self::Glyph(item) => item.validate_impl(ctx),
1580            Self::ColrGlyph(item) => item.validate_impl(ctx),
1581            Self::Transform(item) => item.validate_impl(ctx),
1582            Self::VarTransform(item) => item.validate_impl(ctx),
1583            Self::Translate(item) => item.validate_impl(ctx),
1584            Self::VarTranslate(item) => item.validate_impl(ctx),
1585            Self::Scale(item) => item.validate_impl(ctx),
1586            Self::VarScale(item) => item.validate_impl(ctx),
1587            Self::ScaleAroundCenter(item) => item.validate_impl(ctx),
1588            Self::VarScaleAroundCenter(item) => item.validate_impl(ctx),
1589            Self::ScaleUniform(item) => item.validate_impl(ctx),
1590            Self::VarScaleUniform(item) => item.validate_impl(ctx),
1591            Self::ScaleUniformAroundCenter(item) => item.validate_impl(ctx),
1592            Self::VarScaleUniformAroundCenter(item) => item.validate_impl(ctx),
1593            Self::Rotate(item) => item.validate_impl(ctx),
1594            Self::VarRotate(item) => item.validate_impl(ctx),
1595            Self::RotateAroundCenter(item) => item.validate_impl(ctx),
1596            Self::VarRotateAroundCenter(item) => item.validate_impl(ctx),
1597            Self::Skew(item) => item.validate_impl(ctx),
1598            Self::VarSkew(item) => item.validate_impl(ctx),
1599            Self::SkewAroundCenter(item) => item.validate_impl(ctx),
1600            Self::VarSkewAroundCenter(item) => item.validate_impl(ctx),
1601            Self::Composite(item) => item.validate_impl(ctx),
1602        }
1603    }
1604}
1605
1606impl FromObjRef<read_fonts::tables::colr::Paint<'_>> for Paint {
1607    fn from_obj_ref(obj: &read_fonts::tables::colr::Paint, _: FontData) -> Self {
1608        use read_fonts::tables::colr::Paint as ObjRefType;
1609        match obj {
1610            ObjRefType::ColrLayers(item) => Paint::ColrLayers(item.to_owned_table()),
1611            ObjRefType::Solid(item) => Paint::Solid(item.to_owned_table()),
1612            ObjRefType::VarSolid(item) => Paint::VarSolid(item.to_owned_table()),
1613            ObjRefType::LinearGradient(item) => Paint::LinearGradient(item.to_owned_table()),
1614            ObjRefType::VarLinearGradient(item) => Paint::VarLinearGradient(item.to_owned_table()),
1615            ObjRefType::RadialGradient(item) => Paint::RadialGradient(item.to_owned_table()),
1616            ObjRefType::VarRadialGradient(item) => Paint::VarRadialGradient(item.to_owned_table()),
1617            ObjRefType::SweepGradient(item) => Paint::SweepGradient(item.to_owned_table()),
1618            ObjRefType::VarSweepGradient(item) => Paint::VarSweepGradient(item.to_owned_table()),
1619            ObjRefType::Glyph(item) => Paint::Glyph(item.to_owned_table()),
1620            ObjRefType::ColrGlyph(item) => Paint::ColrGlyph(item.to_owned_table()),
1621            ObjRefType::Transform(item) => Paint::Transform(item.to_owned_table()),
1622            ObjRefType::VarTransform(item) => Paint::VarTransform(item.to_owned_table()),
1623            ObjRefType::Translate(item) => Paint::Translate(item.to_owned_table()),
1624            ObjRefType::VarTranslate(item) => Paint::VarTranslate(item.to_owned_table()),
1625            ObjRefType::Scale(item) => Paint::Scale(item.to_owned_table()),
1626            ObjRefType::VarScale(item) => Paint::VarScale(item.to_owned_table()),
1627            ObjRefType::ScaleAroundCenter(item) => Paint::ScaleAroundCenter(item.to_owned_table()),
1628            ObjRefType::VarScaleAroundCenter(item) => {
1629                Paint::VarScaleAroundCenter(item.to_owned_table())
1630            }
1631            ObjRefType::ScaleUniform(item) => Paint::ScaleUniform(item.to_owned_table()),
1632            ObjRefType::VarScaleUniform(item) => Paint::VarScaleUniform(item.to_owned_table()),
1633            ObjRefType::ScaleUniformAroundCenter(item) => {
1634                Paint::ScaleUniformAroundCenter(item.to_owned_table())
1635            }
1636            ObjRefType::VarScaleUniformAroundCenter(item) => {
1637                Paint::VarScaleUniformAroundCenter(item.to_owned_table())
1638            }
1639            ObjRefType::Rotate(item) => Paint::Rotate(item.to_owned_table()),
1640            ObjRefType::VarRotate(item) => Paint::VarRotate(item.to_owned_table()),
1641            ObjRefType::RotateAroundCenter(item) => {
1642                Paint::RotateAroundCenter(item.to_owned_table())
1643            }
1644            ObjRefType::VarRotateAroundCenter(item) => {
1645                Paint::VarRotateAroundCenter(item.to_owned_table())
1646            }
1647            ObjRefType::Skew(item) => Paint::Skew(item.to_owned_table()),
1648            ObjRefType::VarSkew(item) => Paint::VarSkew(item.to_owned_table()),
1649            ObjRefType::SkewAroundCenter(item) => Paint::SkewAroundCenter(item.to_owned_table()),
1650            ObjRefType::VarSkewAroundCenter(item) => {
1651                Paint::VarSkewAroundCenter(item.to_owned_table())
1652            }
1653            ObjRefType::Composite(item) => Paint::Composite(item.to_owned_table()),
1654        }
1655    }
1656}
1657
1658impl FromTableRef<read_fonts::tables::colr::Paint<'_>> for Paint {}
1659
1660impl<'a> FontRead<'a> for Paint {
1661    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
1662        <read_fonts::tables::colr::Paint as FontRead>::read(data).map(|x| x.to_owned_table())
1663    }
1664}
1665
1666impl From<PaintColrLayers> for Paint {
1667    fn from(src: PaintColrLayers) -> Paint {
1668        Paint::ColrLayers(src)
1669    }
1670}
1671
1672impl From<PaintSolid> for Paint {
1673    fn from(src: PaintSolid) -> Paint {
1674        Paint::Solid(src)
1675    }
1676}
1677
1678impl From<PaintVarSolid> for Paint {
1679    fn from(src: PaintVarSolid) -> Paint {
1680        Paint::VarSolid(src)
1681    }
1682}
1683
1684impl From<PaintLinearGradient> for Paint {
1685    fn from(src: PaintLinearGradient) -> Paint {
1686        Paint::LinearGradient(src)
1687    }
1688}
1689
1690impl From<PaintVarLinearGradient> for Paint {
1691    fn from(src: PaintVarLinearGradient) -> Paint {
1692        Paint::VarLinearGradient(src)
1693    }
1694}
1695
1696impl From<PaintRadialGradient> for Paint {
1697    fn from(src: PaintRadialGradient) -> Paint {
1698        Paint::RadialGradient(src)
1699    }
1700}
1701
1702impl From<PaintVarRadialGradient> for Paint {
1703    fn from(src: PaintVarRadialGradient) -> Paint {
1704        Paint::VarRadialGradient(src)
1705    }
1706}
1707
1708impl From<PaintSweepGradient> for Paint {
1709    fn from(src: PaintSweepGradient) -> Paint {
1710        Paint::SweepGradient(src)
1711    }
1712}
1713
1714impl From<PaintVarSweepGradient> for Paint {
1715    fn from(src: PaintVarSweepGradient) -> Paint {
1716        Paint::VarSweepGradient(src)
1717    }
1718}
1719
1720impl From<PaintGlyph> for Paint {
1721    fn from(src: PaintGlyph) -> Paint {
1722        Paint::Glyph(src)
1723    }
1724}
1725
1726impl From<PaintColrGlyph> for Paint {
1727    fn from(src: PaintColrGlyph) -> Paint {
1728        Paint::ColrGlyph(src)
1729    }
1730}
1731
1732impl From<PaintTransform> for Paint {
1733    fn from(src: PaintTransform) -> Paint {
1734        Paint::Transform(src)
1735    }
1736}
1737
1738impl From<PaintVarTransform> for Paint {
1739    fn from(src: PaintVarTransform) -> Paint {
1740        Paint::VarTransform(src)
1741    }
1742}
1743
1744impl From<PaintTranslate> for Paint {
1745    fn from(src: PaintTranslate) -> Paint {
1746        Paint::Translate(src)
1747    }
1748}
1749
1750impl From<PaintVarTranslate> for Paint {
1751    fn from(src: PaintVarTranslate) -> Paint {
1752        Paint::VarTranslate(src)
1753    }
1754}
1755
1756impl From<PaintScale> for Paint {
1757    fn from(src: PaintScale) -> Paint {
1758        Paint::Scale(src)
1759    }
1760}
1761
1762impl From<PaintVarScale> for Paint {
1763    fn from(src: PaintVarScale) -> Paint {
1764        Paint::VarScale(src)
1765    }
1766}
1767
1768impl From<PaintScaleAroundCenter> for Paint {
1769    fn from(src: PaintScaleAroundCenter) -> Paint {
1770        Paint::ScaleAroundCenter(src)
1771    }
1772}
1773
1774impl From<PaintVarScaleAroundCenter> for Paint {
1775    fn from(src: PaintVarScaleAroundCenter) -> Paint {
1776        Paint::VarScaleAroundCenter(src)
1777    }
1778}
1779
1780impl From<PaintScaleUniform> for Paint {
1781    fn from(src: PaintScaleUniform) -> Paint {
1782        Paint::ScaleUniform(src)
1783    }
1784}
1785
1786impl From<PaintVarScaleUniform> for Paint {
1787    fn from(src: PaintVarScaleUniform) -> Paint {
1788        Paint::VarScaleUniform(src)
1789    }
1790}
1791
1792impl From<PaintScaleUniformAroundCenter> for Paint {
1793    fn from(src: PaintScaleUniformAroundCenter) -> Paint {
1794        Paint::ScaleUniformAroundCenter(src)
1795    }
1796}
1797
1798impl From<PaintVarScaleUniformAroundCenter> for Paint {
1799    fn from(src: PaintVarScaleUniformAroundCenter) -> Paint {
1800        Paint::VarScaleUniformAroundCenter(src)
1801    }
1802}
1803
1804impl From<PaintRotate> for Paint {
1805    fn from(src: PaintRotate) -> Paint {
1806        Paint::Rotate(src)
1807    }
1808}
1809
1810impl From<PaintVarRotate> for Paint {
1811    fn from(src: PaintVarRotate) -> Paint {
1812        Paint::VarRotate(src)
1813    }
1814}
1815
1816impl From<PaintRotateAroundCenter> for Paint {
1817    fn from(src: PaintRotateAroundCenter) -> Paint {
1818        Paint::RotateAroundCenter(src)
1819    }
1820}
1821
1822impl From<PaintVarRotateAroundCenter> for Paint {
1823    fn from(src: PaintVarRotateAroundCenter) -> Paint {
1824        Paint::VarRotateAroundCenter(src)
1825    }
1826}
1827
1828impl From<PaintSkew> for Paint {
1829    fn from(src: PaintSkew) -> Paint {
1830        Paint::Skew(src)
1831    }
1832}
1833
1834impl From<PaintVarSkew> for Paint {
1835    fn from(src: PaintVarSkew) -> Paint {
1836        Paint::VarSkew(src)
1837    }
1838}
1839
1840impl From<PaintSkewAroundCenter> for Paint {
1841    fn from(src: PaintSkewAroundCenter) -> Paint {
1842        Paint::SkewAroundCenter(src)
1843    }
1844}
1845
1846impl From<PaintVarSkewAroundCenter> for Paint {
1847    fn from(src: PaintVarSkewAroundCenter) -> Paint {
1848        Paint::VarSkewAroundCenter(src)
1849    }
1850}
1851
1852impl From<PaintComposite> for Paint {
1853    fn from(src: PaintComposite) -> Paint {
1854        Paint::Composite(src)
1855    }
1856}
1857
1858/// [PaintColrLayers](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#format-1-paintcolrlayers) table
1859#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
1860#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1861pub struct PaintColrLayers {
1862    /// Number of offsets to paint tables to read from LayerList.
1863    pub num_layers: u8,
1864    /// Index (base 0) into the LayerList.
1865    pub first_layer_index: u32,
1866}
1867
1868impl PaintColrLayers {
1869    /// Construct a new `PaintColrLayers`
1870    pub fn new(num_layers: u8, first_layer_index: u32) -> Self {
1871        Self {
1872            num_layers,
1873            first_layer_index,
1874        }
1875    }
1876}
1877
1878impl FontWrite for PaintColrLayers {
1879    #[allow(clippy::unnecessary_cast)]
1880    fn write_into(&self, writer: &mut TableWriter) {
1881        (1 as u8).write_into(writer);
1882        self.num_layers.write_into(writer);
1883        self.first_layer_index.write_into(writer);
1884    }
1885    fn table_type(&self) -> TableType {
1886        TableType::Named("PaintColrLayers")
1887    }
1888}
1889
1890impl Validate for PaintColrLayers {
1891    fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
1892}
1893
1894impl<'a> FromObjRef<read_fonts::tables::colr::PaintColrLayers<'a>> for PaintColrLayers {
1895    fn from_obj_ref(obj: &read_fonts::tables::colr::PaintColrLayers<'a>, _: FontData) -> Self {
1896        PaintColrLayers {
1897            num_layers: obj.num_layers(),
1898            first_layer_index: obj.first_layer_index(),
1899        }
1900    }
1901}
1902
1903#[allow(clippy::needless_lifetimes)]
1904impl<'a> FromTableRef<read_fonts::tables::colr::PaintColrLayers<'a>> for PaintColrLayers {}
1905
1906impl<'a> FontRead<'a> for PaintColrLayers {
1907    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
1908        <read_fonts::tables::colr::PaintColrLayers as FontRead>::read(data)
1909            .map(|x| x.to_owned_table())
1910    }
1911}
1912
1913/// [PaintSolid](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-2-and-3-paintsolid-paintvarsolid) table
1914#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
1915#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1916pub struct PaintSolid {
1917    /// Index for a CPAL palette entry.
1918    pub palette_index: u16,
1919    /// Alpha value.
1920    pub alpha: F2Dot14,
1921}
1922
1923impl PaintSolid {
1924    /// Construct a new `PaintSolid`
1925    pub fn new(palette_index: u16, alpha: F2Dot14) -> Self {
1926        Self {
1927            palette_index,
1928            alpha,
1929        }
1930    }
1931}
1932
1933impl FontWrite for PaintSolid {
1934    #[allow(clippy::unnecessary_cast)]
1935    fn write_into(&self, writer: &mut TableWriter) {
1936        (2 as u8).write_into(writer);
1937        self.palette_index.write_into(writer);
1938        self.alpha.write_into(writer);
1939    }
1940    fn table_type(&self) -> TableType {
1941        TableType::Named("PaintSolid")
1942    }
1943}
1944
1945impl Validate for PaintSolid {
1946    fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
1947}
1948
1949impl<'a> FromObjRef<read_fonts::tables::colr::PaintSolid<'a>> for PaintSolid {
1950    fn from_obj_ref(obj: &read_fonts::tables::colr::PaintSolid<'a>, _: FontData) -> Self {
1951        PaintSolid {
1952            palette_index: obj.palette_index(),
1953            alpha: obj.alpha(),
1954        }
1955    }
1956}
1957
1958#[allow(clippy::needless_lifetimes)]
1959impl<'a> FromTableRef<read_fonts::tables::colr::PaintSolid<'a>> for PaintSolid {}
1960
1961impl<'a> FontRead<'a> for PaintSolid {
1962    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
1963        <read_fonts::tables::colr::PaintSolid as FontRead>::read(data).map(|x| x.to_owned_table())
1964    }
1965}
1966
1967/// [PaintVarSolid](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-2-and-3-paintsolid-paintvarsolid) table
1968#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
1969#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1970pub struct PaintVarSolid {
1971    /// Index for a CPAL palette entry.
1972    pub palette_index: u16,
1973    /// Alpha value. For variation, use varIndexBase + 0.
1974    pub alpha: F2Dot14,
1975    /// Base index into DeltaSetIndexMap.
1976    pub var_index_base: u32,
1977}
1978
1979impl PaintVarSolid {
1980    /// Construct a new `PaintVarSolid`
1981    pub fn new(palette_index: u16, alpha: F2Dot14, var_index_base: u32) -> Self {
1982        Self {
1983            palette_index,
1984            alpha,
1985            var_index_base,
1986        }
1987    }
1988}
1989
1990impl FontWrite for PaintVarSolid {
1991    #[allow(clippy::unnecessary_cast)]
1992    fn write_into(&self, writer: &mut TableWriter) {
1993        (3 as u8).write_into(writer);
1994        self.palette_index.write_into(writer);
1995        self.alpha.write_into(writer);
1996        self.var_index_base.write_into(writer);
1997    }
1998    fn table_type(&self) -> TableType {
1999        TableType::Named("PaintVarSolid")
2000    }
2001}
2002
2003impl Validate for PaintVarSolid {
2004    fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
2005}
2006
2007impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarSolid<'a>> for PaintVarSolid {
2008    fn from_obj_ref(obj: &read_fonts::tables::colr::PaintVarSolid<'a>, _: FontData) -> Self {
2009        PaintVarSolid {
2010            palette_index: obj.palette_index(),
2011            alpha: obj.alpha(),
2012            var_index_base: obj.var_index_base(),
2013        }
2014    }
2015}
2016
2017#[allow(clippy::needless_lifetimes)]
2018impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarSolid<'a>> for PaintVarSolid {}
2019
2020impl<'a> FontRead<'a> for PaintVarSolid {
2021    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
2022        <read_fonts::tables::colr::PaintVarSolid as FontRead>::read(data)
2023            .map(|x| x.to_owned_table())
2024    }
2025}
2026
2027/// [PaintLinearGradient](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-4-and-5-paintlineargradient-paintvarlineargradient) table
2028#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2029#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2030pub struct PaintLinearGradient {
2031    /// Offset to ColorLine table.
2032    pub color_line: OffsetMarker<ColorLine, WIDTH_24>,
2033    /// Start point (p₀) x coordinate.
2034    pub x0: FWord,
2035    /// Start point (p₀) y coordinate.
2036    pub y0: FWord,
2037    /// End point (p₁) x coordinate.
2038    pub x1: FWord,
2039    /// End point (p₁) y coordinate.
2040    pub y1: FWord,
2041    /// Rotation point (p₂) x coordinate.
2042    pub x2: FWord,
2043    /// Rotation point (p₂) y coordinate.
2044    pub y2: FWord,
2045}
2046
2047impl PaintLinearGradient {
2048    /// Construct a new `PaintLinearGradient`
2049    pub fn new(
2050        color_line: ColorLine,
2051        x0: FWord,
2052        y0: FWord,
2053        x1: FWord,
2054        y1: FWord,
2055        x2: FWord,
2056        y2: FWord,
2057    ) -> Self {
2058        Self {
2059            color_line: color_line.into(),
2060            x0,
2061            y0,
2062            x1,
2063            y1,
2064            x2,
2065            y2,
2066        }
2067    }
2068}
2069
2070impl FontWrite for PaintLinearGradient {
2071    #[allow(clippy::unnecessary_cast)]
2072    fn write_into(&self, writer: &mut TableWriter) {
2073        (4 as u8).write_into(writer);
2074        self.color_line.write_into(writer);
2075        self.x0.write_into(writer);
2076        self.y0.write_into(writer);
2077        self.x1.write_into(writer);
2078        self.y1.write_into(writer);
2079        self.x2.write_into(writer);
2080        self.y2.write_into(writer);
2081    }
2082    fn table_type(&self) -> TableType {
2083        TableType::Named("PaintLinearGradient")
2084    }
2085}
2086
2087impl Validate for PaintLinearGradient {
2088    fn validate_impl(&self, ctx: &mut ValidationCtx) {
2089        ctx.in_table("PaintLinearGradient", |ctx| {
2090            ctx.in_field("color_line", |ctx| {
2091                self.color_line.validate_impl(ctx);
2092            });
2093        })
2094    }
2095}
2096
2097impl<'a> FromObjRef<read_fonts::tables::colr::PaintLinearGradient<'a>> for PaintLinearGradient {
2098    fn from_obj_ref(obj: &read_fonts::tables::colr::PaintLinearGradient<'a>, _: FontData) -> Self {
2099        PaintLinearGradient {
2100            color_line: obj.color_line().to_owned_table(),
2101            x0: obj.x0(),
2102            y0: obj.y0(),
2103            x1: obj.x1(),
2104            y1: obj.y1(),
2105            x2: obj.x2(),
2106            y2: obj.y2(),
2107        }
2108    }
2109}
2110
2111#[allow(clippy::needless_lifetimes)]
2112impl<'a> FromTableRef<read_fonts::tables::colr::PaintLinearGradient<'a>> for PaintLinearGradient {}
2113
2114impl<'a> FontRead<'a> for PaintLinearGradient {
2115    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
2116        <read_fonts::tables::colr::PaintLinearGradient as FontRead>::read(data)
2117            .map(|x| x.to_owned_table())
2118    }
2119}
2120
2121/// [PaintVarLinearGradient](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-4-and-5-paintlineargradient-paintvarlineargradient) table
2122#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2123#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2124pub struct PaintVarLinearGradient {
2125    /// Offset to VarColorLine table.
2126    pub color_line: OffsetMarker<VarColorLine, WIDTH_24>,
2127    /// Start point (p₀) x coordinate. For variation, use
2128    /// varIndexBase + 0.
2129    pub x0: FWord,
2130    /// Start point (p₀) y coordinate. For variation, use
2131    /// varIndexBase + 1.
2132    pub y0: FWord,
2133    /// End point (p₁) x coordinate. For variation, use varIndexBase
2134    /// + 2.
2135    pub x1: FWord,
2136    /// End point (p₁) y coordinate. For variation, use varIndexBase
2137    /// + 3.
2138    pub y1: FWord,
2139    /// Rotation point (p₂) x coordinate. For variation, use
2140    /// varIndexBase + 4.
2141    pub x2: FWord,
2142    /// Rotation point (p₂) y coordinate. For variation, use
2143    /// varIndexBase + 5.
2144    pub y2: FWord,
2145    /// Base index into DeltaSetIndexMap.
2146    pub var_index_base: u32,
2147}
2148
2149impl PaintVarLinearGradient {
2150    /// Construct a new `PaintVarLinearGradient`
2151    #[allow(clippy::too_many_arguments)]
2152    pub fn new(
2153        color_line: VarColorLine,
2154        x0: FWord,
2155        y0: FWord,
2156        x1: FWord,
2157        y1: FWord,
2158        x2: FWord,
2159        y2: FWord,
2160        var_index_base: u32,
2161    ) -> Self {
2162        Self {
2163            color_line: color_line.into(),
2164            x0,
2165            y0,
2166            x1,
2167            y1,
2168            x2,
2169            y2,
2170            var_index_base,
2171        }
2172    }
2173}
2174
2175impl FontWrite for PaintVarLinearGradient {
2176    #[allow(clippy::unnecessary_cast)]
2177    fn write_into(&self, writer: &mut TableWriter) {
2178        (5 as u8).write_into(writer);
2179        self.color_line.write_into(writer);
2180        self.x0.write_into(writer);
2181        self.y0.write_into(writer);
2182        self.x1.write_into(writer);
2183        self.y1.write_into(writer);
2184        self.x2.write_into(writer);
2185        self.y2.write_into(writer);
2186        self.var_index_base.write_into(writer);
2187    }
2188    fn table_type(&self) -> TableType {
2189        TableType::Named("PaintVarLinearGradient")
2190    }
2191}
2192
2193impl Validate for PaintVarLinearGradient {
2194    fn validate_impl(&self, ctx: &mut ValidationCtx) {
2195        ctx.in_table("PaintVarLinearGradient", |ctx| {
2196            ctx.in_field("color_line", |ctx| {
2197                self.color_line.validate_impl(ctx);
2198            });
2199        })
2200    }
2201}
2202
2203impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarLinearGradient<'a>>
2204    for PaintVarLinearGradient
2205{
2206    fn from_obj_ref(
2207        obj: &read_fonts::tables::colr::PaintVarLinearGradient<'a>,
2208        _: FontData,
2209    ) -> Self {
2210        PaintVarLinearGradient {
2211            color_line: obj.color_line().to_owned_table(),
2212            x0: obj.x0(),
2213            y0: obj.y0(),
2214            x1: obj.x1(),
2215            y1: obj.y1(),
2216            x2: obj.x2(),
2217            y2: obj.y2(),
2218            var_index_base: obj.var_index_base(),
2219        }
2220    }
2221}
2222
2223#[allow(clippy::needless_lifetimes)]
2224impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarLinearGradient<'a>>
2225    for PaintVarLinearGradient
2226{
2227}
2228
2229impl<'a> FontRead<'a> for PaintVarLinearGradient {
2230    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
2231        <read_fonts::tables::colr::PaintVarLinearGradient as FontRead>::read(data)
2232            .map(|x| x.to_owned_table())
2233    }
2234}
2235
2236/// [PaintRadialGradient](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-6-and-7-paintradialgradient-paintvarradialgradient) table
2237#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2238#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2239pub struct PaintRadialGradient {
2240    /// Offset to ColorLine table.
2241    pub color_line: OffsetMarker<ColorLine, WIDTH_24>,
2242    /// Start circle center x coordinate.
2243    pub x0: FWord,
2244    /// Start circle center y coordinate.
2245    pub y0: FWord,
2246    /// Start circle radius.
2247    pub radius0: UfWord,
2248    /// End circle center x coordinate.
2249    pub x1: FWord,
2250    /// End circle center y coordinate.
2251    pub y1: FWord,
2252    /// End circle radius.
2253    pub radius1: UfWord,
2254}
2255
2256impl PaintRadialGradient {
2257    /// Construct a new `PaintRadialGradient`
2258    pub fn new(
2259        color_line: ColorLine,
2260        x0: FWord,
2261        y0: FWord,
2262        radius0: UfWord,
2263        x1: FWord,
2264        y1: FWord,
2265        radius1: UfWord,
2266    ) -> Self {
2267        Self {
2268            color_line: color_line.into(),
2269            x0,
2270            y0,
2271            radius0,
2272            x1,
2273            y1,
2274            radius1,
2275        }
2276    }
2277}
2278
2279impl FontWrite for PaintRadialGradient {
2280    #[allow(clippy::unnecessary_cast)]
2281    fn write_into(&self, writer: &mut TableWriter) {
2282        (6 as u8).write_into(writer);
2283        self.color_line.write_into(writer);
2284        self.x0.write_into(writer);
2285        self.y0.write_into(writer);
2286        self.radius0.write_into(writer);
2287        self.x1.write_into(writer);
2288        self.y1.write_into(writer);
2289        self.radius1.write_into(writer);
2290    }
2291    fn table_type(&self) -> TableType {
2292        TableType::Named("PaintRadialGradient")
2293    }
2294}
2295
2296impl Validate for PaintRadialGradient {
2297    fn validate_impl(&self, ctx: &mut ValidationCtx) {
2298        ctx.in_table("PaintRadialGradient", |ctx| {
2299            ctx.in_field("color_line", |ctx| {
2300                self.color_line.validate_impl(ctx);
2301            });
2302        })
2303    }
2304}
2305
2306impl<'a> FromObjRef<read_fonts::tables::colr::PaintRadialGradient<'a>> for PaintRadialGradient {
2307    fn from_obj_ref(obj: &read_fonts::tables::colr::PaintRadialGradient<'a>, _: FontData) -> Self {
2308        PaintRadialGradient {
2309            color_line: obj.color_line().to_owned_table(),
2310            x0: obj.x0(),
2311            y0: obj.y0(),
2312            radius0: obj.radius0(),
2313            x1: obj.x1(),
2314            y1: obj.y1(),
2315            radius1: obj.radius1(),
2316        }
2317    }
2318}
2319
2320#[allow(clippy::needless_lifetimes)]
2321impl<'a> FromTableRef<read_fonts::tables::colr::PaintRadialGradient<'a>> for PaintRadialGradient {}
2322
2323impl<'a> FontRead<'a> for PaintRadialGradient {
2324    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
2325        <read_fonts::tables::colr::PaintRadialGradient as FontRead>::read(data)
2326            .map(|x| x.to_owned_table())
2327    }
2328}
2329
2330/// [PaintVarRadialGradient](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-6-and-7-paintradialgradient-paintvarradialgradient) table
2331#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2332#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2333pub struct PaintVarRadialGradient {
2334    /// Offset to VarColorLine table.
2335    pub color_line: OffsetMarker<VarColorLine, WIDTH_24>,
2336    /// Start circle center x coordinate. For variation, use
2337    /// varIndexBase + 0.
2338    pub x0: FWord,
2339    /// Start circle center y coordinate. For variation, use
2340    /// varIndexBase + 1.
2341    pub y0: FWord,
2342    /// Start circle radius. For variation, use varIndexBase + 2.
2343    pub radius0: UfWord,
2344    /// End circle center x coordinate. For variation, use varIndexBase
2345    /// + 3.
2346    pub x1: FWord,
2347    /// End circle center y coordinate. For variation, use varIndexBase
2348    /// + 4.
2349    pub y1: FWord,
2350    /// End circle radius. For variation, use varIndexBase + 5.
2351    pub radius1: UfWord,
2352    /// Base index into DeltaSetIndexMap.
2353    pub var_index_base: u32,
2354}
2355
2356impl PaintVarRadialGradient {
2357    /// Construct a new `PaintVarRadialGradient`
2358    #[allow(clippy::too_many_arguments)]
2359    pub fn new(
2360        color_line: VarColorLine,
2361        x0: FWord,
2362        y0: FWord,
2363        radius0: UfWord,
2364        x1: FWord,
2365        y1: FWord,
2366        radius1: UfWord,
2367        var_index_base: u32,
2368    ) -> Self {
2369        Self {
2370            color_line: color_line.into(),
2371            x0,
2372            y0,
2373            radius0,
2374            x1,
2375            y1,
2376            radius1,
2377            var_index_base,
2378        }
2379    }
2380}
2381
2382impl FontWrite for PaintVarRadialGradient {
2383    #[allow(clippy::unnecessary_cast)]
2384    fn write_into(&self, writer: &mut TableWriter) {
2385        (7 as u8).write_into(writer);
2386        self.color_line.write_into(writer);
2387        self.x0.write_into(writer);
2388        self.y0.write_into(writer);
2389        self.radius0.write_into(writer);
2390        self.x1.write_into(writer);
2391        self.y1.write_into(writer);
2392        self.radius1.write_into(writer);
2393        self.var_index_base.write_into(writer);
2394    }
2395    fn table_type(&self) -> TableType {
2396        TableType::Named("PaintVarRadialGradient")
2397    }
2398}
2399
2400impl Validate for PaintVarRadialGradient {
2401    fn validate_impl(&self, ctx: &mut ValidationCtx) {
2402        ctx.in_table("PaintVarRadialGradient", |ctx| {
2403            ctx.in_field("color_line", |ctx| {
2404                self.color_line.validate_impl(ctx);
2405            });
2406        })
2407    }
2408}
2409
2410impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarRadialGradient<'a>>
2411    for PaintVarRadialGradient
2412{
2413    fn from_obj_ref(
2414        obj: &read_fonts::tables::colr::PaintVarRadialGradient<'a>,
2415        _: FontData,
2416    ) -> Self {
2417        PaintVarRadialGradient {
2418            color_line: obj.color_line().to_owned_table(),
2419            x0: obj.x0(),
2420            y0: obj.y0(),
2421            radius0: obj.radius0(),
2422            x1: obj.x1(),
2423            y1: obj.y1(),
2424            radius1: obj.radius1(),
2425            var_index_base: obj.var_index_base(),
2426        }
2427    }
2428}
2429
2430#[allow(clippy::needless_lifetimes)]
2431impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarRadialGradient<'a>>
2432    for PaintVarRadialGradient
2433{
2434}
2435
2436impl<'a> FontRead<'a> for PaintVarRadialGradient {
2437    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
2438        <read_fonts::tables::colr::PaintVarRadialGradient as FontRead>::read(data)
2439            .map(|x| x.to_owned_table())
2440    }
2441}
2442
2443/// [PaintSweepGradient](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-8-and-9-paintsweepgradient-paintvarsweepgradient) table
2444#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2445#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2446pub struct PaintSweepGradient {
2447    /// Offset to ColorLine table.
2448    pub color_line: OffsetMarker<ColorLine, WIDTH_24>,
2449    /// Center x coordinate.
2450    pub center_x: FWord,
2451    /// Center y coordinate.
2452    pub center_y: FWord,
2453    /// Start of the angular range of the gradient, 180° in
2454    /// counter-clockwise degrees per 1.0 of value.
2455    pub start_angle: F2Dot14,
2456    /// End of the angular range of the gradient, 180° in
2457    /// counter-clockwise degrees per 1.0 of value.
2458    pub end_angle: F2Dot14,
2459}
2460
2461impl PaintSweepGradient {
2462    /// Construct a new `PaintSweepGradient`
2463    pub fn new(
2464        color_line: ColorLine,
2465        center_x: FWord,
2466        center_y: FWord,
2467        start_angle: F2Dot14,
2468        end_angle: F2Dot14,
2469    ) -> Self {
2470        Self {
2471            color_line: color_line.into(),
2472            center_x,
2473            center_y,
2474            start_angle,
2475            end_angle,
2476        }
2477    }
2478}
2479
2480impl FontWrite for PaintSweepGradient {
2481    #[allow(clippy::unnecessary_cast)]
2482    fn write_into(&self, writer: &mut TableWriter) {
2483        (8 as u8).write_into(writer);
2484        self.color_line.write_into(writer);
2485        self.center_x.write_into(writer);
2486        self.center_y.write_into(writer);
2487        self.start_angle.write_into(writer);
2488        self.end_angle.write_into(writer);
2489    }
2490    fn table_type(&self) -> TableType {
2491        TableType::Named("PaintSweepGradient")
2492    }
2493}
2494
2495impl Validate for PaintSweepGradient {
2496    fn validate_impl(&self, ctx: &mut ValidationCtx) {
2497        ctx.in_table("PaintSweepGradient", |ctx| {
2498            ctx.in_field("color_line", |ctx| {
2499                self.color_line.validate_impl(ctx);
2500            });
2501        })
2502    }
2503}
2504
2505impl<'a> FromObjRef<read_fonts::tables::colr::PaintSweepGradient<'a>> for PaintSweepGradient {
2506    fn from_obj_ref(obj: &read_fonts::tables::colr::PaintSweepGradient<'a>, _: FontData) -> Self {
2507        PaintSweepGradient {
2508            color_line: obj.color_line().to_owned_table(),
2509            center_x: obj.center_x(),
2510            center_y: obj.center_y(),
2511            start_angle: obj.start_angle(),
2512            end_angle: obj.end_angle(),
2513        }
2514    }
2515}
2516
2517#[allow(clippy::needless_lifetimes)]
2518impl<'a> FromTableRef<read_fonts::tables::colr::PaintSweepGradient<'a>> for PaintSweepGradient {}
2519
2520impl<'a> FontRead<'a> for PaintSweepGradient {
2521    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
2522        <read_fonts::tables::colr::PaintSweepGradient as FontRead>::read(data)
2523            .map(|x| x.to_owned_table())
2524    }
2525}
2526
2527/// [PaintVarSweepGradient](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-8-and-9-paintsweepgradient-paintvarsweepgradient) table
2528#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2529#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2530pub struct PaintVarSweepGradient {
2531    /// Offset to VarColorLine table.
2532    pub color_line: OffsetMarker<VarColorLine, WIDTH_24>,
2533    /// Center x coordinate. For variation, use varIndexBase + 0.
2534    pub center_x: FWord,
2535    /// Center y coordinate. For variation, use varIndexBase + 1.
2536    pub center_y: FWord,
2537    /// Start of the angular range of the gradient, 180° in
2538    /// counter-clockwise degrees per 1.0 of value. For variation, use
2539    /// varIndexBase + 2.
2540    pub start_angle: F2Dot14,
2541    /// End of the angular range of the gradient, 180° in
2542    /// counter-clockwise degrees per 1.0 of value. For variation, use
2543    /// varIndexBase + 3.
2544    pub end_angle: F2Dot14,
2545    /// Base index into DeltaSetIndexMap.
2546    pub var_index_base: u32,
2547}
2548
2549impl PaintVarSweepGradient {
2550    /// Construct a new `PaintVarSweepGradient`
2551    pub fn new(
2552        color_line: VarColorLine,
2553        center_x: FWord,
2554        center_y: FWord,
2555        start_angle: F2Dot14,
2556        end_angle: F2Dot14,
2557        var_index_base: u32,
2558    ) -> Self {
2559        Self {
2560            color_line: color_line.into(),
2561            center_x,
2562            center_y,
2563            start_angle,
2564            end_angle,
2565            var_index_base,
2566        }
2567    }
2568}
2569
2570impl FontWrite for PaintVarSweepGradient {
2571    #[allow(clippy::unnecessary_cast)]
2572    fn write_into(&self, writer: &mut TableWriter) {
2573        (9 as u8).write_into(writer);
2574        self.color_line.write_into(writer);
2575        self.center_x.write_into(writer);
2576        self.center_y.write_into(writer);
2577        self.start_angle.write_into(writer);
2578        self.end_angle.write_into(writer);
2579        self.var_index_base.write_into(writer);
2580    }
2581    fn table_type(&self) -> TableType {
2582        TableType::Named("PaintVarSweepGradient")
2583    }
2584}
2585
2586impl Validate for PaintVarSweepGradient {
2587    fn validate_impl(&self, ctx: &mut ValidationCtx) {
2588        ctx.in_table("PaintVarSweepGradient", |ctx| {
2589            ctx.in_field("color_line", |ctx| {
2590                self.color_line.validate_impl(ctx);
2591            });
2592        })
2593    }
2594}
2595
2596impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarSweepGradient<'a>> for PaintVarSweepGradient {
2597    fn from_obj_ref(
2598        obj: &read_fonts::tables::colr::PaintVarSweepGradient<'a>,
2599        _: FontData,
2600    ) -> Self {
2601        PaintVarSweepGradient {
2602            color_line: obj.color_line().to_owned_table(),
2603            center_x: obj.center_x(),
2604            center_y: obj.center_y(),
2605            start_angle: obj.start_angle(),
2606            end_angle: obj.end_angle(),
2607            var_index_base: obj.var_index_base(),
2608        }
2609    }
2610}
2611
2612#[allow(clippy::needless_lifetimes)]
2613impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarSweepGradient<'a>>
2614    for PaintVarSweepGradient
2615{
2616}
2617
2618impl<'a> FontRead<'a> for PaintVarSweepGradient {
2619    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
2620        <read_fonts::tables::colr::PaintVarSweepGradient as FontRead>::read(data)
2621            .map(|x| x.to_owned_table())
2622    }
2623}
2624
2625/// [PaintGlyph](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#format-10-paintglyph) table
2626#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2627#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2628pub struct PaintGlyph {
2629    /// Offset to a Paint table.
2630    pub paint: OffsetMarker<Paint, WIDTH_24>,
2631    /// Glyph ID for the source outline.
2632    pub glyph_id: GlyphId16,
2633}
2634
2635impl PaintGlyph {
2636    /// Construct a new `PaintGlyph`
2637    pub fn new(paint: Paint, glyph_id: GlyphId16) -> Self {
2638        Self {
2639            paint: paint.into(),
2640            glyph_id,
2641        }
2642    }
2643}
2644
2645impl FontWrite for PaintGlyph {
2646    #[allow(clippy::unnecessary_cast)]
2647    fn write_into(&self, writer: &mut TableWriter) {
2648        (10 as u8).write_into(writer);
2649        self.paint.write_into(writer);
2650        self.glyph_id.write_into(writer);
2651    }
2652    fn table_type(&self) -> TableType {
2653        TableType::Named("PaintGlyph")
2654    }
2655}
2656
2657impl Validate for PaintGlyph {
2658    fn validate_impl(&self, ctx: &mut ValidationCtx) {
2659        ctx.in_table("PaintGlyph", |ctx| {
2660            ctx.in_field("paint", |ctx| {
2661                self.paint.validate_impl(ctx);
2662            });
2663        })
2664    }
2665}
2666
2667impl<'a> FromObjRef<read_fonts::tables::colr::PaintGlyph<'a>> for PaintGlyph {
2668    fn from_obj_ref(obj: &read_fonts::tables::colr::PaintGlyph<'a>, _: FontData) -> Self {
2669        PaintGlyph {
2670            paint: obj.paint().to_owned_table(),
2671            glyph_id: obj.glyph_id(),
2672        }
2673    }
2674}
2675
2676#[allow(clippy::needless_lifetimes)]
2677impl<'a> FromTableRef<read_fonts::tables::colr::PaintGlyph<'a>> for PaintGlyph {}
2678
2679impl<'a> FontRead<'a> for PaintGlyph {
2680    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
2681        <read_fonts::tables::colr::PaintGlyph as FontRead>::read(data).map(|x| x.to_owned_table())
2682    }
2683}
2684
2685/// [PaintColrGlyph](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#format-11-paintcolrglyph) table
2686#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2687#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2688pub struct PaintColrGlyph {
2689    /// Glyph ID for a BaseGlyphList base glyph.
2690    pub glyph_id: GlyphId16,
2691}
2692
2693impl PaintColrGlyph {
2694    /// Construct a new `PaintColrGlyph`
2695    pub fn new(glyph_id: GlyphId16) -> Self {
2696        Self { glyph_id }
2697    }
2698}
2699
2700impl FontWrite for PaintColrGlyph {
2701    #[allow(clippy::unnecessary_cast)]
2702    fn write_into(&self, writer: &mut TableWriter) {
2703        (11 as u8).write_into(writer);
2704        self.glyph_id.write_into(writer);
2705    }
2706    fn table_type(&self) -> TableType {
2707        TableType::Named("PaintColrGlyph")
2708    }
2709}
2710
2711impl Validate for PaintColrGlyph {
2712    fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
2713}
2714
2715impl<'a> FromObjRef<read_fonts::tables::colr::PaintColrGlyph<'a>> for PaintColrGlyph {
2716    fn from_obj_ref(obj: &read_fonts::tables::colr::PaintColrGlyph<'a>, _: FontData) -> Self {
2717        PaintColrGlyph {
2718            glyph_id: obj.glyph_id(),
2719        }
2720    }
2721}
2722
2723#[allow(clippy::needless_lifetimes)]
2724impl<'a> FromTableRef<read_fonts::tables::colr::PaintColrGlyph<'a>> for PaintColrGlyph {}
2725
2726impl<'a> FontRead<'a> for PaintColrGlyph {
2727    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
2728        <read_fonts::tables::colr::PaintColrGlyph as FontRead>::read(data)
2729            .map(|x| x.to_owned_table())
2730    }
2731}
2732
2733/// [PaintTransform](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-12-and-13-painttransform-paintvartransform) table
2734#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2735#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2736pub struct PaintTransform {
2737    /// Offset to a Paint subtable.
2738    pub paint: OffsetMarker<Paint, WIDTH_24>,
2739    /// Offset to an Affine2x3 table.
2740    pub transform: OffsetMarker<Affine2x3, WIDTH_24>,
2741}
2742
2743impl PaintTransform {
2744    /// Construct a new `PaintTransform`
2745    pub fn new(paint: Paint, transform: Affine2x3) -> Self {
2746        Self {
2747            paint: paint.into(),
2748            transform: transform.into(),
2749        }
2750    }
2751}
2752
2753impl FontWrite for PaintTransform {
2754    #[allow(clippy::unnecessary_cast)]
2755    fn write_into(&self, writer: &mut TableWriter) {
2756        (12 as u8).write_into(writer);
2757        self.paint.write_into(writer);
2758        self.transform.write_into(writer);
2759    }
2760    fn table_type(&self) -> TableType {
2761        TableType::Named("PaintTransform")
2762    }
2763}
2764
2765impl Validate for PaintTransform {
2766    fn validate_impl(&self, ctx: &mut ValidationCtx) {
2767        ctx.in_table("PaintTransform", |ctx| {
2768            ctx.in_field("paint", |ctx| {
2769                self.paint.validate_impl(ctx);
2770            });
2771            ctx.in_field("transform", |ctx| {
2772                self.transform.validate_impl(ctx);
2773            });
2774        })
2775    }
2776}
2777
2778impl<'a> FromObjRef<read_fonts::tables::colr::PaintTransform<'a>> for PaintTransform {
2779    fn from_obj_ref(obj: &read_fonts::tables::colr::PaintTransform<'a>, _: FontData) -> Self {
2780        PaintTransform {
2781            paint: obj.paint().to_owned_table(),
2782            transform: obj.transform().to_owned_table(),
2783        }
2784    }
2785}
2786
2787#[allow(clippy::needless_lifetimes)]
2788impl<'a> FromTableRef<read_fonts::tables::colr::PaintTransform<'a>> for PaintTransform {}
2789
2790impl<'a> FontRead<'a> for PaintTransform {
2791    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
2792        <read_fonts::tables::colr::PaintTransform as FontRead>::read(data)
2793            .map(|x| x.to_owned_table())
2794    }
2795}
2796
2797/// [PaintVarTransform](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-12-and-13-painttransform-paintvartransform) table
2798#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2799#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2800pub struct PaintVarTransform {
2801    /// Offset to a Paint subtable.
2802    pub paint: OffsetMarker<Paint, WIDTH_24>,
2803    /// Offset to a VarAffine2x3 table.
2804    pub transform: OffsetMarker<VarAffine2x3, WIDTH_24>,
2805}
2806
2807impl PaintVarTransform {
2808    /// Construct a new `PaintVarTransform`
2809    pub fn new(paint: Paint, transform: VarAffine2x3) -> Self {
2810        Self {
2811            paint: paint.into(),
2812            transform: transform.into(),
2813        }
2814    }
2815}
2816
2817impl FontWrite for PaintVarTransform {
2818    #[allow(clippy::unnecessary_cast)]
2819    fn write_into(&self, writer: &mut TableWriter) {
2820        (13 as u8).write_into(writer);
2821        self.paint.write_into(writer);
2822        self.transform.write_into(writer);
2823    }
2824    fn table_type(&self) -> TableType {
2825        TableType::Named("PaintVarTransform")
2826    }
2827}
2828
2829impl Validate for PaintVarTransform {
2830    fn validate_impl(&self, ctx: &mut ValidationCtx) {
2831        ctx.in_table("PaintVarTransform", |ctx| {
2832            ctx.in_field("paint", |ctx| {
2833                self.paint.validate_impl(ctx);
2834            });
2835            ctx.in_field("transform", |ctx| {
2836                self.transform.validate_impl(ctx);
2837            });
2838        })
2839    }
2840}
2841
2842impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarTransform<'a>> for PaintVarTransform {
2843    fn from_obj_ref(obj: &read_fonts::tables::colr::PaintVarTransform<'a>, _: FontData) -> Self {
2844        PaintVarTransform {
2845            paint: obj.paint().to_owned_table(),
2846            transform: obj.transform().to_owned_table(),
2847        }
2848    }
2849}
2850
2851#[allow(clippy::needless_lifetimes)]
2852impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarTransform<'a>> for PaintVarTransform {}
2853
2854impl<'a> FontRead<'a> for PaintVarTransform {
2855    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
2856        <read_fonts::tables::colr::PaintVarTransform as FontRead>::read(data)
2857            .map(|x| x.to_owned_table())
2858    }
2859}
2860
2861/// [Affine2x3](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-12-and-13-painttransform-paintvartransform) record
2862#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2863#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2864pub struct Affine2x3 {
2865    /// x-component of transformed x-basis vector.
2866    pub xx: Fixed,
2867    /// y-component of transformed x-basis vector.
2868    pub yx: Fixed,
2869    /// x-component of transformed y-basis vector.
2870    pub xy: Fixed,
2871    /// y-component of transformed y-basis vector.
2872    pub yy: Fixed,
2873    /// Translation in x direction.
2874    pub dx: Fixed,
2875    /// Translation in y direction.
2876    pub dy: Fixed,
2877}
2878
2879impl Affine2x3 {
2880    /// Construct a new `Affine2x3`
2881    pub fn new(xx: Fixed, yx: Fixed, xy: Fixed, yy: Fixed, dx: Fixed, dy: Fixed) -> Self {
2882        Self {
2883            xx,
2884            yx,
2885            xy,
2886            yy,
2887            dx,
2888            dy,
2889        }
2890    }
2891}
2892
2893impl FontWrite for Affine2x3 {
2894    fn write_into(&self, writer: &mut TableWriter) {
2895        self.xx.write_into(writer);
2896        self.yx.write_into(writer);
2897        self.xy.write_into(writer);
2898        self.yy.write_into(writer);
2899        self.dx.write_into(writer);
2900        self.dy.write_into(writer);
2901    }
2902    fn table_type(&self) -> TableType {
2903        TableType::Named("Affine2x3")
2904    }
2905}
2906
2907impl Validate for Affine2x3 {
2908    fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
2909}
2910
2911impl<'a> FromObjRef<read_fonts::tables::colr::Affine2x3<'a>> for Affine2x3 {
2912    fn from_obj_ref(obj: &read_fonts::tables::colr::Affine2x3<'a>, _: FontData) -> Self {
2913        Affine2x3 {
2914            xx: obj.xx(),
2915            yx: obj.yx(),
2916            xy: obj.xy(),
2917            yy: obj.yy(),
2918            dx: obj.dx(),
2919            dy: obj.dy(),
2920        }
2921    }
2922}
2923
2924#[allow(clippy::needless_lifetimes)]
2925impl<'a> FromTableRef<read_fonts::tables::colr::Affine2x3<'a>> for Affine2x3 {}
2926
2927impl<'a> FontRead<'a> for Affine2x3 {
2928    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
2929        <read_fonts::tables::colr::Affine2x3 as FontRead>::read(data).map(|x| x.to_owned_table())
2930    }
2931}
2932
2933/// [VarAffine2x3](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-12-and-13-painttransform-paintvartransform) record
2934#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2935#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2936pub struct VarAffine2x3 {
2937    /// x-component of transformed x-basis vector. For variation, use
2938    /// varIndexBase + 0.
2939    pub xx: Fixed,
2940    /// y-component of transformed x-basis vector. For variation, use
2941    /// varIndexBase + 1.
2942    pub yx: Fixed,
2943    /// x-component of transformed y-basis vector. For variation, use
2944    /// varIndexBase + 2.
2945    pub xy: Fixed,
2946    /// y-component of transformed y-basis vector. For variation, use
2947    /// varIndexBase + 3.
2948    pub yy: Fixed,
2949    /// Translation in x direction. For variation, use varIndexBase + 4.
2950    pub dx: Fixed,
2951    /// Translation in y direction. For variation, use varIndexBase + 5.
2952    pub dy: Fixed,
2953    /// Base index into DeltaSetIndexMap.
2954    pub var_index_base: u32,
2955}
2956
2957impl VarAffine2x3 {
2958    /// Construct a new `VarAffine2x3`
2959    pub fn new(
2960        xx: Fixed,
2961        yx: Fixed,
2962        xy: Fixed,
2963        yy: Fixed,
2964        dx: Fixed,
2965        dy: Fixed,
2966        var_index_base: u32,
2967    ) -> Self {
2968        Self {
2969            xx,
2970            yx,
2971            xy,
2972            yy,
2973            dx,
2974            dy,
2975            var_index_base,
2976        }
2977    }
2978}
2979
2980impl FontWrite for VarAffine2x3 {
2981    fn write_into(&self, writer: &mut TableWriter) {
2982        self.xx.write_into(writer);
2983        self.yx.write_into(writer);
2984        self.xy.write_into(writer);
2985        self.yy.write_into(writer);
2986        self.dx.write_into(writer);
2987        self.dy.write_into(writer);
2988        self.var_index_base.write_into(writer);
2989    }
2990    fn table_type(&self) -> TableType {
2991        TableType::Named("VarAffine2x3")
2992    }
2993}
2994
2995impl Validate for VarAffine2x3 {
2996    fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
2997}
2998
2999impl<'a> FromObjRef<read_fonts::tables::colr::VarAffine2x3<'a>> for VarAffine2x3 {
3000    fn from_obj_ref(obj: &read_fonts::tables::colr::VarAffine2x3<'a>, _: FontData) -> Self {
3001        VarAffine2x3 {
3002            xx: obj.xx(),
3003            yx: obj.yx(),
3004            xy: obj.xy(),
3005            yy: obj.yy(),
3006            dx: obj.dx(),
3007            dy: obj.dy(),
3008            var_index_base: obj.var_index_base(),
3009        }
3010    }
3011}
3012
3013#[allow(clippy::needless_lifetimes)]
3014impl<'a> FromTableRef<read_fonts::tables::colr::VarAffine2x3<'a>> for VarAffine2x3 {}
3015
3016impl<'a> FontRead<'a> for VarAffine2x3 {
3017    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
3018        <read_fonts::tables::colr::VarAffine2x3 as FontRead>::read(data).map(|x| x.to_owned_table())
3019    }
3020}
3021
3022/// [PaintTranslate](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-14-and-15-painttranslate-paintvartranslate) table
3023#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3024#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3025pub struct PaintTranslate {
3026    /// Offset to a Paint subtable.
3027    pub paint: OffsetMarker<Paint, WIDTH_24>,
3028    /// Translation in x direction.
3029    pub dx: FWord,
3030    /// Translation in y direction.
3031    pub dy: FWord,
3032}
3033
3034impl PaintTranslate {
3035    /// Construct a new `PaintTranslate`
3036    pub fn new(paint: Paint, dx: FWord, dy: FWord) -> Self {
3037        Self {
3038            paint: paint.into(),
3039            dx,
3040            dy,
3041        }
3042    }
3043}
3044
3045impl FontWrite for PaintTranslate {
3046    #[allow(clippy::unnecessary_cast)]
3047    fn write_into(&self, writer: &mut TableWriter) {
3048        (14 as u8).write_into(writer);
3049        self.paint.write_into(writer);
3050        self.dx.write_into(writer);
3051        self.dy.write_into(writer);
3052    }
3053    fn table_type(&self) -> TableType {
3054        TableType::Named("PaintTranslate")
3055    }
3056}
3057
3058impl Validate for PaintTranslate {
3059    fn validate_impl(&self, ctx: &mut ValidationCtx) {
3060        ctx.in_table("PaintTranslate", |ctx| {
3061            ctx.in_field("paint", |ctx| {
3062                self.paint.validate_impl(ctx);
3063            });
3064        })
3065    }
3066}
3067
3068impl<'a> FromObjRef<read_fonts::tables::colr::PaintTranslate<'a>> for PaintTranslate {
3069    fn from_obj_ref(obj: &read_fonts::tables::colr::PaintTranslate<'a>, _: FontData) -> Self {
3070        PaintTranslate {
3071            paint: obj.paint().to_owned_table(),
3072            dx: obj.dx(),
3073            dy: obj.dy(),
3074        }
3075    }
3076}
3077
3078#[allow(clippy::needless_lifetimes)]
3079impl<'a> FromTableRef<read_fonts::tables::colr::PaintTranslate<'a>> for PaintTranslate {}
3080
3081impl<'a> FontRead<'a> for PaintTranslate {
3082    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
3083        <read_fonts::tables::colr::PaintTranslate as FontRead>::read(data)
3084            .map(|x| x.to_owned_table())
3085    }
3086}
3087
3088/// [PaintVarTranslate](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-14-and-15-painttranslate-paintvartranslate) table
3089#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3090#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3091pub struct PaintVarTranslate {
3092    /// Offset to a Paint subtable.
3093    pub paint: OffsetMarker<Paint, WIDTH_24>,
3094    /// Translation in x direction. For variation, use varIndexBase + 0.
3095    pub dx: FWord,
3096    /// Translation in y direction. For variation, use varIndexBase + 1.
3097    pub dy: FWord,
3098    /// Base index into DeltaSetIndexMap.
3099    pub var_index_base: u32,
3100}
3101
3102impl PaintVarTranslate {
3103    /// Construct a new `PaintVarTranslate`
3104    pub fn new(paint: Paint, dx: FWord, dy: FWord, var_index_base: u32) -> Self {
3105        Self {
3106            paint: paint.into(),
3107            dx,
3108            dy,
3109            var_index_base,
3110        }
3111    }
3112}
3113
3114impl FontWrite for PaintVarTranslate {
3115    #[allow(clippy::unnecessary_cast)]
3116    fn write_into(&self, writer: &mut TableWriter) {
3117        (15 as u8).write_into(writer);
3118        self.paint.write_into(writer);
3119        self.dx.write_into(writer);
3120        self.dy.write_into(writer);
3121        self.var_index_base.write_into(writer);
3122    }
3123    fn table_type(&self) -> TableType {
3124        TableType::Named("PaintVarTranslate")
3125    }
3126}
3127
3128impl Validate for PaintVarTranslate {
3129    fn validate_impl(&self, ctx: &mut ValidationCtx) {
3130        ctx.in_table("PaintVarTranslate", |ctx| {
3131            ctx.in_field("paint", |ctx| {
3132                self.paint.validate_impl(ctx);
3133            });
3134        })
3135    }
3136}
3137
3138impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarTranslate<'a>> for PaintVarTranslate {
3139    fn from_obj_ref(obj: &read_fonts::tables::colr::PaintVarTranslate<'a>, _: FontData) -> Self {
3140        PaintVarTranslate {
3141            paint: obj.paint().to_owned_table(),
3142            dx: obj.dx(),
3143            dy: obj.dy(),
3144            var_index_base: obj.var_index_base(),
3145        }
3146    }
3147}
3148
3149#[allow(clippy::needless_lifetimes)]
3150impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarTranslate<'a>> for PaintVarTranslate {}
3151
3152impl<'a> FontRead<'a> for PaintVarTranslate {
3153    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
3154        <read_fonts::tables::colr::PaintVarTranslate as FontRead>::read(data)
3155            .map(|x| x.to_owned_table())
3156    }
3157}
3158
3159/// [PaintScale](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-16-to-23-paintscale-and-variant-scaling-formats) table
3160#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3161#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3162pub struct PaintScale {
3163    /// Offset to a Paint subtable.
3164    pub paint: OffsetMarker<Paint, WIDTH_24>,
3165    /// Scale factor in x direction.
3166    pub scale_x: F2Dot14,
3167    /// Scale factor in y direction.
3168    pub scale_y: F2Dot14,
3169}
3170
3171impl PaintScale {
3172    /// Construct a new `PaintScale`
3173    pub fn new(paint: Paint, scale_x: F2Dot14, scale_y: F2Dot14) -> Self {
3174        Self {
3175            paint: paint.into(),
3176            scale_x,
3177            scale_y,
3178        }
3179    }
3180}
3181
3182impl FontWrite for PaintScale {
3183    #[allow(clippy::unnecessary_cast)]
3184    fn write_into(&self, writer: &mut TableWriter) {
3185        (16 as u8).write_into(writer);
3186        self.paint.write_into(writer);
3187        self.scale_x.write_into(writer);
3188        self.scale_y.write_into(writer);
3189    }
3190    fn table_type(&self) -> TableType {
3191        TableType::Named("PaintScale")
3192    }
3193}
3194
3195impl Validate for PaintScale {
3196    fn validate_impl(&self, ctx: &mut ValidationCtx) {
3197        ctx.in_table("PaintScale", |ctx| {
3198            ctx.in_field("paint", |ctx| {
3199                self.paint.validate_impl(ctx);
3200            });
3201        })
3202    }
3203}
3204
3205impl<'a> FromObjRef<read_fonts::tables::colr::PaintScale<'a>> for PaintScale {
3206    fn from_obj_ref(obj: &read_fonts::tables::colr::PaintScale<'a>, _: FontData) -> Self {
3207        PaintScale {
3208            paint: obj.paint().to_owned_table(),
3209            scale_x: obj.scale_x(),
3210            scale_y: obj.scale_y(),
3211        }
3212    }
3213}
3214
3215#[allow(clippy::needless_lifetimes)]
3216impl<'a> FromTableRef<read_fonts::tables::colr::PaintScale<'a>> for PaintScale {}
3217
3218impl<'a> FontRead<'a> for PaintScale {
3219    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
3220        <read_fonts::tables::colr::PaintScale as FontRead>::read(data).map(|x| x.to_owned_table())
3221    }
3222}
3223
3224/// [PaintVarScale](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-16-to-23-paintscale-and-variant-scaling-formats) table
3225#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3226#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3227pub struct PaintVarScale {
3228    /// Offset to a Paint subtable.
3229    pub paint: OffsetMarker<Paint, WIDTH_24>,
3230    /// Scale factor in x direction. For variation, use varIndexBase +
3231    /// 0.
3232    pub scale_x: F2Dot14,
3233    /// Scale factor in y direction. For variation, use varIndexBase +
3234    /// 1.
3235    pub scale_y: F2Dot14,
3236    /// Base index into DeltaSetIndexMap.
3237    pub var_index_base: u32,
3238}
3239
3240impl PaintVarScale {
3241    /// Construct a new `PaintVarScale`
3242    pub fn new(paint: Paint, scale_x: F2Dot14, scale_y: F2Dot14, var_index_base: u32) -> Self {
3243        Self {
3244            paint: paint.into(),
3245            scale_x,
3246            scale_y,
3247            var_index_base,
3248        }
3249    }
3250}
3251
3252impl FontWrite for PaintVarScale {
3253    #[allow(clippy::unnecessary_cast)]
3254    fn write_into(&self, writer: &mut TableWriter) {
3255        (17 as u8).write_into(writer);
3256        self.paint.write_into(writer);
3257        self.scale_x.write_into(writer);
3258        self.scale_y.write_into(writer);
3259        self.var_index_base.write_into(writer);
3260    }
3261    fn table_type(&self) -> TableType {
3262        TableType::Named("PaintVarScale")
3263    }
3264}
3265
3266impl Validate for PaintVarScale {
3267    fn validate_impl(&self, ctx: &mut ValidationCtx) {
3268        ctx.in_table("PaintVarScale", |ctx| {
3269            ctx.in_field("paint", |ctx| {
3270                self.paint.validate_impl(ctx);
3271            });
3272        })
3273    }
3274}
3275
3276impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarScale<'a>> for PaintVarScale {
3277    fn from_obj_ref(obj: &read_fonts::tables::colr::PaintVarScale<'a>, _: FontData) -> Self {
3278        PaintVarScale {
3279            paint: obj.paint().to_owned_table(),
3280            scale_x: obj.scale_x(),
3281            scale_y: obj.scale_y(),
3282            var_index_base: obj.var_index_base(),
3283        }
3284    }
3285}
3286
3287#[allow(clippy::needless_lifetimes)]
3288impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarScale<'a>> for PaintVarScale {}
3289
3290impl<'a> FontRead<'a> for PaintVarScale {
3291    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
3292        <read_fonts::tables::colr::PaintVarScale as FontRead>::read(data)
3293            .map(|x| x.to_owned_table())
3294    }
3295}
3296
3297/// [PaintScaleAroundCenter](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-16-to-23-paintscale-and-variant-scaling-formats) table
3298#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3299#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3300pub struct PaintScaleAroundCenter {
3301    /// Offset to a Paint subtable.
3302    pub paint: OffsetMarker<Paint, WIDTH_24>,
3303    /// Scale factor in x direction.
3304    pub scale_x: F2Dot14,
3305    /// Scale factor in y direction.
3306    pub scale_y: F2Dot14,
3307    /// x coordinate for the center of scaling.
3308    pub center_x: FWord,
3309    /// y coordinate for the center of scaling.
3310    pub center_y: FWord,
3311}
3312
3313impl PaintScaleAroundCenter {
3314    /// Construct a new `PaintScaleAroundCenter`
3315    pub fn new(
3316        paint: Paint,
3317        scale_x: F2Dot14,
3318        scale_y: F2Dot14,
3319        center_x: FWord,
3320        center_y: FWord,
3321    ) -> Self {
3322        Self {
3323            paint: paint.into(),
3324            scale_x,
3325            scale_y,
3326            center_x,
3327            center_y,
3328        }
3329    }
3330}
3331
3332impl FontWrite for PaintScaleAroundCenter {
3333    #[allow(clippy::unnecessary_cast)]
3334    fn write_into(&self, writer: &mut TableWriter) {
3335        (18 as u8).write_into(writer);
3336        self.paint.write_into(writer);
3337        self.scale_x.write_into(writer);
3338        self.scale_y.write_into(writer);
3339        self.center_x.write_into(writer);
3340        self.center_y.write_into(writer);
3341    }
3342    fn table_type(&self) -> TableType {
3343        TableType::Named("PaintScaleAroundCenter")
3344    }
3345}
3346
3347impl Validate for PaintScaleAroundCenter {
3348    fn validate_impl(&self, ctx: &mut ValidationCtx) {
3349        ctx.in_table("PaintScaleAroundCenter", |ctx| {
3350            ctx.in_field("paint", |ctx| {
3351                self.paint.validate_impl(ctx);
3352            });
3353        })
3354    }
3355}
3356
3357impl<'a> FromObjRef<read_fonts::tables::colr::PaintScaleAroundCenter<'a>>
3358    for PaintScaleAroundCenter
3359{
3360    fn from_obj_ref(
3361        obj: &read_fonts::tables::colr::PaintScaleAroundCenter<'a>,
3362        _: FontData,
3363    ) -> Self {
3364        PaintScaleAroundCenter {
3365            paint: obj.paint().to_owned_table(),
3366            scale_x: obj.scale_x(),
3367            scale_y: obj.scale_y(),
3368            center_x: obj.center_x(),
3369            center_y: obj.center_y(),
3370        }
3371    }
3372}
3373
3374#[allow(clippy::needless_lifetimes)]
3375impl<'a> FromTableRef<read_fonts::tables::colr::PaintScaleAroundCenter<'a>>
3376    for PaintScaleAroundCenter
3377{
3378}
3379
3380impl<'a> FontRead<'a> for PaintScaleAroundCenter {
3381    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
3382        <read_fonts::tables::colr::PaintScaleAroundCenter as FontRead>::read(data)
3383            .map(|x| x.to_owned_table())
3384    }
3385}
3386
3387/// [PaintVarScaleAroundCenter](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-16-to-23-paintscale-and-variant-scaling-formats) table
3388#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3389#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3390pub struct PaintVarScaleAroundCenter {
3391    /// Offset to a Paint subtable.
3392    pub paint: OffsetMarker<Paint, WIDTH_24>,
3393    /// Scale factor in x direction. For variation, use varIndexBase +
3394    /// 0.
3395    pub scale_x: F2Dot14,
3396    /// Scale factor in y direction. For variation, use varIndexBase +
3397    /// 1.
3398    pub scale_y: F2Dot14,
3399    /// x coordinate for the center of scaling. For variation, use
3400    /// varIndexBase + 2.
3401    pub center_x: FWord,
3402    /// y coordinate for the center of scaling. For variation, use
3403    /// varIndexBase + 3.
3404    pub center_y: FWord,
3405    /// Base index into DeltaSetIndexMap.
3406    pub var_index_base: u32,
3407}
3408
3409impl PaintVarScaleAroundCenter {
3410    /// Construct a new `PaintVarScaleAroundCenter`
3411    pub fn new(
3412        paint: Paint,
3413        scale_x: F2Dot14,
3414        scale_y: F2Dot14,
3415        center_x: FWord,
3416        center_y: FWord,
3417        var_index_base: u32,
3418    ) -> Self {
3419        Self {
3420            paint: paint.into(),
3421            scale_x,
3422            scale_y,
3423            center_x,
3424            center_y,
3425            var_index_base,
3426        }
3427    }
3428}
3429
3430impl FontWrite for PaintVarScaleAroundCenter {
3431    #[allow(clippy::unnecessary_cast)]
3432    fn write_into(&self, writer: &mut TableWriter) {
3433        (19 as u8).write_into(writer);
3434        self.paint.write_into(writer);
3435        self.scale_x.write_into(writer);
3436        self.scale_y.write_into(writer);
3437        self.center_x.write_into(writer);
3438        self.center_y.write_into(writer);
3439        self.var_index_base.write_into(writer);
3440    }
3441    fn table_type(&self) -> TableType {
3442        TableType::Named("PaintVarScaleAroundCenter")
3443    }
3444}
3445
3446impl Validate for PaintVarScaleAroundCenter {
3447    fn validate_impl(&self, ctx: &mut ValidationCtx) {
3448        ctx.in_table("PaintVarScaleAroundCenter", |ctx| {
3449            ctx.in_field("paint", |ctx| {
3450                self.paint.validate_impl(ctx);
3451            });
3452        })
3453    }
3454}
3455
3456impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarScaleAroundCenter<'a>>
3457    for PaintVarScaleAroundCenter
3458{
3459    fn from_obj_ref(
3460        obj: &read_fonts::tables::colr::PaintVarScaleAroundCenter<'a>,
3461        _: FontData,
3462    ) -> Self {
3463        PaintVarScaleAroundCenter {
3464            paint: obj.paint().to_owned_table(),
3465            scale_x: obj.scale_x(),
3466            scale_y: obj.scale_y(),
3467            center_x: obj.center_x(),
3468            center_y: obj.center_y(),
3469            var_index_base: obj.var_index_base(),
3470        }
3471    }
3472}
3473
3474#[allow(clippy::needless_lifetimes)]
3475impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarScaleAroundCenter<'a>>
3476    for PaintVarScaleAroundCenter
3477{
3478}
3479
3480impl<'a> FontRead<'a> for PaintVarScaleAroundCenter {
3481    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
3482        <read_fonts::tables::colr::PaintVarScaleAroundCenter as FontRead>::read(data)
3483            .map(|x| x.to_owned_table())
3484    }
3485}
3486
3487/// [PaintScaleUniform](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-16-to-23-paintscale-and-variant-scaling-formats) table
3488#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3489#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3490pub struct PaintScaleUniform {
3491    /// Offset to a Paint subtable.
3492    pub paint: OffsetMarker<Paint, WIDTH_24>,
3493    /// Scale factor in x and y directions.
3494    pub scale: F2Dot14,
3495}
3496
3497impl PaintScaleUniform {
3498    /// Construct a new `PaintScaleUniform`
3499    pub fn new(paint: Paint, scale: F2Dot14) -> Self {
3500        Self {
3501            paint: paint.into(),
3502            scale,
3503        }
3504    }
3505}
3506
3507impl FontWrite for PaintScaleUniform {
3508    #[allow(clippy::unnecessary_cast)]
3509    fn write_into(&self, writer: &mut TableWriter) {
3510        (20 as u8).write_into(writer);
3511        self.paint.write_into(writer);
3512        self.scale.write_into(writer);
3513    }
3514    fn table_type(&self) -> TableType {
3515        TableType::Named("PaintScaleUniform")
3516    }
3517}
3518
3519impl Validate for PaintScaleUniform {
3520    fn validate_impl(&self, ctx: &mut ValidationCtx) {
3521        ctx.in_table("PaintScaleUniform", |ctx| {
3522            ctx.in_field("paint", |ctx| {
3523                self.paint.validate_impl(ctx);
3524            });
3525        })
3526    }
3527}
3528
3529impl<'a> FromObjRef<read_fonts::tables::colr::PaintScaleUniform<'a>> for PaintScaleUniform {
3530    fn from_obj_ref(obj: &read_fonts::tables::colr::PaintScaleUniform<'a>, _: FontData) -> Self {
3531        PaintScaleUniform {
3532            paint: obj.paint().to_owned_table(),
3533            scale: obj.scale(),
3534        }
3535    }
3536}
3537
3538#[allow(clippy::needless_lifetimes)]
3539impl<'a> FromTableRef<read_fonts::tables::colr::PaintScaleUniform<'a>> for PaintScaleUniform {}
3540
3541impl<'a> FontRead<'a> for PaintScaleUniform {
3542    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
3543        <read_fonts::tables::colr::PaintScaleUniform as FontRead>::read(data)
3544            .map(|x| x.to_owned_table())
3545    }
3546}
3547
3548/// [PaintVarScaleUniform](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-16-to-23-paintscale-and-variant-scaling-formats) table
3549#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3550#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3551pub struct PaintVarScaleUniform {
3552    /// Offset to a Paint subtable.
3553    pub paint: OffsetMarker<Paint, WIDTH_24>,
3554    /// Scale factor in x and y directions. For variation, use
3555    /// varIndexBase + 0.
3556    pub scale: F2Dot14,
3557    /// Base index into DeltaSetIndexMap.
3558    pub var_index_base: u32,
3559}
3560
3561impl PaintVarScaleUniform {
3562    /// Construct a new `PaintVarScaleUniform`
3563    pub fn new(paint: Paint, scale: F2Dot14, var_index_base: u32) -> Self {
3564        Self {
3565            paint: paint.into(),
3566            scale,
3567            var_index_base,
3568        }
3569    }
3570}
3571
3572impl FontWrite for PaintVarScaleUniform {
3573    #[allow(clippy::unnecessary_cast)]
3574    fn write_into(&self, writer: &mut TableWriter) {
3575        (21 as u8).write_into(writer);
3576        self.paint.write_into(writer);
3577        self.scale.write_into(writer);
3578        self.var_index_base.write_into(writer);
3579    }
3580    fn table_type(&self) -> TableType {
3581        TableType::Named("PaintVarScaleUniform")
3582    }
3583}
3584
3585impl Validate for PaintVarScaleUniform {
3586    fn validate_impl(&self, ctx: &mut ValidationCtx) {
3587        ctx.in_table("PaintVarScaleUniform", |ctx| {
3588            ctx.in_field("paint", |ctx| {
3589                self.paint.validate_impl(ctx);
3590            });
3591        })
3592    }
3593}
3594
3595impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarScaleUniform<'a>> for PaintVarScaleUniform {
3596    fn from_obj_ref(obj: &read_fonts::tables::colr::PaintVarScaleUniform<'a>, _: FontData) -> Self {
3597        PaintVarScaleUniform {
3598            paint: obj.paint().to_owned_table(),
3599            scale: obj.scale(),
3600            var_index_base: obj.var_index_base(),
3601        }
3602    }
3603}
3604
3605#[allow(clippy::needless_lifetimes)]
3606impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarScaleUniform<'a>> for PaintVarScaleUniform {}
3607
3608impl<'a> FontRead<'a> for PaintVarScaleUniform {
3609    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
3610        <read_fonts::tables::colr::PaintVarScaleUniform as FontRead>::read(data)
3611            .map(|x| x.to_owned_table())
3612    }
3613}
3614
3615/// [PaintScaleUniformAroundCenter](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-16-to-23-paintscale-and-variant-scaling-formats) table
3616#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3617#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3618pub struct PaintScaleUniformAroundCenter {
3619    /// Offset to a Paint subtable.
3620    pub paint: OffsetMarker<Paint, WIDTH_24>,
3621    /// Scale factor in x and y directions.
3622    pub scale: F2Dot14,
3623    /// x coordinate for the center of scaling.
3624    pub center_x: FWord,
3625    /// y coordinate for the center of scaling.
3626    pub center_y: FWord,
3627}
3628
3629impl PaintScaleUniformAroundCenter {
3630    /// Construct a new `PaintScaleUniformAroundCenter`
3631    pub fn new(paint: Paint, scale: F2Dot14, center_x: FWord, center_y: FWord) -> Self {
3632        Self {
3633            paint: paint.into(),
3634            scale,
3635            center_x,
3636            center_y,
3637        }
3638    }
3639}
3640
3641impl FontWrite for PaintScaleUniformAroundCenter {
3642    #[allow(clippy::unnecessary_cast)]
3643    fn write_into(&self, writer: &mut TableWriter) {
3644        (22 as u8).write_into(writer);
3645        self.paint.write_into(writer);
3646        self.scale.write_into(writer);
3647        self.center_x.write_into(writer);
3648        self.center_y.write_into(writer);
3649    }
3650    fn table_type(&self) -> TableType {
3651        TableType::Named("PaintScaleUniformAroundCenter")
3652    }
3653}
3654
3655impl Validate for PaintScaleUniformAroundCenter {
3656    fn validate_impl(&self, ctx: &mut ValidationCtx) {
3657        ctx.in_table("PaintScaleUniformAroundCenter", |ctx| {
3658            ctx.in_field("paint", |ctx| {
3659                self.paint.validate_impl(ctx);
3660            });
3661        })
3662    }
3663}
3664
3665impl<'a> FromObjRef<read_fonts::tables::colr::PaintScaleUniformAroundCenter<'a>>
3666    for PaintScaleUniformAroundCenter
3667{
3668    fn from_obj_ref(
3669        obj: &read_fonts::tables::colr::PaintScaleUniformAroundCenter<'a>,
3670        _: FontData,
3671    ) -> Self {
3672        PaintScaleUniformAroundCenter {
3673            paint: obj.paint().to_owned_table(),
3674            scale: obj.scale(),
3675            center_x: obj.center_x(),
3676            center_y: obj.center_y(),
3677        }
3678    }
3679}
3680
3681#[allow(clippy::needless_lifetimes)]
3682impl<'a> FromTableRef<read_fonts::tables::colr::PaintScaleUniformAroundCenter<'a>>
3683    for PaintScaleUniformAroundCenter
3684{
3685}
3686
3687impl<'a> FontRead<'a> for PaintScaleUniformAroundCenter {
3688    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
3689        <read_fonts::tables::colr::PaintScaleUniformAroundCenter as FontRead>::read(data)
3690            .map(|x| x.to_owned_table())
3691    }
3692}
3693
3694/// [PaintVarScaleUniformAroundCenter](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-16-to-23-paintscale-and-variant-scaling-formats) table
3695#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3696#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3697pub struct PaintVarScaleUniformAroundCenter {
3698    /// Offset to a Paint subtable.
3699    pub paint: OffsetMarker<Paint, WIDTH_24>,
3700    /// Scale factor in x and y directions. For variation, use
3701    /// varIndexBase + 0.
3702    pub scale: F2Dot14,
3703    /// x coordinate for the center of scaling. For variation, use
3704    /// varIndexBase + 1.
3705    pub center_x: FWord,
3706    /// y coordinate for the center of scaling. For variation, use
3707    /// varIndexBase + 2.
3708    pub center_y: FWord,
3709    /// Base index into DeltaSetIndexMap.
3710    pub var_index_base: u32,
3711}
3712
3713impl PaintVarScaleUniformAroundCenter {
3714    /// Construct a new `PaintVarScaleUniformAroundCenter`
3715    pub fn new(
3716        paint: Paint,
3717        scale: F2Dot14,
3718        center_x: FWord,
3719        center_y: FWord,
3720        var_index_base: u32,
3721    ) -> Self {
3722        Self {
3723            paint: paint.into(),
3724            scale,
3725            center_x,
3726            center_y,
3727            var_index_base,
3728        }
3729    }
3730}
3731
3732impl FontWrite for PaintVarScaleUniformAroundCenter {
3733    #[allow(clippy::unnecessary_cast)]
3734    fn write_into(&self, writer: &mut TableWriter) {
3735        (23 as u8).write_into(writer);
3736        self.paint.write_into(writer);
3737        self.scale.write_into(writer);
3738        self.center_x.write_into(writer);
3739        self.center_y.write_into(writer);
3740        self.var_index_base.write_into(writer);
3741    }
3742    fn table_type(&self) -> TableType {
3743        TableType::Named("PaintVarScaleUniformAroundCenter")
3744    }
3745}
3746
3747impl Validate for PaintVarScaleUniformAroundCenter {
3748    fn validate_impl(&self, ctx: &mut ValidationCtx) {
3749        ctx.in_table("PaintVarScaleUniformAroundCenter", |ctx| {
3750            ctx.in_field("paint", |ctx| {
3751                self.paint.validate_impl(ctx);
3752            });
3753        })
3754    }
3755}
3756
3757impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarScaleUniformAroundCenter<'a>>
3758    for PaintVarScaleUniformAroundCenter
3759{
3760    fn from_obj_ref(
3761        obj: &read_fonts::tables::colr::PaintVarScaleUniformAroundCenter<'a>,
3762        _: FontData,
3763    ) -> Self {
3764        PaintVarScaleUniformAroundCenter {
3765            paint: obj.paint().to_owned_table(),
3766            scale: obj.scale(),
3767            center_x: obj.center_x(),
3768            center_y: obj.center_y(),
3769            var_index_base: obj.var_index_base(),
3770        }
3771    }
3772}
3773
3774#[allow(clippy::needless_lifetimes)]
3775impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarScaleUniformAroundCenter<'a>>
3776    for PaintVarScaleUniformAroundCenter
3777{
3778}
3779
3780impl<'a> FontRead<'a> for PaintVarScaleUniformAroundCenter {
3781    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
3782        <read_fonts::tables::colr::PaintVarScaleUniformAroundCenter as FontRead>::read(data)
3783            .map(|x| x.to_owned_table())
3784    }
3785}
3786
3787/// [PaintRotate](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-24-to-27-paintrotate-paintvarrotate-paintrotatearoundcenter-paintvarrotatearoundcenter) table
3788#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3789#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3790pub struct PaintRotate {
3791    /// Offset to a Paint subtable.
3792    pub paint: OffsetMarker<Paint, WIDTH_24>,
3793    /// Rotation angle, 180° in counter-clockwise degrees per 1.0 of
3794    /// value.
3795    pub angle: F2Dot14,
3796}
3797
3798impl PaintRotate {
3799    /// Construct a new `PaintRotate`
3800    pub fn new(paint: Paint, angle: F2Dot14) -> Self {
3801        Self {
3802            paint: paint.into(),
3803            angle,
3804        }
3805    }
3806}
3807
3808impl FontWrite for PaintRotate {
3809    #[allow(clippy::unnecessary_cast)]
3810    fn write_into(&self, writer: &mut TableWriter) {
3811        (24 as u8).write_into(writer);
3812        self.paint.write_into(writer);
3813        self.angle.write_into(writer);
3814    }
3815    fn table_type(&self) -> TableType {
3816        TableType::Named("PaintRotate")
3817    }
3818}
3819
3820impl Validate for PaintRotate {
3821    fn validate_impl(&self, ctx: &mut ValidationCtx) {
3822        ctx.in_table("PaintRotate", |ctx| {
3823            ctx.in_field("paint", |ctx| {
3824                self.paint.validate_impl(ctx);
3825            });
3826        })
3827    }
3828}
3829
3830impl<'a> FromObjRef<read_fonts::tables::colr::PaintRotate<'a>> for PaintRotate {
3831    fn from_obj_ref(obj: &read_fonts::tables::colr::PaintRotate<'a>, _: FontData) -> Self {
3832        PaintRotate {
3833            paint: obj.paint().to_owned_table(),
3834            angle: obj.angle(),
3835        }
3836    }
3837}
3838
3839#[allow(clippy::needless_lifetimes)]
3840impl<'a> FromTableRef<read_fonts::tables::colr::PaintRotate<'a>> for PaintRotate {}
3841
3842impl<'a> FontRead<'a> for PaintRotate {
3843    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
3844        <read_fonts::tables::colr::PaintRotate as FontRead>::read(data).map(|x| x.to_owned_table())
3845    }
3846}
3847
3848/// [PaintVarRotate](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-24-to-27-paintrotate-paintvarrotate-paintrotatearoundcenter-paintvarrotatearoundcenter) table
3849#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3850#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3851pub struct PaintVarRotate {
3852    /// Offset to a Paint subtable.
3853    pub paint: OffsetMarker<Paint, WIDTH_24>,
3854    /// Rotation angle, 180° in counter-clockwise degrees per 1.0 of
3855    /// value. For variation, use varIndexBase + 0.
3856    pub angle: F2Dot14,
3857    /// Base index into DeltaSetIndexMap.
3858    pub var_index_base: u32,
3859}
3860
3861impl PaintVarRotate {
3862    /// Construct a new `PaintVarRotate`
3863    pub fn new(paint: Paint, angle: F2Dot14, var_index_base: u32) -> Self {
3864        Self {
3865            paint: paint.into(),
3866            angle,
3867            var_index_base,
3868        }
3869    }
3870}
3871
3872impl FontWrite for PaintVarRotate {
3873    #[allow(clippy::unnecessary_cast)]
3874    fn write_into(&self, writer: &mut TableWriter) {
3875        (25 as u8).write_into(writer);
3876        self.paint.write_into(writer);
3877        self.angle.write_into(writer);
3878        self.var_index_base.write_into(writer);
3879    }
3880    fn table_type(&self) -> TableType {
3881        TableType::Named("PaintVarRotate")
3882    }
3883}
3884
3885impl Validate for PaintVarRotate {
3886    fn validate_impl(&self, ctx: &mut ValidationCtx) {
3887        ctx.in_table("PaintVarRotate", |ctx| {
3888            ctx.in_field("paint", |ctx| {
3889                self.paint.validate_impl(ctx);
3890            });
3891        })
3892    }
3893}
3894
3895impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarRotate<'a>> for PaintVarRotate {
3896    fn from_obj_ref(obj: &read_fonts::tables::colr::PaintVarRotate<'a>, _: FontData) -> Self {
3897        PaintVarRotate {
3898            paint: obj.paint().to_owned_table(),
3899            angle: obj.angle(),
3900            var_index_base: obj.var_index_base(),
3901        }
3902    }
3903}
3904
3905#[allow(clippy::needless_lifetimes)]
3906impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarRotate<'a>> for PaintVarRotate {}
3907
3908impl<'a> FontRead<'a> for PaintVarRotate {
3909    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
3910        <read_fonts::tables::colr::PaintVarRotate as FontRead>::read(data)
3911            .map(|x| x.to_owned_table())
3912    }
3913}
3914
3915/// [PaintRotateAroundCenter](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-24-to-27-paintrotate-paintvarrotate-paintrotatearoundcenter-paintvarrotatearoundcenter) table
3916#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3917#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3918pub struct PaintRotateAroundCenter {
3919    /// Offset to a Paint subtable.
3920    pub paint: OffsetMarker<Paint, WIDTH_24>,
3921    /// Rotation angle, 180° in counter-clockwise degrees per 1.0 of
3922    /// value.
3923    pub angle: F2Dot14,
3924    /// x coordinate for the center of rotation.
3925    pub center_x: FWord,
3926    /// y coordinate for the center of rotation.
3927    pub center_y: FWord,
3928}
3929
3930impl PaintRotateAroundCenter {
3931    /// Construct a new `PaintRotateAroundCenter`
3932    pub fn new(paint: Paint, angle: F2Dot14, center_x: FWord, center_y: FWord) -> Self {
3933        Self {
3934            paint: paint.into(),
3935            angle,
3936            center_x,
3937            center_y,
3938        }
3939    }
3940}
3941
3942impl FontWrite for PaintRotateAroundCenter {
3943    #[allow(clippy::unnecessary_cast)]
3944    fn write_into(&self, writer: &mut TableWriter) {
3945        (26 as u8).write_into(writer);
3946        self.paint.write_into(writer);
3947        self.angle.write_into(writer);
3948        self.center_x.write_into(writer);
3949        self.center_y.write_into(writer);
3950    }
3951    fn table_type(&self) -> TableType {
3952        TableType::Named("PaintRotateAroundCenter")
3953    }
3954}
3955
3956impl Validate for PaintRotateAroundCenter {
3957    fn validate_impl(&self, ctx: &mut ValidationCtx) {
3958        ctx.in_table("PaintRotateAroundCenter", |ctx| {
3959            ctx.in_field("paint", |ctx| {
3960                self.paint.validate_impl(ctx);
3961            });
3962        })
3963    }
3964}
3965
3966impl<'a> FromObjRef<read_fonts::tables::colr::PaintRotateAroundCenter<'a>>
3967    for PaintRotateAroundCenter
3968{
3969    fn from_obj_ref(
3970        obj: &read_fonts::tables::colr::PaintRotateAroundCenter<'a>,
3971        _: FontData,
3972    ) -> Self {
3973        PaintRotateAroundCenter {
3974            paint: obj.paint().to_owned_table(),
3975            angle: obj.angle(),
3976            center_x: obj.center_x(),
3977            center_y: obj.center_y(),
3978        }
3979    }
3980}
3981
3982#[allow(clippy::needless_lifetimes)]
3983impl<'a> FromTableRef<read_fonts::tables::colr::PaintRotateAroundCenter<'a>>
3984    for PaintRotateAroundCenter
3985{
3986}
3987
3988impl<'a> FontRead<'a> for PaintRotateAroundCenter {
3989    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
3990        <read_fonts::tables::colr::PaintRotateAroundCenter as FontRead>::read(data)
3991            .map(|x| x.to_owned_table())
3992    }
3993}
3994
3995/// [PaintVarRotateAroundCenter](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-24-to-27-paintrotate-paintvarrotate-paintrotatearoundcenter-paintvarrotatearoundcenter) table
3996#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3997#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3998pub struct PaintVarRotateAroundCenter {
3999    /// Offset to a Paint subtable.
4000    pub paint: OffsetMarker<Paint, WIDTH_24>,
4001    /// Rotation angle, 180° in counter-clockwise degrees per 1.0 of
4002    /// value. For variation, use varIndexBase + 0.
4003    pub angle: F2Dot14,
4004    /// x coordinate for the center of rotation. For variation, use
4005    /// varIndexBase + 1.
4006    pub center_x: FWord,
4007    /// y coordinate for the center of rotation. For variation, use
4008    /// varIndexBase + 2.
4009    pub center_y: FWord,
4010    /// Base index into DeltaSetIndexMap.
4011    pub var_index_base: u32,
4012}
4013
4014impl PaintVarRotateAroundCenter {
4015    /// Construct a new `PaintVarRotateAroundCenter`
4016    pub fn new(
4017        paint: Paint,
4018        angle: F2Dot14,
4019        center_x: FWord,
4020        center_y: FWord,
4021        var_index_base: u32,
4022    ) -> Self {
4023        Self {
4024            paint: paint.into(),
4025            angle,
4026            center_x,
4027            center_y,
4028            var_index_base,
4029        }
4030    }
4031}
4032
4033impl FontWrite for PaintVarRotateAroundCenter {
4034    #[allow(clippy::unnecessary_cast)]
4035    fn write_into(&self, writer: &mut TableWriter) {
4036        (27 as u8).write_into(writer);
4037        self.paint.write_into(writer);
4038        self.angle.write_into(writer);
4039        self.center_x.write_into(writer);
4040        self.center_y.write_into(writer);
4041        self.var_index_base.write_into(writer);
4042    }
4043    fn table_type(&self) -> TableType {
4044        TableType::Named("PaintVarRotateAroundCenter")
4045    }
4046}
4047
4048impl Validate for PaintVarRotateAroundCenter {
4049    fn validate_impl(&self, ctx: &mut ValidationCtx) {
4050        ctx.in_table("PaintVarRotateAroundCenter", |ctx| {
4051            ctx.in_field("paint", |ctx| {
4052                self.paint.validate_impl(ctx);
4053            });
4054        })
4055    }
4056}
4057
4058impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarRotateAroundCenter<'a>>
4059    for PaintVarRotateAroundCenter
4060{
4061    fn from_obj_ref(
4062        obj: &read_fonts::tables::colr::PaintVarRotateAroundCenter<'a>,
4063        _: FontData,
4064    ) -> Self {
4065        PaintVarRotateAroundCenter {
4066            paint: obj.paint().to_owned_table(),
4067            angle: obj.angle(),
4068            center_x: obj.center_x(),
4069            center_y: obj.center_y(),
4070            var_index_base: obj.var_index_base(),
4071        }
4072    }
4073}
4074
4075#[allow(clippy::needless_lifetimes)]
4076impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarRotateAroundCenter<'a>>
4077    for PaintVarRotateAroundCenter
4078{
4079}
4080
4081impl<'a> FontRead<'a> for PaintVarRotateAroundCenter {
4082    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
4083        <read_fonts::tables::colr::PaintVarRotateAroundCenter as FontRead>::read(data)
4084            .map(|x| x.to_owned_table())
4085    }
4086}
4087
4088/// [PaintSkew](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-28-to-31-paintskew-paintvarskew-paintskewaroundcenter-paintvarskewaroundcenter) table
4089#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
4090#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4091pub struct PaintSkew {
4092    /// Offset to a Paint subtable.
4093    pub paint: OffsetMarker<Paint, WIDTH_24>,
4094    /// Angle of skew in the direction of the x-axis, 180° in
4095    /// counter-clockwise degrees per 1.0 of value.
4096    pub x_skew_angle: F2Dot14,
4097    /// Angle of skew in the direction of the y-axis, 180° in
4098    /// counter-clockwise degrees per 1.0 of value.
4099    pub y_skew_angle: F2Dot14,
4100}
4101
4102impl PaintSkew {
4103    /// Construct a new `PaintSkew`
4104    pub fn new(paint: Paint, x_skew_angle: F2Dot14, y_skew_angle: F2Dot14) -> Self {
4105        Self {
4106            paint: paint.into(),
4107            x_skew_angle,
4108            y_skew_angle,
4109        }
4110    }
4111}
4112
4113impl FontWrite for PaintSkew {
4114    #[allow(clippy::unnecessary_cast)]
4115    fn write_into(&self, writer: &mut TableWriter) {
4116        (28 as u8).write_into(writer);
4117        self.paint.write_into(writer);
4118        self.x_skew_angle.write_into(writer);
4119        self.y_skew_angle.write_into(writer);
4120    }
4121    fn table_type(&self) -> TableType {
4122        TableType::Named("PaintSkew")
4123    }
4124}
4125
4126impl Validate for PaintSkew {
4127    fn validate_impl(&self, ctx: &mut ValidationCtx) {
4128        ctx.in_table("PaintSkew", |ctx| {
4129            ctx.in_field("paint", |ctx| {
4130                self.paint.validate_impl(ctx);
4131            });
4132        })
4133    }
4134}
4135
4136impl<'a> FromObjRef<read_fonts::tables::colr::PaintSkew<'a>> for PaintSkew {
4137    fn from_obj_ref(obj: &read_fonts::tables::colr::PaintSkew<'a>, _: FontData) -> Self {
4138        PaintSkew {
4139            paint: obj.paint().to_owned_table(),
4140            x_skew_angle: obj.x_skew_angle(),
4141            y_skew_angle: obj.y_skew_angle(),
4142        }
4143    }
4144}
4145
4146#[allow(clippy::needless_lifetimes)]
4147impl<'a> FromTableRef<read_fonts::tables::colr::PaintSkew<'a>> for PaintSkew {}
4148
4149impl<'a> FontRead<'a> for PaintSkew {
4150    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
4151        <read_fonts::tables::colr::PaintSkew as FontRead>::read(data).map(|x| x.to_owned_table())
4152    }
4153}
4154
4155/// [PaintVarSkew](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-28-to-31-paintskew-paintvarskew-paintskewaroundcenter-paintvarskewaroundcenter) table
4156#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
4157#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4158pub struct PaintVarSkew {
4159    /// Offset to a Paint subtable.
4160    pub paint: OffsetMarker<Paint, WIDTH_24>,
4161    /// Angle of skew in the direction of the x-axis, 180° ┬░ in
4162    /// counter-clockwise degrees per 1.0 of value. For variation, use
4163    /// varIndexBase + 0.
4164    pub x_skew_angle: F2Dot14,
4165    /// Angle of skew in the direction of the y-axis, 180° in
4166    /// counter-clockwise degrees per 1.0 of value. For variation, use
4167    /// varIndexBase + 1.
4168    pub y_skew_angle: F2Dot14,
4169    /// Base index into DeltaSetIndexMap.
4170    pub var_index_base: u32,
4171}
4172
4173impl PaintVarSkew {
4174    /// Construct a new `PaintVarSkew`
4175    pub fn new(
4176        paint: Paint,
4177        x_skew_angle: F2Dot14,
4178        y_skew_angle: F2Dot14,
4179        var_index_base: u32,
4180    ) -> Self {
4181        Self {
4182            paint: paint.into(),
4183            x_skew_angle,
4184            y_skew_angle,
4185            var_index_base,
4186        }
4187    }
4188}
4189
4190impl FontWrite for PaintVarSkew {
4191    #[allow(clippy::unnecessary_cast)]
4192    fn write_into(&self, writer: &mut TableWriter) {
4193        (29 as u8).write_into(writer);
4194        self.paint.write_into(writer);
4195        self.x_skew_angle.write_into(writer);
4196        self.y_skew_angle.write_into(writer);
4197        self.var_index_base.write_into(writer);
4198    }
4199    fn table_type(&self) -> TableType {
4200        TableType::Named("PaintVarSkew")
4201    }
4202}
4203
4204impl Validate for PaintVarSkew {
4205    fn validate_impl(&self, ctx: &mut ValidationCtx) {
4206        ctx.in_table("PaintVarSkew", |ctx| {
4207            ctx.in_field("paint", |ctx| {
4208                self.paint.validate_impl(ctx);
4209            });
4210        })
4211    }
4212}
4213
4214impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarSkew<'a>> for PaintVarSkew {
4215    fn from_obj_ref(obj: &read_fonts::tables::colr::PaintVarSkew<'a>, _: FontData) -> Self {
4216        PaintVarSkew {
4217            paint: obj.paint().to_owned_table(),
4218            x_skew_angle: obj.x_skew_angle(),
4219            y_skew_angle: obj.y_skew_angle(),
4220            var_index_base: obj.var_index_base(),
4221        }
4222    }
4223}
4224
4225#[allow(clippy::needless_lifetimes)]
4226impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarSkew<'a>> for PaintVarSkew {}
4227
4228impl<'a> FontRead<'a> for PaintVarSkew {
4229    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
4230        <read_fonts::tables::colr::PaintVarSkew as FontRead>::read(data).map(|x| x.to_owned_table())
4231    }
4232}
4233
4234/// [PaintSkewAroundCenter](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-28-to-31-paintskew-paintvarskew-paintskewaroundcenter-paintvarskewaroundcenter) table
4235#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
4236#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4237pub struct PaintSkewAroundCenter {
4238    /// Offset to a Paint subtable.
4239    pub paint: OffsetMarker<Paint, WIDTH_24>,
4240    /// Angle of skew in the direction of the x-axis, 180° in
4241    /// counter-clockwise degrees per 1.0 of value.
4242    pub x_skew_angle: F2Dot14,
4243    /// Angle of skew in the direction of the y-axis, 180° in
4244    /// counter-clockwise degrees per 1.0 of value.
4245    pub y_skew_angle: F2Dot14,
4246    /// x coordinate for the center of rotation.
4247    pub center_x: FWord,
4248    /// y coordinate for the center of rotation.
4249    pub center_y: FWord,
4250}
4251
4252impl PaintSkewAroundCenter {
4253    /// Construct a new `PaintSkewAroundCenter`
4254    pub fn new(
4255        paint: Paint,
4256        x_skew_angle: F2Dot14,
4257        y_skew_angle: F2Dot14,
4258        center_x: FWord,
4259        center_y: FWord,
4260    ) -> Self {
4261        Self {
4262            paint: paint.into(),
4263            x_skew_angle,
4264            y_skew_angle,
4265            center_x,
4266            center_y,
4267        }
4268    }
4269}
4270
4271impl FontWrite for PaintSkewAroundCenter {
4272    #[allow(clippy::unnecessary_cast)]
4273    fn write_into(&self, writer: &mut TableWriter) {
4274        (30 as u8).write_into(writer);
4275        self.paint.write_into(writer);
4276        self.x_skew_angle.write_into(writer);
4277        self.y_skew_angle.write_into(writer);
4278        self.center_x.write_into(writer);
4279        self.center_y.write_into(writer);
4280    }
4281    fn table_type(&self) -> TableType {
4282        TableType::Named("PaintSkewAroundCenter")
4283    }
4284}
4285
4286impl Validate for PaintSkewAroundCenter {
4287    fn validate_impl(&self, ctx: &mut ValidationCtx) {
4288        ctx.in_table("PaintSkewAroundCenter", |ctx| {
4289            ctx.in_field("paint", |ctx| {
4290                self.paint.validate_impl(ctx);
4291            });
4292        })
4293    }
4294}
4295
4296impl<'a> FromObjRef<read_fonts::tables::colr::PaintSkewAroundCenter<'a>> for PaintSkewAroundCenter {
4297    fn from_obj_ref(
4298        obj: &read_fonts::tables::colr::PaintSkewAroundCenter<'a>,
4299        _: FontData,
4300    ) -> Self {
4301        PaintSkewAroundCenter {
4302            paint: obj.paint().to_owned_table(),
4303            x_skew_angle: obj.x_skew_angle(),
4304            y_skew_angle: obj.y_skew_angle(),
4305            center_x: obj.center_x(),
4306            center_y: obj.center_y(),
4307        }
4308    }
4309}
4310
4311#[allow(clippy::needless_lifetimes)]
4312impl<'a> FromTableRef<read_fonts::tables::colr::PaintSkewAroundCenter<'a>>
4313    for PaintSkewAroundCenter
4314{
4315}
4316
4317impl<'a> FontRead<'a> for PaintSkewAroundCenter {
4318    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
4319        <read_fonts::tables::colr::PaintSkewAroundCenter as FontRead>::read(data)
4320            .map(|x| x.to_owned_table())
4321    }
4322}
4323
4324/// [PaintVarSkewAroundCenter](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#formats-28-to-31-paintskew-paintvarskew-paintskewaroundcenter-paintvarskewaroundcenter) table
4325#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
4326#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4327pub struct PaintVarSkewAroundCenter {
4328    /// Offset to a Paint subtable.
4329    pub paint: OffsetMarker<Paint, WIDTH_24>,
4330    /// Angle of skew in the direction of the x-axis, 180° in
4331    /// counter-clockwise degrees per 1.0 of value. For variation, use
4332    /// varIndexBase + 0.
4333    pub x_skew_angle: F2Dot14,
4334    /// Angle of skew in the direction of the y-axis, 180° in
4335    /// counter-clockwise degrees per 1.0 of value. For variation, use
4336    /// varIndexBase + 1.
4337    pub y_skew_angle: F2Dot14,
4338    /// x coordinate for the center of rotation. For variation, use
4339    /// varIndexBase + 2.
4340    pub center_x: FWord,
4341    /// y coordinate for the center of rotation. For variation, use
4342    /// varIndexBase + 3.
4343    pub center_y: FWord,
4344    /// Base index into DeltaSetIndexMap.
4345    pub var_index_base: u32,
4346}
4347
4348impl PaintVarSkewAroundCenter {
4349    /// Construct a new `PaintVarSkewAroundCenter`
4350    pub fn new(
4351        paint: Paint,
4352        x_skew_angle: F2Dot14,
4353        y_skew_angle: F2Dot14,
4354        center_x: FWord,
4355        center_y: FWord,
4356        var_index_base: u32,
4357    ) -> Self {
4358        Self {
4359            paint: paint.into(),
4360            x_skew_angle,
4361            y_skew_angle,
4362            center_x,
4363            center_y,
4364            var_index_base,
4365        }
4366    }
4367}
4368
4369impl FontWrite for PaintVarSkewAroundCenter {
4370    #[allow(clippy::unnecessary_cast)]
4371    fn write_into(&self, writer: &mut TableWriter) {
4372        (31 as u8).write_into(writer);
4373        self.paint.write_into(writer);
4374        self.x_skew_angle.write_into(writer);
4375        self.y_skew_angle.write_into(writer);
4376        self.center_x.write_into(writer);
4377        self.center_y.write_into(writer);
4378        self.var_index_base.write_into(writer);
4379    }
4380    fn table_type(&self) -> TableType {
4381        TableType::Named("PaintVarSkewAroundCenter")
4382    }
4383}
4384
4385impl Validate for PaintVarSkewAroundCenter {
4386    fn validate_impl(&self, ctx: &mut ValidationCtx) {
4387        ctx.in_table("PaintVarSkewAroundCenter", |ctx| {
4388            ctx.in_field("paint", |ctx| {
4389                self.paint.validate_impl(ctx);
4390            });
4391        })
4392    }
4393}
4394
4395impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarSkewAroundCenter<'a>>
4396    for PaintVarSkewAroundCenter
4397{
4398    fn from_obj_ref(
4399        obj: &read_fonts::tables::colr::PaintVarSkewAroundCenter<'a>,
4400        _: FontData,
4401    ) -> Self {
4402        PaintVarSkewAroundCenter {
4403            paint: obj.paint().to_owned_table(),
4404            x_skew_angle: obj.x_skew_angle(),
4405            y_skew_angle: obj.y_skew_angle(),
4406            center_x: obj.center_x(),
4407            center_y: obj.center_y(),
4408            var_index_base: obj.var_index_base(),
4409        }
4410    }
4411}
4412
4413#[allow(clippy::needless_lifetimes)]
4414impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarSkewAroundCenter<'a>>
4415    for PaintVarSkewAroundCenter
4416{
4417}
4418
4419impl<'a> FontRead<'a> for PaintVarSkewAroundCenter {
4420    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
4421        <read_fonts::tables::colr::PaintVarSkewAroundCenter as FontRead>::read(data)
4422            .map(|x| x.to_owned_table())
4423    }
4424}
4425
4426/// [PaintComposite](https://learn.microsoft.com/en-us/typography/opentype/spec/colr#format-32-paintcomposite) table
4427#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
4428#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4429pub struct PaintComposite {
4430    /// Offset to a source Paint table.
4431    pub source_paint: OffsetMarker<Paint, WIDTH_24>,
4432    /// A CompositeMode enumeration value.
4433    pub composite_mode: CompositeMode,
4434    /// Offset to a backdrop Paint table.
4435    pub backdrop_paint: OffsetMarker<Paint, WIDTH_24>,
4436}
4437
4438impl PaintComposite {
4439    /// Construct a new `PaintComposite`
4440    pub fn new(source_paint: Paint, composite_mode: CompositeMode, backdrop_paint: Paint) -> Self {
4441        Self {
4442            source_paint: source_paint.into(),
4443            composite_mode,
4444            backdrop_paint: backdrop_paint.into(),
4445        }
4446    }
4447}
4448
4449impl FontWrite for PaintComposite {
4450    #[allow(clippy::unnecessary_cast)]
4451    fn write_into(&self, writer: &mut TableWriter) {
4452        (32 as u8).write_into(writer);
4453        self.source_paint.write_into(writer);
4454        self.composite_mode.write_into(writer);
4455        self.backdrop_paint.write_into(writer);
4456    }
4457    fn table_type(&self) -> TableType {
4458        TableType::Named("PaintComposite")
4459    }
4460}
4461
4462impl Validate for PaintComposite {
4463    fn validate_impl(&self, ctx: &mut ValidationCtx) {
4464        ctx.in_table("PaintComposite", |ctx| {
4465            ctx.in_field("source_paint", |ctx| {
4466                self.source_paint.validate_impl(ctx);
4467            });
4468            ctx.in_field("backdrop_paint", |ctx| {
4469                self.backdrop_paint.validate_impl(ctx);
4470            });
4471        })
4472    }
4473}
4474
4475impl<'a> FromObjRef<read_fonts::tables::colr::PaintComposite<'a>> for PaintComposite {
4476    fn from_obj_ref(obj: &read_fonts::tables::colr::PaintComposite<'a>, _: FontData) -> Self {
4477        PaintComposite {
4478            source_paint: obj.source_paint().to_owned_table(),
4479            composite_mode: obj.composite_mode(),
4480            backdrop_paint: obj.backdrop_paint().to_owned_table(),
4481        }
4482    }
4483}
4484
4485#[allow(clippy::needless_lifetimes)]
4486impl<'a> FromTableRef<read_fonts::tables::colr::PaintComposite<'a>> for PaintComposite {}
4487
4488impl<'a> FontRead<'a> for PaintComposite {
4489    fn read(data: FontData<'a>) -> Result<Self, ReadError> {
4490        <read_fonts::tables::colr::PaintComposite as FontRead>::read(data)
4491            .map(|x| x.to_owned_table())
4492    }
4493}
4494
4495impl FontWrite for CompositeMode {
4496    fn write_into(&self, writer: &mut TableWriter) {
4497        let val = *self as u8;
4498        writer.write_slice(&val.to_be_bytes())
4499    }
4500}