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