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 Glyph2(PaintGlyph2),
1168}
1169
1170impl Paint {
1171 pub fn colr_layers(num_layers: u8, first_layer_index: u32) -> Self {
1173 Self::ColrLayers(PaintColrLayers::new(num_layers, first_layer_index))
1174 }
1175
1176 pub fn solid(palette_index: u16, alpha: F2Dot14) -> Self {
1178 Self::Solid(PaintSolid::new(palette_index, alpha))
1179 }
1180
1181 pub fn var_solid(palette_index: u16, alpha: F2Dot14, var_index_base: u32) -> Self {
1183 Self::VarSolid(PaintVarSolid::new(palette_index, alpha, var_index_base))
1184 }
1185
1186 pub fn linear_gradient(
1188 color_line: ColorLine,
1189 x0: FWord,
1190 y0: FWord,
1191 x1: FWord,
1192 y1: FWord,
1193 x2: FWord,
1194 y2: FWord,
1195 ) -> Self {
1196 Self::LinearGradient(PaintLinearGradient::new(color_line, x0, y0, x1, y1, x2, y2))
1197 }
1198
1199 #[allow(clippy::too_many_arguments)]
1201 pub fn var_linear_gradient(
1202 color_line: VarColorLine,
1203 x0: FWord,
1204 y0: FWord,
1205 x1: FWord,
1206 y1: FWord,
1207 x2: FWord,
1208 y2: FWord,
1209 var_index_base: u32,
1210 ) -> Self {
1211 Self::VarLinearGradient(PaintVarLinearGradient::new(
1212 color_line,
1213 x0,
1214 y0,
1215 x1,
1216 y1,
1217 x2,
1218 y2,
1219 var_index_base,
1220 ))
1221 }
1222
1223 pub fn radial_gradient(
1225 color_line: ColorLine,
1226 x0: FWord,
1227 y0: FWord,
1228 radius0: UfWord,
1229 x1: FWord,
1230 y1: FWord,
1231 radius1: UfWord,
1232 ) -> Self {
1233 Self::RadialGradient(PaintRadialGradient::new(
1234 color_line, x0, y0, radius0, x1, y1, radius1,
1235 ))
1236 }
1237
1238 #[allow(clippy::too_many_arguments)]
1240 pub fn var_radial_gradient(
1241 color_line: VarColorLine,
1242 x0: FWord,
1243 y0: FWord,
1244 radius0: UfWord,
1245 x1: FWord,
1246 y1: FWord,
1247 radius1: UfWord,
1248 var_index_base: u32,
1249 ) -> Self {
1250 Self::VarRadialGradient(PaintVarRadialGradient::new(
1251 color_line,
1252 x0,
1253 y0,
1254 radius0,
1255 x1,
1256 y1,
1257 radius1,
1258 var_index_base,
1259 ))
1260 }
1261
1262 pub fn sweep_gradient(
1264 color_line: ColorLine,
1265 center_x: FWord,
1266 center_y: FWord,
1267 start_angle: F2Dot14,
1268 end_angle: F2Dot14,
1269 ) -> Self {
1270 Self::SweepGradient(PaintSweepGradient::new(
1271 color_line,
1272 center_x,
1273 center_y,
1274 start_angle,
1275 end_angle,
1276 ))
1277 }
1278
1279 pub fn var_sweep_gradient(
1281 color_line: VarColorLine,
1282 center_x: FWord,
1283 center_y: FWord,
1284 start_angle: F2Dot14,
1285 end_angle: F2Dot14,
1286 var_index_base: u32,
1287 ) -> Self {
1288 Self::VarSweepGradient(PaintVarSweepGradient::new(
1289 color_line,
1290 center_x,
1291 center_y,
1292 start_angle,
1293 end_angle,
1294 var_index_base,
1295 ))
1296 }
1297
1298 pub fn glyph(paint: Paint, glyph_id: GlyphId16) -> Self {
1300 Self::Glyph(PaintGlyph::new(paint, glyph_id))
1301 }
1302
1303 pub fn colr_glyph(glyph_id: GlyphId16) -> Self {
1305 Self::ColrGlyph(PaintColrGlyph::new(glyph_id))
1306 }
1307
1308 pub fn transform(paint: Paint, transform: Affine2x3) -> Self {
1310 Self::Transform(PaintTransform::new(paint, transform))
1311 }
1312
1313 pub fn var_transform(paint: Paint, transform: VarAffine2x3) -> Self {
1315 Self::VarTransform(PaintVarTransform::new(paint, transform))
1316 }
1317
1318 pub fn translate(paint: Paint, dx: FWord, dy: FWord) -> Self {
1320 Self::Translate(PaintTranslate::new(paint, dx, dy))
1321 }
1322
1323 pub fn var_translate(paint: Paint, dx: FWord, dy: FWord, var_index_base: u32) -> Self {
1325 Self::VarTranslate(PaintVarTranslate::new(paint, dx, dy, var_index_base))
1326 }
1327
1328 pub fn scale(paint: Paint, scale_x: F2Dot14, scale_y: F2Dot14) -> Self {
1330 Self::Scale(PaintScale::new(paint, scale_x, scale_y))
1331 }
1332
1333 pub fn var_scale(
1335 paint: Paint,
1336 scale_x: F2Dot14,
1337 scale_y: F2Dot14,
1338 var_index_base: u32,
1339 ) -> Self {
1340 Self::VarScale(PaintVarScale::new(paint, scale_x, scale_y, var_index_base))
1341 }
1342
1343 pub fn scale_around_center(
1345 paint: Paint,
1346 scale_x: F2Dot14,
1347 scale_y: F2Dot14,
1348 center_x: FWord,
1349 center_y: FWord,
1350 ) -> Self {
1351 Self::ScaleAroundCenter(PaintScaleAroundCenter::new(
1352 paint, scale_x, scale_y, center_x, center_y,
1353 ))
1354 }
1355
1356 pub fn var_scale_around_center(
1358 paint: Paint,
1359 scale_x: F2Dot14,
1360 scale_y: F2Dot14,
1361 center_x: FWord,
1362 center_y: FWord,
1363 var_index_base: u32,
1364 ) -> Self {
1365 Self::VarScaleAroundCenter(PaintVarScaleAroundCenter::new(
1366 paint,
1367 scale_x,
1368 scale_y,
1369 center_x,
1370 center_y,
1371 var_index_base,
1372 ))
1373 }
1374
1375 pub fn scale_uniform(paint: Paint, scale: F2Dot14) -> Self {
1377 Self::ScaleUniform(PaintScaleUniform::new(paint, scale))
1378 }
1379
1380 pub fn var_scale_uniform(paint: Paint, scale: F2Dot14, var_index_base: u32) -> Self {
1382 Self::VarScaleUniform(PaintVarScaleUniform::new(paint, scale, var_index_base))
1383 }
1384
1385 pub fn scale_uniform_around_center(
1387 paint: Paint,
1388 scale: F2Dot14,
1389 center_x: FWord,
1390 center_y: FWord,
1391 ) -> Self {
1392 Self::ScaleUniformAroundCenter(PaintScaleUniformAroundCenter::new(
1393 paint, scale, center_x, center_y,
1394 ))
1395 }
1396
1397 pub fn var_scale_uniform_around_center(
1399 paint: Paint,
1400 scale: F2Dot14,
1401 center_x: FWord,
1402 center_y: FWord,
1403 var_index_base: u32,
1404 ) -> Self {
1405 Self::VarScaleUniformAroundCenter(PaintVarScaleUniformAroundCenter::new(
1406 paint,
1407 scale,
1408 center_x,
1409 center_y,
1410 var_index_base,
1411 ))
1412 }
1413
1414 pub fn rotate(paint: Paint, angle: F2Dot14) -> Self {
1416 Self::Rotate(PaintRotate::new(paint, angle))
1417 }
1418
1419 pub fn var_rotate(paint: Paint, angle: F2Dot14, var_index_base: u32) -> Self {
1421 Self::VarRotate(PaintVarRotate::new(paint, angle, var_index_base))
1422 }
1423
1424 pub fn rotate_around_center(
1426 paint: Paint,
1427 angle: F2Dot14,
1428 center_x: FWord,
1429 center_y: FWord,
1430 ) -> Self {
1431 Self::RotateAroundCenter(PaintRotateAroundCenter::new(
1432 paint, angle, center_x, center_y,
1433 ))
1434 }
1435
1436 pub fn var_rotate_around_center(
1438 paint: Paint,
1439 angle: F2Dot14,
1440 center_x: FWord,
1441 center_y: FWord,
1442 var_index_base: u32,
1443 ) -> Self {
1444 Self::VarRotateAroundCenter(PaintVarRotateAroundCenter::new(
1445 paint,
1446 angle,
1447 center_x,
1448 center_y,
1449 var_index_base,
1450 ))
1451 }
1452
1453 pub fn skew(paint: Paint, x_skew_angle: F2Dot14, y_skew_angle: F2Dot14) -> Self {
1455 Self::Skew(PaintSkew::new(paint, x_skew_angle, y_skew_angle))
1456 }
1457
1458 pub fn var_skew(
1460 paint: Paint,
1461 x_skew_angle: F2Dot14,
1462 y_skew_angle: F2Dot14,
1463 var_index_base: u32,
1464 ) -> Self {
1465 Self::VarSkew(PaintVarSkew::new(
1466 paint,
1467 x_skew_angle,
1468 y_skew_angle,
1469 var_index_base,
1470 ))
1471 }
1472
1473 pub fn skew_around_center(
1475 paint: Paint,
1476 x_skew_angle: F2Dot14,
1477 y_skew_angle: F2Dot14,
1478 center_x: FWord,
1479 center_y: FWord,
1480 ) -> Self {
1481 Self::SkewAroundCenter(PaintSkewAroundCenter::new(
1482 paint,
1483 x_skew_angle,
1484 y_skew_angle,
1485 center_x,
1486 center_y,
1487 ))
1488 }
1489
1490 pub fn var_skew_around_center(
1492 paint: Paint,
1493 x_skew_angle: F2Dot14,
1494 y_skew_angle: F2Dot14,
1495 center_x: FWord,
1496 center_y: FWord,
1497 var_index_base: u32,
1498 ) -> Self {
1499 Self::VarSkewAroundCenter(PaintVarSkewAroundCenter::new(
1500 paint,
1501 x_skew_angle,
1502 y_skew_angle,
1503 center_x,
1504 center_y,
1505 var_index_base,
1506 ))
1507 }
1508
1509 pub fn composite(
1511 source_paint: Paint,
1512 composite_mode: CompositeMode,
1513 backdrop_paint: Paint,
1514 ) -> Self {
1515 Self::Composite(PaintComposite::new(
1516 source_paint,
1517 composite_mode,
1518 backdrop_paint,
1519 ))
1520 }
1521
1522 pub fn glyph_2(paint: Paint, glyph_id: GlyphId24) -> Self {
1524 Self::Glyph2(PaintGlyph2::new(paint, glyph_id))
1525 }
1526}
1527
1528impl Default for Paint {
1529 fn default() -> Self {
1530 Self::ColrLayers(Default::default())
1531 }
1532}
1533
1534impl FontWrite for Paint {
1535 fn write_into(&self, writer: &mut TableWriter) {
1536 match self {
1537 Self::ColrLayers(item) => item.write_into(writer),
1538 Self::Solid(item) => item.write_into(writer),
1539 Self::VarSolid(item) => item.write_into(writer),
1540 Self::LinearGradient(item) => item.write_into(writer),
1541 Self::VarLinearGradient(item) => item.write_into(writer),
1542 Self::RadialGradient(item) => item.write_into(writer),
1543 Self::VarRadialGradient(item) => item.write_into(writer),
1544 Self::SweepGradient(item) => item.write_into(writer),
1545 Self::VarSweepGradient(item) => item.write_into(writer),
1546 Self::Glyph(item) => item.write_into(writer),
1547 Self::ColrGlyph(item) => item.write_into(writer),
1548 Self::Transform(item) => item.write_into(writer),
1549 Self::VarTransform(item) => item.write_into(writer),
1550 Self::Translate(item) => item.write_into(writer),
1551 Self::VarTranslate(item) => item.write_into(writer),
1552 Self::Scale(item) => item.write_into(writer),
1553 Self::VarScale(item) => item.write_into(writer),
1554 Self::ScaleAroundCenter(item) => item.write_into(writer),
1555 Self::VarScaleAroundCenter(item) => item.write_into(writer),
1556 Self::ScaleUniform(item) => item.write_into(writer),
1557 Self::VarScaleUniform(item) => item.write_into(writer),
1558 Self::ScaleUniformAroundCenter(item) => item.write_into(writer),
1559 Self::VarScaleUniformAroundCenter(item) => item.write_into(writer),
1560 Self::Rotate(item) => item.write_into(writer),
1561 Self::VarRotate(item) => item.write_into(writer),
1562 Self::RotateAroundCenter(item) => item.write_into(writer),
1563 Self::VarRotateAroundCenter(item) => item.write_into(writer),
1564 Self::Skew(item) => item.write_into(writer),
1565 Self::VarSkew(item) => item.write_into(writer),
1566 Self::SkewAroundCenter(item) => item.write_into(writer),
1567 Self::VarSkewAroundCenter(item) => item.write_into(writer),
1568 Self::Composite(item) => item.write_into(writer),
1569 Self::Glyph2(item) => item.write_into(writer),
1570 }
1571 }
1572 fn table_type(&self) -> TableType {
1573 match self {
1574 Self::ColrLayers(item) => item.table_type(),
1575 Self::Solid(item) => item.table_type(),
1576 Self::VarSolid(item) => item.table_type(),
1577 Self::LinearGradient(item) => item.table_type(),
1578 Self::VarLinearGradient(item) => item.table_type(),
1579 Self::RadialGradient(item) => item.table_type(),
1580 Self::VarRadialGradient(item) => item.table_type(),
1581 Self::SweepGradient(item) => item.table_type(),
1582 Self::VarSweepGradient(item) => item.table_type(),
1583 Self::Glyph(item) => item.table_type(),
1584 Self::ColrGlyph(item) => item.table_type(),
1585 Self::Transform(item) => item.table_type(),
1586 Self::VarTransform(item) => item.table_type(),
1587 Self::Translate(item) => item.table_type(),
1588 Self::VarTranslate(item) => item.table_type(),
1589 Self::Scale(item) => item.table_type(),
1590 Self::VarScale(item) => item.table_type(),
1591 Self::ScaleAroundCenter(item) => item.table_type(),
1592 Self::VarScaleAroundCenter(item) => item.table_type(),
1593 Self::ScaleUniform(item) => item.table_type(),
1594 Self::VarScaleUniform(item) => item.table_type(),
1595 Self::ScaleUniformAroundCenter(item) => item.table_type(),
1596 Self::VarScaleUniformAroundCenter(item) => item.table_type(),
1597 Self::Rotate(item) => item.table_type(),
1598 Self::VarRotate(item) => item.table_type(),
1599 Self::RotateAroundCenter(item) => item.table_type(),
1600 Self::VarRotateAroundCenter(item) => item.table_type(),
1601 Self::Skew(item) => item.table_type(),
1602 Self::VarSkew(item) => item.table_type(),
1603 Self::SkewAroundCenter(item) => item.table_type(),
1604 Self::VarSkewAroundCenter(item) => item.table_type(),
1605 Self::Composite(item) => item.table_type(),
1606 Self::Glyph2(item) => item.table_type(),
1607 }
1608 }
1609}
1610
1611impl Validate for Paint {
1612 fn validate_impl(&self, ctx: &mut ValidationCtx) {
1613 match self {
1614 Self::ColrLayers(item) => item.validate_impl(ctx),
1615 Self::Solid(item) => item.validate_impl(ctx),
1616 Self::VarSolid(item) => item.validate_impl(ctx),
1617 Self::LinearGradient(item) => item.validate_impl(ctx),
1618 Self::VarLinearGradient(item) => item.validate_impl(ctx),
1619 Self::RadialGradient(item) => item.validate_impl(ctx),
1620 Self::VarRadialGradient(item) => item.validate_impl(ctx),
1621 Self::SweepGradient(item) => item.validate_impl(ctx),
1622 Self::VarSweepGradient(item) => item.validate_impl(ctx),
1623 Self::Glyph(item) => item.validate_impl(ctx),
1624 Self::ColrGlyph(item) => item.validate_impl(ctx),
1625 Self::Transform(item) => item.validate_impl(ctx),
1626 Self::VarTransform(item) => item.validate_impl(ctx),
1627 Self::Translate(item) => item.validate_impl(ctx),
1628 Self::VarTranslate(item) => item.validate_impl(ctx),
1629 Self::Scale(item) => item.validate_impl(ctx),
1630 Self::VarScale(item) => item.validate_impl(ctx),
1631 Self::ScaleAroundCenter(item) => item.validate_impl(ctx),
1632 Self::VarScaleAroundCenter(item) => item.validate_impl(ctx),
1633 Self::ScaleUniform(item) => item.validate_impl(ctx),
1634 Self::VarScaleUniform(item) => item.validate_impl(ctx),
1635 Self::ScaleUniformAroundCenter(item) => item.validate_impl(ctx),
1636 Self::VarScaleUniformAroundCenter(item) => item.validate_impl(ctx),
1637 Self::Rotate(item) => item.validate_impl(ctx),
1638 Self::VarRotate(item) => item.validate_impl(ctx),
1639 Self::RotateAroundCenter(item) => item.validate_impl(ctx),
1640 Self::VarRotateAroundCenter(item) => item.validate_impl(ctx),
1641 Self::Skew(item) => item.validate_impl(ctx),
1642 Self::VarSkew(item) => item.validate_impl(ctx),
1643 Self::SkewAroundCenter(item) => item.validate_impl(ctx),
1644 Self::VarSkewAroundCenter(item) => item.validate_impl(ctx),
1645 Self::Composite(item) => item.validate_impl(ctx),
1646 Self::Glyph2(item) => item.validate_impl(ctx),
1647 }
1648 }
1649}
1650
1651impl FromObjRef<read_fonts::tables::colr::Paint<'_>> for Paint {
1652 fn from_obj_ref(obj: &read_fonts::tables::colr::Paint, _: FontData) -> Self {
1653 use read_fonts::tables::colr::Paint as ObjRefType;
1654 match obj {
1655 ObjRefType::ColrLayers(item) => Paint::ColrLayers(item.to_owned_table()),
1656 ObjRefType::Solid(item) => Paint::Solid(item.to_owned_table()),
1657 ObjRefType::VarSolid(item) => Paint::VarSolid(item.to_owned_table()),
1658 ObjRefType::LinearGradient(item) => Paint::LinearGradient(item.to_owned_table()),
1659 ObjRefType::VarLinearGradient(item) => Paint::VarLinearGradient(item.to_owned_table()),
1660 ObjRefType::RadialGradient(item) => Paint::RadialGradient(item.to_owned_table()),
1661 ObjRefType::VarRadialGradient(item) => Paint::VarRadialGradient(item.to_owned_table()),
1662 ObjRefType::SweepGradient(item) => Paint::SweepGradient(item.to_owned_table()),
1663 ObjRefType::VarSweepGradient(item) => Paint::VarSweepGradient(item.to_owned_table()),
1664 ObjRefType::Glyph(item) => Paint::Glyph(item.to_owned_table()),
1665 ObjRefType::ColrGlyph(item) => Paint::ColrGlyph(item.to_owned_table()),
1666 ObjRefType::Transform(item) => Paint::Transform(item.to_owned_table()),
1667 ObjRefType::VarTransform(item) => Paint::VarTransform(item.to_owned_table()),
1668 ObjRefType::Translate(item) => Paint::Translate(item.to_owned_table()),
1669 ObjRefType::VarTranslate(item) => Paint::VarTranslate(item.to_owned_table()),
1670 ObjRefType::Scale(item) => Paint::Scale(item.to_owned_table()),
1671 ObjRefType::VarScale(item) => Paint::VarScale(item.to_owned_table()),
1672 ObjRefType::ScaleAroundCenter(item) => Paint::ScaleAroundCenter(item.to_owned_table()),
1673 ObjRefType::VarScaleAroundCenter(item) => {
1674 Paint::VarScaleAroundCenter(item.to_owned_table())
1675 }
1676 ObjRefType::ScaleUniform(item) => Paint::ScaleUniform(item.to_owned_table()),
1677 ObjRefType::VarScaleUniform(item) => Paint::VarScaleUniform(item.to_owned_table()),
1678 ObjRefType::ScaleUniformAroundCenter(item) => {
1679 Paint::ScaleUniformAroundCenter(item.to_owned_table())
1680 }
1681 ObjRefType::VarScaleUniformAroundCenter(item) => {
1682 Paint::VarScaleUniformAroundCenter(item.to_owned_table())
1683 }
1684 ObjRefType::Rotate(item) => Paint::Rotate(item.to_owned_table()),
1685 ObjRefType::VarRotate(item) => Paint::VarRotate(item.to_owned_table()),
1686 ObjRefType::RotateAroundCenter(item) => {
1687 Paint::RotateAroundCenter(item.to_owned_table())
1688 }
1689 ObjRefType::VarRotateAroundCenter(item) => {
1690 Paint::VarRotateAroundCenter(item.to_owned_table())
1691 }
1692 ObjRefType::Skew(item) => Paint::Skew(item.to_owned_table()),
1693 ObjRefType::VarSkew(item) => Paint::VarSkew(item.to_owned_table()),
1694 ObjRefType::SkewAroundCenter(item) => Paint::SkewAroundCenter(item.to_owned_table()),
1695 ObjRefType::VarSkewAroundCenter(item) => {
1696 Paint::VarSkewAroundCenter(item.to_owned_table())
1697 }
1698 ObjRefType::Composite(item) => Paint::Composite(item.to_owned_table()),
1699 ObjRefType::Glyph2(item) => Paint::Glyph2(item.to_owned_table()),
1700 }
1701 }
1702}
1703
1704impl FromTableRef<read_fonts::tables::colr::Paint<'_>> for Paint {}
1705
1706impl ReadArgs for Paint {
1707 type Args = ();
1708}
1709
1710impl<'a> FontRead<'a> for Paint {
1711 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
1712 <read_fonts::tables::colr::Paint as FontRead>::read(data).map(|x| x.to_owned_table())
1713 }
1714}
1715
1716impl From<PaintColrLayers> for Paint {
1717 fn from(src: PaintColrLayers) -> Paint {
1718 Paint::ColrLayers(src)
1719 }
1720}
1721
1722impl From<PaintSolid> for Paint {
1723 fn from(src: PaintSolid) -> Paint {
1724 Paint::Solid(src)
1725 }
1726}
1727
1728impl From<PaintVarSolid> for Paint {
1729 fn from(src: PaintVarSolid) -> Paint {
1730 Paint::VarSolid(src)
1731 }
1732}
1733
1734impl From<PaintLinearGradient> for Paint {
1735 fn from(src: PaintLinearGradient) -> Paint {
1736 Paint::LinearGradient(src)
1737 }
1738}
1739
1740impl From<PaintVarLinearGradient> for Paint {
1741 fn from(src: PaintVarLinearGradient) -> Paint {
1742 Paint::VarLinearGradient(src)
1743 }
1744}
1745
1746impl From<PaintRadialGradient> for Paint {
1747 fn from(src: PaintRadialGradient) -> Paint {
1748 Paint::RadialGradient(src)
1749 }
1750}
1751
1752impl From<PaintVarRadialGradient> for Paint {
1753 fn from(src: PaintVarRadialGradient) -> Paint {
1754 Paint::VarRadialGradient(src)
1755 }
1756}
1757
1758impl From<PaintSweepGradient> for Paint {
1759 fn from(src: PaintSweepGradient) -> Paint {
1760 Paint::SweepGradient(src)
1761 }
1762}
1763
1764impl From<PaintVarSweepGradient> for Paint {
1765 fn from(src: PaintVarSweepGradient) -> Paint {
1766 Paint::VarSweepGradient(src)
1767 }
1768}
1769
1770impl From<PaintGlyph> for Paint {
1771 fn from(src: PaintGlyph) -> Paint {
1772 Paint::Glyph(src)
1773 }
1774}
1775
1776impl From<PaintColrGlyph> for Paint {
1777 fn from(src: PaintColrGlyph) -> Paint {
1778 Paint::ColrGlyph(src)
1779 }
1780}
1781
1782impl From<PaintTransform> for Paint {
1783 fn from(src: PaintTransform) -> Paint {
1784 Paint::Transform(src)
1785 }
1786}
1787
1788impl From<PaintVarTransform> for Paint {
1789 fn from(src: PaintVarTransform) -> Paint {
1790 Paint::VarTransform(src)
1791 }
1792}
1793
1794impl From<PaintTranslate> for Paint {
1795 fn from(src: PaintTranslate) -> Paint {
1796 Paint::Translate(src)
1797 }
1798}
1799
1800impl From<PaintVarTranslate> for Paint {
1801 fn from(src: PaintVarTranslate) -> Paint {
1802 Paint::VarTranslate(src)
1803 }
1804}
1805
1806impl From<PaintScale> for Paint {
1807 fn from(src: PaintScale) -> Paint {
1808 Paint::Scale(src)
1809 }
1810}
1811
1812impl From<PaintVarScale> for Paint {
1813 fn from(src: PaintVarScale) -> Paint {
1814 Paint::VarScale(src)
1815 }
1816}
1817
1818impl From<PaintScaleAroundCenter> for Paint {
1819 fn from(src: PaintScaleAroundCenter) -> Paint {
1820 Paint::ScaleAroundCenter(src)
1821 }
1822}
1823
1824impl From<PaintVarScaleAroundCenter> for Paint {
1825 fn from(src: PaintVarScaleAroundCenter) -> Paint {
1826 Paint::VarScaleAroundCenter(src)
1827 }
1828}
1829
1830impl From<PaintScaleUniform> for Paint {
1831 fn from(src: PaintScaleUniform) -> Paint {
1832 Paint::ScaleUniform(src)
1833 }
1834}
1835
1836impl From<PaintVarScaleUniform> for Paint {
1837 fn from(src: PaintVarScaleUniform) -> Paint {
1838 Paint::VarScaleUniform(src)
1839 }
1840}
1841
1842impl From<PaintScaleUniformAroundCenter> for Paint {
1843 fn from(src: PaintScaleUniformAroundCenter) -> Paint {
1844 Paint::ScaleUniformAroundCenter(src)
1845 }
1846}
1847
1848impl From<PaintVarScaleUniformAroundCenter> for Paint {
1849 fn from(src: PaintVarScaleUniformAroundCenter) -> Paint {
1850 Paint::VarScaleUniformAroundCenter(src)
1851 }
1852}
1853
1854impl From<PaintRotate> for Paint {
1855 fn from(src: PaintRotate) -> Paint {
1856 Paint::Rotate(src)
1857 }
1858}
1859
1860impl From<PaintVarRotate> for Paint {
1861 fn from(src: PaintVarRotate) -> Paint {
1862 Paint::VarRotate(src)
1863 }
1864}
1865
1866impl From<PaintRotateAroundCenter> for Paint {
1867 fn from(src: PaintRotateAroundCenter) -> Paint {
1868 Paint::RotateAroundCenter(src)
1869 }
1870}
1871
1872impl From<PaintVarRotateAroundCenter> for Paint {
1873 fn from(src: PaintVarRotateAroundCenter) -> Paint {
1874 Paint::VarRotateAroundCenter(src)
1875 }
1876}
1877
1878impl From<PaintSkew> for Paint {
1879 fn from(src: PaintSkew) -> Paint {
1880 Paint::Skew(src)
1881 }
1882}
1883
1884impl From<PaintVarSkew> for Paint {
1885 fn from(src: PaintVarSkew) -> Paint {
1886 Paint::VarSkew(src)
1887 }
1888}
1889
1890impl From<PaintSkewAroundCenter> for Paint {
1891 fn from(src: PaintSkewAroundCenter) -> Paint {
1892 Paint::SkewAroundCenter(src)
1893 }
1894}
1895
1896impl From<PaintVarSkewAroundCenter> for Paint {
1897 fn from(src: PaintVarSkewAroundCenter) -> Paint {
1898 Paint::VarSkewAroundCenter(src)
1899 }
1900}
1901
1902impl From<PaintComposite> for Paint {
1903 fn from(src: PaintComposite) -> Paint {
1904 Paint::Composite(src)
1905 }
1906}
1907
1908impl From<PaintGlyph2> for Paint {
1909 fn from(src: PaintGlyph2) -> Paint {
1910 Paint::Glyph2(src)
1911 }
1912}
1913
1914#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
1916#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1917pub struct PaintColrLayers {
1918 pub num_layers: u8,
1920 pub first_layer_index: u32,
1922}
1923
1924impl PaintColrLayers {
1925 pub fn new(num_layers: u8, first_layer_index: u32) -> Self {
1927 Self {
1928 num_layers,
1929 first_layer_index,
1930 }
1931 }
1932}
1933
1934impl FontWrite for PaintColrLayers {
1935 #[allow(clippy::unnecessary_cast)]
1936 fn write_into(&self, writer: &mut TableWriter) {
1937 (1 as u8).write_into(writer);
1938 self.num_layers.write_into(writer);
1939 self.first_layer_index.write_into(writer);
1940 }
1941 fn table_type(&self) -> TableType {
1942 TableType::Named("PaintColrLayers")
1943 }
1944}
1945
1946impl Validate for PaintColrLayers {
1947 fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
1948}
1949
1950impl<'a> FromObjRef<read_fonts::tables::colr::PaintColrLayers<'a>> for PaintColrLayers {
1951 fn from_obj_ref(obj: &read_fonts::tables::colr::PaintColrLayers<'a>, _: FontData) -> Self {
1952 PaintColrLayers {
1953 num_layers: obj.num_layers(),
1954 first_layer_index: obj.first_layer_index(),
1955 }
1956 }
1957}
1958
1959#[allow(clippy::needless_lifetimes)]
1960impl<'a> FromTableRef<read_fonts::tables::colr::PaintColrLayers<'a>> for PaintColrLayers {}
1961
1962impl ReadArgs for PaintColrLayers {
1963 type Args = ();
1964}
1965
1966impl<'a> FontRead<'a> for PaintColrLayers {
1967 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
1968 <read_fonts::tables::colr::PaintColrLayers as FontRead>::read(data)
1969 .map(|x| x.to_owned_table())
1970 }
1971}
1972
1973#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
1975#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
1976pub struct PaintSolid {
1977 pub palette_index: u16,
1979 pub alpha: F2Dot14,
1981}
1982
1983impl PaintSolid {
1984 pub fn new(palette_index: u16, alpha: F2Dot14) -> Self {
1986 Self {
1987 palette_index,
1988 alpha,
1989 }
1990 }
1991}
1992
1993impl FontWrite for PaintSolid {
1994 #[allow(clippy::unnecessary_cast)]
1995 fn write_into(&self, writer: &mut TableWriter) {
1996 (2 as u8).write_into(writer);
1997 self.palette_index.write_into(writer);
1998 self.alpha.write_into(writer);
1999 }
2000 fn table_type(&self) -> TableType {
2001 TableType::Named("PaintSolid")
2002 }
2003}
2004
2005impl Validate for PaintSolid {
2006 fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
2007}
2008
2009impl<'a> FromObjRef<read_fonts::tables::colr::PaintSolid<'a>> for PaintSolid {
2010 fn from_obj_ref(obj: &read_fonts::tables::colr::PaintSolid<'a>, _: FontData) -> Self {
2011 PaintSolid {
2012 palette_index: obj.palette_index(),
2013 alpha: obj.alpha(),
2014 }
2015 }
2016}
2017
2018#[allow(clippy::needless_lifetimes)]
2019impl<'a> FromTableRef<read_fonts::tables::colr::PaintSolid<'a>> for PaintSolid {}
2020
2021impl ReadArgs for PaintSolid {
2022 type Args = ();
2023}
2024
2025impl<'a> FontRead<'a> for PaintSolid {
2026 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
2027 <read_fonts::tables::colr::PaintSolid as FontRead>::read(data).map(|x| x.to_owned_table())
2028 }
2029}
2030
2031#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2033#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2034pub struct PaintVarSolid {
2035 pub palette_index: u16,
2037 pub alpha: F2Dot14,
2039 pub var_index_base: u32,
2041}
2042
2043impl PaintVarSolid {
2044 pub fn new(palette_index: u16, alpha: F2Dot14, var_index_base: u32) -> Self {
2046 Self {
2047 palette_index,
2048 alpha,
2049 var_index_base,
2050 }
2051 }
2052}
2053
2054impl FontWrite for PaintVarSolid {
2055 #[allow(clippy::unnecessary_cast)]
2056 fn write_into(&self, writer: &mut TableWriter) {
2057 (3 as u8).write_into(writer);
2058 self.palette_index.write_into(writer);
2059 self.alpha.write_into(writer);
2060 self.var_index_base.write_into(writer);
2061 }
2062 fn table_type(&self) -> TableType {
2063 TableType::Named("PaintVarSolid")
2064 }
2065}
2066
2067impl Validate for PaintVarSolid {
2068 fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
2069}
2070
2071impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarSolid<'a>> for PaintVarSolid {
2072 fn from_obj_ref(obj: &read_fonts::tables::colr::PaintVarSolid<'a>, _: FontData) -> Self {
2073 PaintVarSolid {
2074 palette_index: obj.palette_index(),
2075 alpha: obj.alpha(),
2076 var_index_base: obj.var_index_base(),
2077 }
2078 }
2079}
2080
2081#[allow(clippy::needless_lifetimes)]
2082impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarSolid<'a>> for PaintVarSolid {}
2083
2084impl ReadArgs for PaintVarSolid {
2085 type Args = ();
2086}
2087
2088impl<'a> FontRead<'a> for PaintVarSolid {
2089 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
2090 <read_fonts::tables::colr::PaintVarSolid as FontRead>::read(data)
2091 .map(|x| x.to_owned_table())
2092 }
2093}
2094
2095#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2097#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2098pub struct PaintLinearGradient {
2099 pub color_line: OffsetMarker<ColorLine, WIDTH_24>,
2101 pub x0: FWord,
2103 pub y0: FWord,
2105 pub x1: FWord,
2107 pub y1: FWord,
2109 pub x2: FWord,
2111 pub y2: FWord,
2113}
2114
2115impl PaintLinearGradient {
2116 pub fn new(
2118 color_line: ColorLine,
2119 x0: FWord,
2120 y0: FWord,
2121 x1: FWord,
2122 y1: FWord,
2123 x2: FWord,
2124 y2: FWord,
2125 ) -> Self {
2126 Self {
2127 color_line: color_line.into(),
2128 x0,
2129 y0,
2130 x1,
2131 y1,
2132 x2,
2133 y2,
2134 }
2135 }
2136}
2137
2138impl FontWrite for PaintLinearGradient {
2139 #[allow(clippy::unnecessary_cast)]
2140 fn write_into(&self, writer: &mut TableWriter) {
2141 (4 as u8).write_into(writer);
2142 self.color_line.write_into(writer);
2143 self.x0.write_into(writer);
2144 self.y0.write_into(writer);
2145 self.x1.write_into(writer);
2146 self.y1.write_into(writer);
2147 self.x2.write_into(writer);
2148 self.y2.write_into(writer);
2149 }
2150 fn table_type(&self) -> TableType {
2151 TableType::Named("PaintLinearGradient")
2152 }
2153}
2154
2155impl Validate for PaintLinearGradient {
2156 fn validate_impl(&self, ctx: &mut ValidationCtx) {
2157 ctx.in_table("PaintLinearGradient", |ctx| {
2158 ctx.in_field("color_line", |ctx| {
2159 self.color_line.validate_impl(ctx);
2160 });
2161 })
2162 }
2163}
2164
2165impl<'a> FromObjRef<read_fonts::tables::colr::PaintLinearGradient<'a>> for PaintLinearGradient {
2166 fn from_obj_ref(obj: &read_fonts::tables::colr::PaintLinearGradient<'a>, _: FontData) -> Self {
2167 PaintLinearGradient {
2168 color_line: obj.color_line().to_owned_table(),
2169 x0: obj.x0(),
2170 y0: obj.y0(),
2171 x1: obj.x1(),
2172 y1: obj.y1(),
2173 x2: obj.x2(),
2174 y2: obj.y2(),
2175 }
2176 }
2177}
2178
2179#[allow(clippy::needless_lifetimes)]
2180impl<'a> FromTableRef<read_fonts::tables::colr::PaintLinearGradient<'a>> for PaintLinearGradient {}
2181
2182impl ReadArgs for PaintLinearGradient {
2183 type Args = ();
2184}
2185
2186impl<'a> FontRead<'a> for PaintLinearGradient {
2187 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
2188 <read_fonts::tables::colr::PaintLinearGradient as FontRead>::read(data)
2189 .map(|x| x.to_owned_table())
2190 }
2191}
2192
2193#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2195#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2196pub struct PaintVarLinearGradient {
2197 pub color_line: OffsetMarker<VarColorLine, WIDTH_24>,
2199 pub x0: FWord,
2202 pub y0: FWord,
2205 pub x1: FWord,
2208 pub y1: FWord,
2211 pub x2: FWord,
2214 pub y2: FWord,
2217 pub var_index_base: u32,
2219}
2220
2221impl PaintVarLinearGradient {
2222 #[allow(clippy::too_many_arguments)]
2224 pub fn new(
2225 color_line: VarColorLine,
2226 x0: FWord,
2227 y0: FWord,
2228 x1: FWord,
2229 y1: FWord,
2230 x2: FWord,
2231 y2: FWord,
2232 var_index_base: u32,
2233 ) -> Self {
2234 Self {
2235 color_line: color_line.into(),
2236 x0,
2237 y0,
2238 x1,
2239 y1,
2240 x2,
2241 y2,
2242 var_index_base,
2243 }
2244 }
2245}
2246
2247impl FontWrite for PaintVarLinearGradient {
2248 #[allow(clippy::unnecessary_cast)]
2249 fn write_into(&self, writer: &mut TableWriter) {
2250 (5 as u8).write_into(writer);
2251 self.color_line.write_into(writer);
2252 self.x0.write_into(writer);
2253 self.y0.write_into(writer);
2254 self.x1.write_into(writer);
2255 self.y1.write_into(writer);
2256 self.x2.write_into(writer);
2257 self.y2.write_into(writer);
2258 self.var_index_base.write_into(writer);
2259 }
2260 fn table_type(&self) -> TableType {
2261 TableType::Named("PaintVarLinearGradient")
2262 }
2263}
2264
2265impl Validate for PaintVarLinearGradient {
2266 fn validate_impl(&self, ctx: &mut ValidationCtx) {
2267 ctx.in_table("PaintVarLinearGradient", |ctx| {
2268 ctx.in_field("color_line", |ctx| {
2269 self.color_line.validate_impl(ctx);
2270 });
2271 })
2272 }
2273}
2274
2275impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarLinearGradient<'a>>
2276 for PaintVarLinearGradient
2277{
2278 fn from_obj_ref(
2279 obj: &read_fonts::tables::colr::PaintVarLinearGradient<'a>,
2280 _: FontData,
2281 ) -> Self {
2282 PaintVarLinearGradient {
2283 color_line: obj.color_line().to_owned_table(),
2284 x0: obj.x0(),
2285 y0: obj.y0(),
2286 x1: obj.x1(),
2287 y1: obj.y1(),
2288 x2: obj.x2(),
2289 y2: obj.y2(),
2290 var_index_base: obj.var_index_base(),
2291 }
2292 }
2293}
2294
2295#[allow(clippy::needless_lifetimes)]
2296impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarLinearGradient<'a>>
2297 for PaintVarLinearGradient
2298{
2299}
2300
2301impl ReadArgs for PaintVarLinearGradient {
2302 type Args = ();
2303}
2304
2305impl<'a> FontRead<'a> for PaintVarLinearGradient {
2306 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
2307 <read_fonts::tables::colr::PaintVarLinearGradient as FontRead>::read(data)
2308 .map(|x| x.to_owned_table())
2309 }
2310}
2311
2312#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2314#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2315pub struct PaintRadialGradient {
2316 pub color_line: OffsetMarker<ColorLine, WIDTH_24>,
2318 pub x0: FWord,
2320 pub y0: FWord,
2322 pub radius0: UfWord,
2324 pub x1: FWord,
2326 pub y1: FWord,
2328 pub radius1: UfWord,
2330}
2331
2332impl PaintRadialGradient {
2333 pub fn new(
2335 color_line: ColorLine,
2336 x0: FWord,
2337 y0: FWord,
2338 radius0: UfWord,
2339 x1: FWord,
2340 y1: FWord,
2341 radius1: UfWord,
2342 ) -> Self {
2343 Self {
2344 color_line: color_line.into(),
2345 x0,
2346 y0,
2347 radius0,
2348 x1,
2349 y1,
2350 radius1,
2351 }
2352 }
2353}
2354
2355impl FontWrite for PaintRadialGradient {
2356 #[allow(clippy::unnecessary_cast)]
2357 fn write_into(&self, writer: &mut TableWriter) {
2358 (6 as u8).write_into(writer);
2359 self.color_line.write_into(writer);
2360 self.x0.write_into(writer);
2361 self.y0.write_into(writer);
2362 self.radius0.write_into(writer);
2363 self.x1.write_into(writer);
2364 self.y1.write_into(writer);
2365 self.radius1.write_into(writer);
2366 }
2367 fn table_type(&self) -> TableType {
2368 TableType::Named("PaintRadialGradient")
2369 }
2370}
2371
2372impl Validate for PaintRadialGradient {
2373 fn validate_impl(&self, ctx: &mut ValidationCtx) {
2374 ctx.in_table("PaintRadialGradient", |ctx| {
2375 ctx.in_field("color_line", |ctx| {
2376 self.color_line.validate_impl(ctx);
2377 });
2378 })
2379 }
2380}
2381
2382impl<'a> FromObjRef<read_fonts::tables::colr::PaintRadialGradient<'a>> for PaintRadialGradient {
2383 fn from_obj_ref(obj: &read_fonts::tables::colr::PaintRadialGradient<'a>, _: FontData) -> Self {
2384 PaintRadialGradient {
2385 color_line: obj.color_line().to_owned_table(),
2386 x0: obj.x0(),
2387 y0: obj.y0(),
2388 radius0: obj.radius0(),
2389 x1: obj.x1(),
2390 y1: obj.y1(),
2391 radius1: obj.radius1(),
2392 }
2393 }
2394}
2395
2396#[allow(clippy::needless_lifetimes)]
2397impl<'a> FromTableRef<read_fonts::tables::colr::PaintRadialGradient<'a>> for PaintRadialGradient {}
2398
2399impl ReadArgs for PaintRadialGradient {
2400 type Args = ();
2401}
2402
2403impl<'a> FontRead<'a> for PaintRadialGradient {
2404 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
2405 <read_fonts::tables::colr::PaintRadialGradient as FontRead>::read(data)
2406 .map(|x| x.to_owned_table())
2407 }
2408}
2409
2410#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2412#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2413pub struct PaintVarRadialGradient {
2414 pub color_line: OffsetMarker<VarColorLine, WIDTH_24>,
2416 pub x0: FWord,
2419 pub y0: FWord,
2422 pub radius0: UfWord,
2424 pub x1: FWord,
2427 pub y1: FWord,
2430 pub radius1: UfWord,
2432 pub var_index_base: u32,
2434}
2435
2436impl PaintVarRadialGradient {
2437 #[allow(clippy::too_many_arguments)]
2439 pub fn new(
2440 color_line: VarColorLine,
2441 x0: FWord,
2442 y0: FWord,
2443 radius0: UfWord,
2444 x1: FWord,
2445 y1: FWord,
2446 radius1: UfWord,
2447 var_index_base: u32,
2448 ) -> Self {
2449 Self {
2450 color_line: color_line.into(),
2451 x0,
2452 y0,
2453 radius0,
2454 x1,
2455 y1,
2456 radius1,
2457 var_index_base,
2458 }
2459 }
2460}
2461
2462impl FontWrite for PaintVarRadialGradient {
2463 #[allow(clippy::unnecessary_cast)]
2464 fn write_into(&self, writer: &mut TableWriter) {
2465 (7 as u8).write_into(writer);
2466 self.color_line.write_into(writer);
2467 self.x0.write_into(writer);
2468 self.y0.write_into(writer);
2469 self.radius0.write_into(writer);
2470 self.x1.write_into(writer);
2471 self.y1.write_into(writer);
2472 self.radius1.write_into(writer);
2473 self.var_index_base.write_into(writer);
2474 }
2475 fn table_type(&self) -> TableType {
2476 TableType::Named("PaintVarRadialGradient")
2477 }
2478}
2479
2480impl Validate for PaintVarRadialGradient {
2481 fn validate_impl(&self, ctx: &mut ValidationCtx) {
2482 ctx.in_table("PaintVarRadialGradient", |ctx| {
2483 ctx.in_field("color_line", |ctx| {
2484 self.color_line.validate_impl(ctx);
2485 });
2486 })
2487 }
2488}
2489
2490impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarRadialGradient<'a>>
2491 for PaintVarRadialGradient
2492{
2493 fn from_obj_ref(
2494 obj: &read_fonts::tables::colr::PaintVarRadialGradient<'a>,
2495 _: FontData,
2496 ) -> Self {
2497 PaintVarRadialGradient {
2498 color_line: obj.color_line().to_owned_table(),
2499 x0: obj.x0(),
2500 y0: obj.y0(),
2501 radius0: obj.radius0(),
2502 x1: obj.x1(),
2503 y1: obj.y1(),
2504 radius1: obj.radius1(),
2505 var_index_base: obj.var_index_base(),
2506 }
2507 }
2508}
2509
2510#[allow(clippy::needless_lifetimes)]
2511impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarRadialGradient<'a>>
2512 for PaintVarRadialGradient
2513{
2514}
2515
2516impl ReadArgs for PaintVarRadialGradient {
2517 type Args = ();
2518}
2519
2520impl<'a> FontRead<'a> for PaintVarRadialGradient {
2521 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
2522 <read_fonts::tables::colr::PaintVarRadialGradient as FontRead>::read(data)
2523 .map(|x| x.to_owned_table())
2524 }
2525}
2526
2527#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2529#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2530pub struct PaintSweepGradient {
2531 pub color_line: OffsetMarker<ColorLine, WIDTH_24>,
2533 pub center_x: FWord,
2535 pub center_y: FWord,
2537 pub start_angle: F2Dot14,
2540 pub end_angle: F2Dot14,
2543}
2544
2545impl PaintSweepGradient {
2546 pub fn new(
2548 color_line: ColorLine,
2549 center_x: FWord,
2550 center_y: FWord,
2551 start_angle: F2Dot14,
2552 end_angle: F2Dot14,
2553 ) -> Self {
2554 Self {
2555 color_line: color_line.into(),
2556 center_x,
2557 center_y,
2558 start_angle,
2559 end_angle,
2560 }
2561 }
2562}
2563
2564impl FontWrite for PaintSweepGradient {
2565 #[allow(clippy::unnecessary_cast)]
2566 fn write_into(&self, writer: &mut TableWriter) {
2567 (8 as u8).write_into(writer);
2568 self.color_line.write_into(writer);
2569 self.center_x.write_into(writer);
2570 self.center_y.write_into(writer);
2571 self.start_angle.write_into(writer);
2572 self.end_angle.write_into(writer);
2573 }
2574 fn table_type(&self) -> TableType {
2575 TableType::Named("PaintSweepGradient")
2576 }
2577}
2578
2579impl Validate for PaintSweepGradient {
2580 fn validate_impl(&self, ctx: &mut ValidationCtx) {
2581 ctx.in_table("PaintSweepGradient", |ctx| {
2582 ctx.in_field("color_line", |ctx| {
2583 self.color_line.validate_impl(ctx);
2584 });
2585 })
2586 }
2587}
2588
2589impl<'a> FromObjRef<read_fonts::tables::colr::PaintSweepGradient<'a>> for PaintSweepGradient {
2590 fn from_obj_ref(obj: &read_fonts::tables::colr::PaintSweepGradient<'a>, _: FontData) -> Self {
2591 PaintSweepGradient {
2592 color_line: obj.color_line().to_owned_table(),
2593 center_x: obj.center_x(),
2594 center_y: obj.center_y(),
2595 start_angle: obj.start_angle(),
2596 end_angle: obj.end_angle(),
2597 }
2598 }
2599}
2600
2601#[allow(clippy::needless_lifetimes)]
2602impl<'a> FromTableRef<read_fonts::tables::colr::PaintSweepGradient<'a>> for PaintSweepGradient {}
2603
2604impl ReadArgs for PaintSweepGradient {
2605 type Args = ();
2606}
2607
2608impl<'a> FontRead<'a> for PaintSweepGradient {
2609 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
2610 <read_fonts::tables::colr::PaintSweepGradient as FontRead>::read(data)
2611 .map(|x| x.to_owned_table())
2612 }
2613}
2614
2615#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2617#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2618pub struct PaintVarSweepGradient {
2619 pub color_line: OffsetMarker<VarColorLine, WIDTH_24>,
2621 pub center_x: FWord,
2623 pub center_y: FWord,
2625 pub start_angle: F2Dot14,
2629 pub end_angle: F2Dot14,
2633 pub var_index_base: u32,
2635}
2636
2637impl PaintVarSweepGradient {
2638 pub fn new(
2640 color_line: VarColorLine,
2641 center_x: FWord,
2642 center_y: FWord,
2643 start_angle: F2Dot14,
2644 end_angle: F2Dot14,
2645 var_index_base: u32,
2646 ) -> Self {
2647 Self {
2648 color_line: color_line.into(),
2649 center_x,
2650 center_y,
2651 start_angle,
2652 end_angle,
2653 var_index_base,
2654 }
2655 }
2656}
2657
2658impl FontWrite for PaintVarSweepGradient {
2659 #[allow(clippy::unnecessary_cast)]
2660 fn write_into(&self, writer: &mut TableWriter) {
2661 (9 as u8).write_into(writer);
2662 self.color_line.write_into(writer);
2663 self.center_x.write_into(writer);
2664 self.center_y.write_into(writer);
2665 self.start_angle.write_into(writer);
2666 self.end_angle.write_into(writer);
2667 self.var_index_base.write_into(writer);
2668 }
2669 fn table_type(&self) -> TableType {
2670 TableType::Named("PaintVarSweepGradient")
2671 }
2672}
2673
2674impl Validate for PaintVarSweepGradient {
2675 fn validate_impl(&self, ctx: &mut ValidationCtx) {
2676 ctx.in_table("PaintVarSweepGradient", |ctx| {
2677 ctx.in_field("color_line", |ctx| {
2678 self.color_line.validate_impl(ctx);
2679 });
2680 })
2681 }
2682}
2683
2684impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarSweepGradient<'a>> for PaintVarSweepGradient {
2685 fn from_obj_ref(
2686 obj: &read_fonts::tables::colr::PaintVarSweepGradient<'a>,
2687 _: FontData,
2688 ) -> Self {
2689 PaintVarSweepGradient {
2690 color_line: obj.color_line().to_owned_table(),
2691 center_x: obj.center_x(),
2692 center_y: obj.center_y(),
2693 start_angle: obj.start_angle(),
2694 end_angle: obj.end_angle(),
2695 var_index_base: obj.var_index_base(),
2696 }
2697 }
2698}
2699
2700#[allow(clippy::needless_lifetimes)]
2701impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarSweepGradient<'a>>
2702 for PaintVarSweepGradient
2703{
2704}
2705
2706impl ReadArgs for PaintVarSweepGradient {
2707 type Args = ();
2708}
2709
2710impl<'a> FontRead<'a> for PaintVarSweepGradient {
2711 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
2712 <read_fonts::tables::colr::PaintVarSweepGradient as FontRead>::read(data)
2713 .map(|x| x.to_owned_table())
2714 }
2715}
2716
2717#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2719#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2720pub struct PaintGlyph {
2721 pub paint: OffsetMarker<Paint, WIDTH_24>,
2723 pub glyph_id: GlyphId16,
2725}
2726
2727impl PaintGlyph {
2728 pub fn new(paint: Paint, glyph_id: GlyphId16) -> Self {
2730 Self {
2731 paint: paint.into(),
2732 glyph_id,
2733 }
2734 }
2735}
2736
2737impl FontWrite for PaintGlyph {
2738 #[allow(clippy::unnecessary_cast)]
2739 fn write_into(&self, writer: &mut TableWriter) {
2740 (10 as u8).write_into(writer);
2741 self.paint.write_into(writer);
2742 self.glyph_id.write_into(writer);
2743 }
2744 fn table_type(&self) -> TableType {
2745 TableType::Named("PaintGlyph")
2746 }
2747}
2748
2749impl Validate for PaintGlyph {
2750 fn validate_impl(&self, ctx: &mut ValidationCtx) {
2751 ctx.in_table("PaintGlyph", |ctx| {
2752 ctx.in_field("paint", |ctx| {
2753 self.paint.validate_impl(ctx);
2754 });
2755 })
2756 }
2757}
2758
2759impl<'a> FromObjRef<read_fonts::tables::colr::PaintGlyph<'a>> for PaintGlyph {
2760 fn from_obj_ref(obj: &read_fonts::tables::colr::PaintGlyph<'a>, _: FontData) -> Self {
2761 PaintGlyph {
2762 paint: obj.paint().to_owned_table(),
2763 glyph_id: obj.glyph_id(),
2764 }
2765 }
2766}
2767
2768#[allow(clippy::needless_lifetimes)]
2769impl<'a> FromTableRef<read_fonts::tables::colr::PaintGlyph<'a>> for PaintGlyph {}
2770
2771impl ReadArgs for PaintGlyph {
2772 type Args = ();
2773}
2774
2775impl<'a> FontRead<'a> for PaintGlyph {
2776 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
2777 <read_fonts::tables::colr::PaintGlyph as FontRead>::read(data).map(|x| x.to_owned_table())
2778 }
2779}
2780
2781#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2783#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2784pub struct PaintGlyph2 {
2785 pub paint: OffsetMarker<Paint, WIDTH_24>,
2787 pub glyph_id: GlyphId24,
2789}
2790
2791impl PaintGlyph2 {
2792 pub fn new(paint: Paint, glyph_id: GlyphId24) -> Self {
2794 Self {
2795 paint: paint.into(),
2796 glyph_id,
2797 }
2798 }
2799}
2800
2801impl FontWrite for PaintGlyph2 {
2802 #[allow(clippy::unnecessary_cast)]
2803 fn write_into(&self, writer: &mut TableWriter) {
2804 (33 as u8).write_into(writer);
2805 self.paint.write_into(writer);
2806 self.glyph_id.write_into(writer);
2807 }
2808 fn table_type(&self) -> TableType {
2809 TableType::Named("PaintGlyph2")
2810 }
2811}
2812
2813impl Validate for PaintGlyph2 {
2814 fn validate_impl(&self, ctx: &mut ValidationCtx) {
2815 ctx.in_table("PaintGlyph2", |ctx| {
2816 ctx.in_field("paint", |ctx| {
2817 self.paint.validate_impl(ctx);
2818 });
2819 })
2820 }
2821}
2822
2823impl<'a> FromObjRef<read_fonts::tables::colr::PaintGlyph2<'a>> for PaintGlyph2 {
2824 fn from_obj_ref(obj: &read_fonts::tables::colr::PaintGlyph2<'a>, _: FontData) -> Self {
2825 PaintGlyph2 {
2826 paint: obj.paint().to_owned_table(),
2827 glyph_id: obj.glyph_id(),
2828 }
2829 }
2830}
2831
2832#[allow(clippy::needless_lifetimes)]
2833impl<'a> FromTableRef<read_fonts::tables::colr::PaintGlyph2<'a>> for PaintGlyph2 {}
2834
2835impl ReadArgs for PaintGlyph2 {
2836 type Args = ();
2837}
2838
2839impl<'a> FontRead<'a> for PaintGlyph2 {
2840 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
2841 <read_fonts::tables::colr::PaintGlyph2 as FontRead>::read(data).map(|x| x.to_owned_table())
2842 }
2843}
2844
2845#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2847#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2848pub struct PaintColrGlyph {
2849 pub glyph_id: GlyphId16,
2851}
2852
2853impl PaintColrGlyph {
2854 pub fn new(glyph_id: GlyphId16) -> Self {
2856 Self { glyph_id }
2857 }
2858}
2859
2860impl FontWrite for PaintColrGlyph {
2861 #[allow(clippy::unnecessary_cast)]
2862 fn write_into(&self, writer: &mut TableWriter) {
2863 (11 as u8).write_into(writer);
2864 self.glyph_id.write_into(writer);
2865 }
2866 fn table_type(&self) -> TableType {
2867 TableType::Named("PaintColrGlyph")
2868 }
2869}
2870
2871impl Validate for PaintColrGlyph {
2872 fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
2873}
2874
2875impl<'a> FromObjRef<read_fonts::tables::colr::PaintColrGlyph<'a>> for PaintColrGlyph {
2876 fn from_obj_ref(obj: &read_fonts::tables::colr::PaintColrGlyph<'a>, _: FontData) -> Self {
2877 PaintColrGlyph {
2878 glyph_id: obj.glyph_id(),
2879 }
2880 }
2881}
2882
2883#[allow(clippy::needless_lifetimes)]
2884impl<'a> FromTableRef<read_fonts::tables::colr::PaintColrGlyph<'a>> for PaintColrGlyph {}
2885
2886impl ReadArgs for PaintColrGlyph {
2887 type Args = ();
2888}
2889
2890impl<'a> FontRead<'a> for PaintColrGlyph {
2891 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
2892 <read_fonts::tables::colr::PaintColrGlyph as FontRead>::read(data)
2893 .map(|x| x.to_owned_table())
2894 }
2895}
2896
2897#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2899#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2900pub struct PaintTransform {
2901 pub paint: OffsetMarker<Paint, WIDTH_24>,
2903 pub transform: OffsetMarker<Affine2x3, WIDTH_24>,
2905}
2906
2907impl PaintTransform {
2908 pub fn new(paint: Paint, transform: Affine2x3) -> Self {
2910 Self {
2911 paint: paint.into(),
2912 transform: transform.into(),
2913 }
2914 }
2915}
2916
2917impl FontWrite for PaintTransform {
2918 #[allow(clippy::unnecessary_cast)]
2919 fn write_into(&self, writer: &mut TableWriter) {
2920 (12 as u8).write_into(writer);
2921 self.paint.write_into(writer);
2922 self.transform.write_into(writer);
2923 }
2924 fn table_type(&self) -> TableType {
2925 TableType::Named("PaintTransform")
2926 }
2927}
2928
2929impl Validate for PaintTransform {
2930 fn validate_impl(&self, ctx: &mut ValidationCtx) {
2931 ctx.in_table("PaintTransform", |ctx| {
2932 ctx.in_field("paint", |ctx| {
2933 self.paint.validate_impl(ctx);
2934 });
2935 ctx.in_field("transform", |ctx| {
2936 self.transform.validate_impl(ctx);
2937 });
2938 })
2939 }
2940}
2941
2942impl<'a> FromObjRef<read_fonts::tables::colr::PaintTransform<'a>> for PaintTransform {
2943 fn from_obj_ref(obj: &read_fonts::tables::colr::PaintTransform<'a>, _: FontData) -> Self {
2944 PaintTransform {
2945 paint: obj.paint().to_owned_table(),
2946 transform: obj.transform().to_owned_table(),
2947 }
2948 }
2949}
2950
2951#[allow(clippy::needless_lifetimes)]
2952impl<'a> FromTableRef<read_fonts::tables::colr::PaintTransform<'a>> for PaintTransform {}
2953
2954impl ReadArgs for PaintTransform {
2955 type Args = ();
2956}
2957
2958impl<'a> FontRead<'a> for PaintTransform {
2959 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
2960 <read_fonts::tables::colr::PaintTransform as FontRead>::read(data)
2961 .map(|x| x.to_owned_table())
2962 }
2963}
2964
2965#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
2967#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
2968pub struct PaintVarTransform {
2969 pub paint: OffsetMarker<Paint, WIDTH_24>,
2971 pub transform: OffsetMarker<VarAffine2x3, WIDTH_24>,
2973}
2974
2975impl PaintVarTransform {
2976 pub fn new(paint: Paint, transform: VarAffine2x3) -> Self {
2978 Self {
2979 paint: paint.into(),
2980 transform: transform.into(),
2981 }
2982 }
2983}
2984
2985impl FontWrite for PaintVarTransform {
2986 #[allow(clippy::unnecessary_cast)]
2987 fn write_into(&self, writer: &mut TableWriter) {
2988 (13 as u8).write_into(writer);
2989 self.paint.write_into(writer);
2990 self.transform.write_into(writer);
2991 }
2992 fn table_type(&self) -> TableType {
2993 TableType::Named("PaintVarTransform")
2994 }
2995}
2996
2997impl Validate for PaintVarTransform {
2998 fn validate_impl(&self, ctx: &mut ValidationCtx) {
2999 ctx.in_table("PaintVarTransform", |ctx| {
3000 ctx.in_field("paint", |ctx| {
3001 self.paint.validate_impl(ctx);
3002 });
3003 ctx.in_field("transform", |ctx| {
3004 self.transform.validate_impl(ctx);
3005 });
3006 })
3007 }
3008}
3009
3010impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarTransform<'a>> for PaintVarTransform {
3011 fn from_obj_ref(obj: &read_fonts::tables::colr::PaintVarTransform<'a>, _: FontData) -> Self {
3012 PaintVarTransform {
3013 paint: obj.paint().to_owned_table(),
3014 transform: obj.transform().to_owned_table(),
3015 }
3016 }
3017}
3018
3019#[allow(clippy::needless_lifetimes)]
3020impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarTransform<'a>> for PaintVarTransform {}
3021
3022impl ReadArgs for PaintVarTransform {
3023 type Args = ();
3024}
3025
3026impl<'a> FontRead<'a> for PaintVarTransform {
3027 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
3028 <read_fonts::tables::colr::PaintVarTransform as FontRead>::read(data)
3029 .map(|x| x.to_owned_table())
3030 }
3031}
3032
3033#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3035#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3036pub struct Affine2x3 {
3037 pub xx: Fixed,
3039 pub yx: Fixed,
3041 pub xy: Fixed,
3043 pub yy: Fixed,
3045 pub dx: Fixed,
3047 pub dy: Fixed,
3049}
3050
3051impl Affine2x3 {
3052 pub fn new(xx: Fixed, yx: Fixed, xy: Fixed, yy: Fixed, dx: Fixed, dy: Fixed) -> Self {
3054 Self {
3055 xx,
3056 yx,
3057 xy,
3058 yy,
3059 dx,
3060 dy,
3061 }
3062 }
3063}
3064
3065impl FontWrite for Affine2x3 {
3066 fn write_into(&self, writer: &mut TableWriter) {
3067 self.xx.write_into(writer);
3068 self.yx.write_into(writer);
3069 self.xy.write_into(writer);
3070 self.yy.write_into(writer);
3071 self.dx.write_into(writer);
3072 self.dy.write_into(writer);
3073 }
3074 fn table_type(&self) -> TableType {
3075 TableType::Named("Affine2x3")
3076 }
3077}
3078
3079impl Validate for Affine2x3 {
3080 fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
3081}
3082
3083impl<'a> FromObjRef<read_fonts::tables::colr::Affine2x3<'a>> for Affine2x3 {
3084 fn from_obj_ref(obj: &read_fonts::tables::colr::Affine2x3<'a>, _: FontData) -> Self {
3085 Affine2x3 {
3086 xx: obj.xx(),
3087 yx: obj.yx(),
3088 xy: obj.xy(),
3089 yy: obj.yy(),
3090 dx: obj.dx(),
3091 dy: obj.dy(),
3092 }
3093 }
3094}
3095
3096#[allow(clippy::needless_lifetimes)]
3097impl<'a> FromTableRef<read_fonts::tables::colr::Affine2x3<'a>> for Affine2x3 {}
3098
3099impl ReadArgs for Affine2x3 {
3100 type Args = ();
3101}
3102
3103impl<'a> FontRead<'a> for Affine2x3 {
3104 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
3105 <read_fonts::tables::colr::Affine2x3 as FontRead>::read(data).map(|x| x.to_owned_table())
3106 }
3107}
3108
3109#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3111#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3112pub struct VarAffine2x3 {
3113 pub xx: Fixed,
3116 pub yx: Fixed,
3119 pub xy: Fixed,
3122 pub yy: Fixed,
3125 pub dx: Fixed,
3127 pub dy: Fixed,
3129 pub var_index_base: u32,
3131}
3132
3133impl VarAffine2x3 {
3134 pub fn new(
3136 xx: Fixed,
3137 yx: Fixed,
3138 xy: Fixed,
3139 yy: Fixed,
3140 dx: Fixed,
3141 dy: Fixed,
3142 var_index_base: u32,
3143 ) -> Self {
3144 Self {
3145 xx,
3146 yx,
3147 xy,
3148 yy,
3149 dx,
3150 dy,
3151 var_index_base,
3152 }
3153 }
3154}
3155
3156impl FontWrite for VarAffine2x3 {
3157 fn write_into(&self, writer: &mut TableWriter) {
3158 self.xx.write_into(writer);
3159 self.yx.write_into(writer);
3160 self.xy.write_into(writer);
3161 self.yy.write_into(writer);
3162 self.dx.write_into(writer);
3163 self.dy.write_into(writer);
3164 self.var_index_base.write_into(writer);
3165 }
3166 fn table_type(&self) -> TableType {
3167 TableType::Named("VarAffine2x3")
3168 }
3169}
3170
3171impl Validate for VarAffine2x3 {
3172 fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
3173}
3174
3175impl<'a> FromObjRef<read_fonts::tables::colr::VarAffine2x3<'a>> for VarAffine2x3 {
3176 fn from_obj_ref(obj: &read_fonts::tables::colr::VarAffine2x3<'a>, _: FontData) -> Self {
3177 VarAffine2x3 {
3178 xx: obj.xx(),
3179 yx: obj.yx(),
3180 xy: obj.xy(),
3181 yy: obj.yy(),
3182 dx: obj.dx(),
3183 dy: obj.dy(),
3184 var_index_base: obj.var_index_base(),
3185 }
3186 }
3187}
3188
3189#[allow(clippy::needless_lifetimes)]
3190impl<'a> FromTableRef<read_fonts::tables::colr::VarAffine2x3<'a>> for VarAffine2x3 {}
3191
3192impl ReadArgs for VarAffine2x3 {
3193 type Args = ();
3194}
3195
3196impl<'a> FontRead<'a> for VarAffine2x3 {
3197 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
3198 <read_fonts::tables::colr::VarAffine2x3 as FontRead>::read(data).map(|x| x.to_owned_table())
3199 }
3200}
3201
3202#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3204#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3205pub struct PaintTranslate {
3206 pub paint: OffsetMarker<Paint, WIDTH_24>,
3208 pub dx: FWord,
3210 pub dy: FWord,
3212}
3213
3214impl PaintTranslate {
3215 pub fn new(paint: Paint, dx: FWord, dy: FWord) -> Self {
3217 Self {
3218 paint: paint.into(),
3219 dx,
3220 dy,
3221 }
3222 }
3223}
3224
3225impl FontWrite for PaintTranslate {
3226 #[allow(clippy::unnecessary_cast)]
3227 fn write_into(&self, writer: &mut TableWriter) {
3228 (14 as u8).write_into(writer);
3229 self.paint.write_into(writer);
3230 self.dx.write_into(writer);
3231 self.dy.write_into(writer);
3232 }
3233 fn table_type(&self) -> TableType {
3234 TableType::Named("PaintTranslate")
3235 }
3236}
3237
3238impl Validate for PaintTranslate {
3239 fn validate_impl(&self, ctx: &mut ValidationCtx) {
3240 ctx.in_table("PaintTranslate", |ctx| {
3241 ctx.in_field("paint", |ctx| {
3242 self.paint.validate_impl(ctx);
3243 });
3244 })
3245 }
3246}
3247
3248impl<'a> FromObjRef<read_fonts::tables::colr::PaintTranslate<'a>> for PaintTranslate {
3249 fn from_obj_ref(obj: &read_fonts::tables::colr::PaintTranslate<'a>, _: FontData) -> Self {
3250 PaintTranslate {
3251 paint: obj.paint().to_owned_table(),
3252 dx: obj.dx(),
3253 dy: obj.dy(),
3254 }
3255 }
3256}
3257
3258#[allow(clippy::needless_lifetimes)]
3259impl<'a> FromTableRef<read_fonts::tables::colr::PaintTranslate<'a>> for PaintTranslate {}
3260
3261impl ReadArgs for PaintTranslate {
3262 type Args = ();
3263}
3264
3265impl<'a> FontRead<'a> for PaintTranslate {
3266 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
3267 <read_fonts::tables::colr::PaintTranslate as FontRead>::read(data)
3268 .map(|x| x.to_owned_table())
3269 }
3270}
3271
3272#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3274#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3275pub struct PaintVarTranslate {
3276 pub paint: OffsetMarker<Paint, WIDTH_24>,
3278 pub dx: FWord,
3280 pub dy: FWord,
3282 pub var_index_base: u32,
3284}
3285
3286impl PaintVarTranslate {
3287 pub fn new(paint: Paint, dx: FWord, dy: FWord, var_index_base: u32) -> Self {
3289 Self {
3290 paint: paint.into(),
3291 dx,
3292 dy,
3293 var_index_base,
3294 }
3295 }
3296}
3297
3298impl FontWrite for PaintVarTranslate {
3299 #[allow(clippy::unnecessary_cast)]
3300 fn write_into(&self, writer: &mut TableWriter) {
3301 (15 as u8).write_into(writer);
3302 self.paint.write_into(writer);
3303 self.dx.write_into(writer);
3304 self.dy.write_into(writer);
3305 self.var_index_base.write_into(writer);
3306 }
3307 fn table_type(&self) -> TableType {
3308 TableType::Named("PaintVarTranslate")
3309 }
3310}
3311
3312impl Validate for PaintVarTranslate {
3313 fn validate_impl(&self, ctx: &mut ValidationCtx) {
3314 ctx.in_table("PaintVarTranslate", |ctx| {
3315 ctx.in_field("paint", |ctx| {
3316 self.paint.validate_impl(ctx);
3317 });
3318 })
3319 }
3320}
3321
3322impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarTranslate<'a>> for PaintVarTranslate {
3323 fn from_obj_ref(obj: &read_fonts::tables::colr::PaintVarTranslate<'a>, _: FontData) -> Self {
3324 PaintVarTranslate {
3325 paint: obj.paint().to_owned_table(),
3326 dx: obj.dx(),
3327 dy: obj.dy(),
3328 var_index_base: obj.var_index_base(),
3329 }
3330 }
3331}
3332
3333#[allow(clippy::needless_lifetimes)]
3334impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarTranslate<'a>> for PaintVarTranslate {}
3335
3336impl ReadArgs for PaintVarTranslate {
3337 type Args = ();
3338}
3339
3340impl<'a> FontRead<'a> for PaintVarTranslate {
3341 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
3342 <read_fonts::tables::colr::PaintVarTranslate as FontRead>::read(data)
3343 .map(|x| x.to_owned_table())
3344 }
3345}
3346
3347#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3349#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3350pub struct PaintScale {
3351 pub paint: OffsetMarker<Paint, WIDTH_24>,
3353 pub scale_x: F2Dot14,
3355 pub scale_y: F2Dot14,
3357}
3358
3359impl PaintScale {
3360 pub fn new(paint: Paint, scale_x: F2Dot14, scale_y: F2Dot14) -> Self {
3362 Self {
3363 paint: paint.into(),
3364 scale_x,
3365 scale_y,
3366 }
3367 }
3368}
3369
3370impl FontWrite for PaintScale {
3371 #[allow(clippy::unnecessary_cast)]
3372 fn write_into(&self, writer: &mut TableWriter) {
3373 (16 as u8).write_into(writer);
3374 self.paint.write_into(writer);
3375 self.scale_x.write_into(writer);
3376 self.scale_y.write_into(writer);
3377 }
3378 fn table_type(&self) -> TableType {
3379 TableType::Named("PaintScale")
3380 }
3381}
3382
3383impl Validate for PaintScale {
3384 fn validate_impl(&self, ctx: &mut ValidationCtx) {
3385 ctx.in_table("PaintScale", |ctx| {
3386 ctx.in_field("paint", |ctx| {
3387 self.paint.validate_impl(ctx);
3388 });
3389 })
3390 }
3391}
3392
3393impl<'a> FromObjRef<read_fonts::tables::colr::PaintScale<'a>> for PaintScale {
3394 fn from_obj_ref(obj: &read_fonts::tables::colr::PaintScale<'a>, _: FontData) -> Self {
3395 PaintScale {
3396 paint: obj.paint().to_owned_table(),
3397 scale_x: obj.scale_x(),
3398 scale_y: obj.scale_y(),
3399 }
3400 }
3401}
3402
3403#[allow(clippy::needless_lifetimes)]
3404impl<'a> FromTableRef<read_fonts::tables::colr::PaintScale<'a>> for PaintScale {}
3405
3406impl ReadArgs for PaintScale {
3407 type Args = ();
3408}
3409
3410impl<'a> FontRead<'a> for PaintScale {
3411 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
3412 <read_fonts::tables::colr::PaintScale as FontRead>::read(data).map(|x| x.to_owned_table())
3413 }
3414}
3415
3416#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3418#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3419pub struct PaintVarScale {
3420 pub paint: OffsetMarker<Paint, WIDTH_24>,
3422 pub scale_x: F2Dot14,
3425 pub scale_y: F2Dot14,
3428 pub var_index_base: u32,
3430}
3431
3432impl PaintVarScale {
3433 pub fn new(paint: Paint, scale_x: F2Dot14, scale_y: F2Dot14, var_index_base: u32) -> Self {
3435 Self {
3436 paint: paint.into(),
3437 scale_x,
3438 scale_y,
3439 var_index_base,
3440 }
3441 }
3442}
3443
3444impl FontWrite for PaintVarScale {
3445 #[allow(clippy::unnecessary_cast)]
3446 fn write_into(&self, writer: &mut TableWriter) {
3447 (17 as u8).write_into(writer);
3448 self.paint.write_into(writer);
3449 self.scale_x.write_into(writer);
3450 self.scale_y.write_into(writer);
3451 self.var_index_base.write_into(writer);
3452 }
3453 fn table_type(&self) -> TableType {
3454 TableType::Named("PaintVarScale")
3455 }
3456}
3457
3458impl Validate for PaintVarScale {
3459 fn validate_impl(&self, ctx: &mut ValidationCtx) {
3460 ctx.in_table("PaintVarScale", |ctx| {
3461 ctx.in_field("paint", |ctx| {
3462 self.paint.validate_impl(ctx);
3463 });
3464 })
3465 }
3466}
3467
3468impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarScale<'a>> for PaintVarScale {
3469 fn from_obj_ref(obj: &read_fonts::tables::colr::PaintVarScale<'a>, _: FontData) -> Self {
3470 PaintVarScale {
3471 paint: obj.paint().to_owned_table(),
3472 scale_x: obj.scale_x(),
3473 scale_y: obj.scale_y(),
3474 var_index_base: obj.var_index_base(),
3475 }
3476 }
3477}
3478
3479#[allow(clippy::needless_lifetimes)]
3480impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarScale<'a>> for PaintVarScale {}
3481
3482impl ReadArgs for PaintVarScale {
3483 type Args = ();
3484}
3485
3486impl<'a> FontRead<'a> for PaintVarScale {
3487 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
3488 <read_fonts::tables::colr::PaintVarScale as FontRead>::read(data)
3489 .map(|x| x.to_owned_table())
3490 }
3491}
3492
3493#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3495#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3496pub struct PaintScaleAroundCenter {
3497 pub paint: OffsetMarker<Paint, WIDTH_24>,
3499 pub scale_x: F2Dot14,
3501 pub scale_y: F2Dot14,
3503 pub center_x: FWord,
3505 pub center_y: FWord,
3507}
3508
3509impl PaintScaleAroundCenter {
3510 pub fn new(
3512 paint: Paint,
3513 scale_x: F2Dot14,
3514 scale_y: F2Dot14,
3515 center_x: FWord,
3516 center_y: FWord,
3517 ) -> Self {
3518 Self {
3519 paint: paint.into(),
3520 scale_x,
3521 scale_y,
3522 center_x,
3523 center_y,
3524 }
3525 }
3526}
3527
3528impl FontWrite for PaintScaleAroundCenter {
3529 #[allow(clippy::unnecessary_cast)]
3530 fn write_into(&self, writer: &mut TableWriter) {
3531 (18 as u8).write_into(writer);
3532 self.paint.write_into(writer);
3533 self.scale_x.write_into(writer);
3534 self.scale_y.write_into(writer);
3535 self.center_x.write_into(writer);
3536 self.center_y.write_into(writer);
3537 }
3538 fn table_type(&self) -> TableType {
3539 TableType::Named("PaintScaleAroundCenter")
3540 }
3541}
3542
3543impl Validate for PaintScaleAroundCenter {
3544 fn validate_impl(&self, ctx: &mut ValidationCtx) {
3545 ctx.in_table("PaintScaleAroundCenter", |ctx| {
3546 ctx.in_field("paint", |ctx| {
3547 self.paint.validate_impl(ctx);
3548 });
3549 })
3550 }
3551}
3552
3553impl<'a> FromObjRef<read_fonts::tables::colr::PaintScaleAroundCenter<'a>>
3554 for PaintScaleAroundCenter
3555{
3556 fn from_obj_ref(
3557 obj: &read_fonts::tables::colr::PaintScaleAroundCenter<'a>,
3558 _: FontData,
3559 ) -> Self {
3560 PaintScaleAroundCenter {
3561 paint: obj.paint().to_owned_table(),
3562 scale_x: obj.scale_x(),
3563 scale_y: obj.scale_y(),
3564 center_x: obj.center_x(),
3565 center_y: obj.center_y(),
3566 }
3567 }
3568}
3569
3570#[allow(clippy::needless_lifetimes)]
3571impl<'a> FromTableRef<read_fonts::tables::colr::PaintScaleAroundCenter<'a>>
3572 for PaintScaleAroundCenter
3573{
3574}
3575
3576impl ReadArgs for PaintScaleAroundCenter {
3577 type Args = ();
3578}
3579
3580impl<'a> FontRead<'a> for PaintScaleAroundCenter {
3581 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
3582 <read_fonts::tables::colr::PaintScaleAroundCenter as FontRead>::read(data)
3583 .map(|x| x.to_owned_table())
3584 }
3585}
3586
3587#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3589#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3590pub struct PaintVarScaleAroundCenter {
3591 pub paint: OffsetMarker<Paint, WIDTH_24>,
3593 pub scale_x: F2Dot14,
3596 pub scale_y: F2Dot14,
3599 pub center_x: FWord,
3602 pub center_y: FWord,
3605 pub var_index_base: u32,
3607}
3608
3609impl PaintVarScaleAroundCenter {
3610 pub fn new(
3612 paint: Paint,
3613 scale_x: F2Dot14,
3614 scale_y: F2Dot14,
3615 center_x: FWord,
3616 center_y: FWord,
3617 var_index_base: u32,
3618 ) -> Self {
3619 Self {
3620 paint: paint.into(),
3621 scale_x,
3622 scale_y,
3623 center_x,
3624 center_y,
3625 var_index_base,
3626 }
3627 }
3628}
3629
3630impl FontWrite for PaintVarScaleAroundCenter {
3631 #[allow(clippy::unnecessary_cast)]
3632 fn write_into(&self, writer: &mut TableWriter) {
3633 (19 as u8).write_into(writer);
3634 self.paint.write_into(writer);
3635 self.scale_x.write_into(writer);
3636 self.scale_y.write_into(writer);
3637 self.center_x.write_into(writer);
3638 self.center_y.write_into(writer);
3639 self.var_index_base.write_into(writer);
3640 }
3641 fn table_type(&self) -> TableType {
3642 TableType::Named("PaintVarScaleAroundCenter")
3643 }
3644}
3645
3646impl Validate for PaintVarScaleAroundCenter {
3647 fn validate_impl(&self, ctx: &mut ValidationCtx) {
3648 ctx.in_table("PaintVarScaleAroundCenter", |ctx| {
3649 ctx.in_field("paint", |ctx| {
3650 self.paint.validate_impl(ctx);
3651 });
3652 })
3653 }
3654}
3655
3656impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarScaleAroundCenter<'a>>
3657 for PaintVarScaleAroundCenter
3658{
3659 fn from_obj_ref(
3660 obj: &read_fonts::tables::colr::PaintVarScaleAroundCenter<'a>,
3661 _: FontData,
3662 ) -> Self {
3663 PaintVarScaleAroundCenter {
3664 paint: obj.paint().to_owned_table(),
3665 scale_x: obj.scale_x(),
3666 scale_y: obj.scale_y(),
3667 center_x: obj.center_x(),
3668 center_y: obj.center_y(),
3669 var_index_base: obj.var_index_base(),
3670 }
3671 }
3672}
3673
3674#[allow(clippy::needless_lifetimes)]
3675impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarScaleAroundCenter<'a>>
3676 for PaintVarScaleAroundCenter
3677{
3678}
3679
3680impl ReadArgs for PaintVarScaleAroundCenter {
3681 type Args = ();
3682}
3683
3684impl<'a> FontRead<'a> for PaintVarScaleAroundCenter {
3685 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
3686 <read_fonts::tables::colr::PaintVarScaleAroundCenter as FontRead>::read(data)
3687 .map(|x| x.to_owned_table())
3688 }
3689}
3690
3691#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3693#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3694pub struct PaintScaleUniform {
3695 pub paint: OffsetMarker<Paint, WIDTH_24>,
3697 pub scale: F2Dot14,
3699}
3700
3701impl PaintScaleUniform {
3702 pub fn new(paint: Paint, scale: F2Dot14) -> Self {
3704 Self {
3705 paint: paint.into(),
3706 scale,
3707 }
3708 }
3709}
3710
3711impl FontWrite for PaintScaleUniform {
3712 #[allow(clippy::unnecessary_cast)]
3713 fn write_into(&self, writer: &mut TableWriter) {
3714 (20 as u8).write_into(writer);
3715 self.paint.write_into(writer);
3716 self.scale.write_into(writer);
3717 }
3718 fn table_type(&self) -> TableType {
3719 TableType::Named("PaintScaleUniform")
3720 }
3721}
3722
3723impl Validate for PaintScaleUniform {
3724 fn validate_impl(&self, ctx: &mut ValidationCtx) {
3725 ctx.in_table("PaintScaleUniform", |ctx| {
3726 ctx.in_field("paint", |ctx| {
3727 self.paint.validate_impl(ctx);
3728 });
3729 })
3730 }
3731}
3732
3733impl<'a> FromObjRef<read_fonts::tables::colr::PaintScaleUniform<'a>> for PaintScaleUniform {
3734 fn from_obj_ref(obj: &read_fonts::tables::colr::PaintScaleUniform<'a>, _: FontData) -> Self {
3735 PaintScaleUniform {
3736 paint: obj.paint().to_owned_table(),
3737 scale: obj.scale(),
3738 }
3739 }
3740}
3741
3742#[allow(clippy::needless_lifetimes)]
3743impl<'a> FromTableRef<read_fonts::tables::colr::PaintScaleUniform<'a>> for PaintScaleUniform {}
3744
3745impl ReadArgs for PaintScaleUniform {
3746 type Args = ();
3747}
3748
3749impl<'a> FontRead<'a> for PaintScaleUniform {
3750 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
3751 <read_fonts::tables::colr::PaintScaleUniform as FontRead>::read(data)
3752 .map(|x| x.to_owned_table())
3753 }
3754}
3755
3756#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3758#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3759pub struct PaintVarScaleUniform {
3760 pub paint: OffsetMarker<Paint, WIDTH_24>,
3762 pub scale: F2Dot14,
3765 pub var_index_base: u32,
3767}
3768
3769impl PaintVarScaleUniform {
3770 pub fn new(paint: Paint, scale: F2Dot14, var_index_base: u32) -> Self {
3772 Self {
3773 paint: paint.into(),
3774 scale,
3775 var_index_base,
3776 }
3777 }
3778}
3779
3780impl FontWrite for PaintVarScaleUniform {
3781 #[allow(clippy::unnecessary_cast)]
3782 fn write_into(&self, writer: &mut TableWriter) {
3783 (21 as u8).write_into(writer);
3784 self.paint.write_into(writer);
3785 self.scale.write_into(writer);
3786 self.var_index_base.write_into(writer);
3787 }
3788 fn table_type(&self) -> TableType {
3789 TableType::Named("PaintVarScaleUniform")
3790 }
3791}
3792
3793impl Validate for PaintVarScaleUniform {
3794 fn validate_impl(&self, ctx: &mut ValidationCtx) {
3795 ctx.in_table("PaintVarScaleUniform", |ctx| {
3796 ctx.in_field("paint", |ctx| {
3797 self.paint.validate_impl(ctx);
3798 });
3799 })
3800 }
3801}
3802
3803impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarScaleUniform<'a>> for PaintVarScaleUniform {
3804 fn from_obj_ref(obj: &read_fonts::tables::colr::PaintVarScaleUniform<'a>, _: FontData) -> Self {
3805 PaintVarScaleUniform {
3806 paint: obj.paint().to_owned_table(),
3807 scale: obj.scale(),
3808 var_index_base: obj.var_index_base(),
3809 }
3810 }
3811}
3812
3813#[allow(clippy::needless_lifetimes)]
3814impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarScaleUniform<'a>> for PaintVarScaleUniform {}
3815
3816impl ReadArgs for PaintVarScaleUniform {
3817 type Args = ();
3818}
3819
3820impl<'a> FontRead<'a> for PaintVarScaleUniform {
3821 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
3822 <read_fonts::tables::colr::PaintVarScaleUniform as FontRead>::read(data)
3823 .map(|x| x.to_owned_table())
3824 }
3825}
3826
3827#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3829#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3830pub struct PaintScaleUniformAroundCenter {
3831 pub paint: OffsetMarker<Paint, WIDTH_24>,
3833 pub scale: F2Dot14,
3835 pub center_x: FWord,
3837 pub center_y: FWord,
3839}
3840
3841impl PaintScaleUniformAroundCenter {
3842 pub fn new(paint: Paint, scale: F2Dot14, center_x: FWord, center_y: FWord) -> Self {
3844 Self {
3845 paint: paint.into(),
3846 scale,
3847 center_x,
3848 center_y,
3849 }
3850 }
3851}
3852
3853impl FontWrite for PaintScaleUniformAroundCenter {
3854 #[allow(clippy::unnecessary_cast)]
3855 fn write_into(&self, writer: &mut TableWriter) {
3856 (22 as u8).write_into(writer);
3857 self.paint.write_into(writer);
3858 self.scale.write_into(writer);
3859 self.center_x.write_into(writer);
3860 self.center_y.write_into(writer);
3861 }
3862 fn table_type(&self) -> TableType {
3863 TableType::Named("PaintScaleUniformAroundCenter")
3864 }
3865}
3866
3867impl Validate for PaintScaleUniformAroundCenter {
3868 fn validate_impl(&self, ctx: &mut ValidationCtx) {
3869 ctx.in_table("PaintScaleUniformAroundCenter", |ctx| {
3870 ctx.in_field("paint", |ctx| {
3871 self.paint.validate_impl(ctx);
3872 });
3873 })
3874 }
3875}
3876
3877impl<'a> FromObjRef<read_fonts::tables::colr::PaintScaleUniformAroundCenter<'a>>
3878 for PaintScaleUniformAroundCenter
3879{
3880 fn from_obj_ref(
3881 obj: &read_fonts::tables::colr::PaintScaleUniformAroundCenter<'a>,
3882 _: FontData,
3883 ) -> Self {
3884 PaintScaleUniformAroundCenter {
3885 paint: obj.paint().to_owned_table(),
3886 scale: obj.scale(),
3887 center_x: obj.center_x(),
3888 center_y: obj.center_y(),
3889 }
3890 }
3891}
3892
3893#[allow(clippy::needless_lifetimes)]
3894impl<'a> FromTableRef<read_fonts::tables::colr::PaintScaleUniformAroundCenter<'a>>
3895 for PaintScaleUniformAroundCenter
3896{
3897}
3898
3899impl ReadArgs for PaintScaleUniformAroundCenter {
3900 type Args = ();
3901}
3902
3903impl<'a> FontRead<'a> for PaintScaleUniformAroundCenter {
3904 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
3905 <read_fonts::tables::colr::PaintScaleUniformAroundCenter as FontRead>::read(data)
3906 .map(|x| x.to_owned_table())
3907 }
3908}
3909
3910#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
3912#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
3913pub struct PaintVarScaleUniformAroundCenter {
3914 pub paint: OffsetMarker<Paint, WIDTH_24>,
3916 pub scale: F2Dot14,
3919 pub center_x: FWord,
3922 pub center_y: FWord,
3925 pub var_index_base: u32,
3927}
3928
3929impl PaintVarScaleUniformAroundCenter {
3930 pub fn new(
3932 paint: Paint,
3933 scale: F2Dot14,
3934 center_x: FWord,
3935 center_y: FWord,
3936 var_index_base: u32,
3937 ) -> Self {
3938 Self {
3939 paint: paint.into(),
3940 scale,
3941 center_x,
3942 center_y,
3943 var_index_base,
3944 }
3945 }
3946}
3947
3948impl FontWrite for PaintVarScaleUniformAroundCenter {
3949 #[allow(clippy::unnecessary_cast)]
3950 fn write_into(&self, writer: &mut TableWriter) {
3951 (23 as u8).write_into(writer);
3952 self.paint.write_into(writer);
3953 self.scale.write_into(writer);
3954 self.center_x.write_into(writer);
3955 self.center_y.write_into(writer);
3956 self.var_index_base.write_into(writer);
3957 }
3958 fn table_type(&self) -> TableType {
3959 TableType::Named("PaintVarScaleUniformAroundCenter")
3960 }
3961}
3962
3963impl Validate for PaintVarScaleUniformAroundCenter {
3964 fn validate_impl(&self, ctx: &mut ValidationCtx) {
3965 ctx.in_table("PaintVarScaleUniformAroundCenter", |ctx| {
3966 ctx.in_field("paint", |ctx| {
3967 self.paint.validate_impl(ctx);
3968 });
3969 })
3970 }
3971}
3972
3973impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarScaleUniformAroundCenter<'a>>
3974 for PaintVarScaleUniformAroundCenter
3975{
3976 fn from_obj_ref(
3977 obj: &read_fonts::tables::colr::PaintVarScaleUniformAroundCenter<'a>,
3978 _: FontData,
3979 ) -> Self {
3980 PaintVarScaleUniformAroundCenter {
3981 paint: obj.paint().to_owned_table(),
3982 scale: obj.scale(),
3983 center_x: obj.center_x(),
3984 center_y: obj.center_y(),
3985 var_index_base: obj.var_index_base(),
3986 }
3987 }
3988}
3989
3990#[allow(clippy::needless_lifetimes)]
3991impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarScaleUniformAroundCenter<'a>>
3992 for PaintVarScaleUniformAroundCenter
3993{
3994}
3995
3996impl ReadArgs for PaintVarScaleUniformAroundCenter {
3997 type Args = ();
3998}
3999
4000impl<'a> FontRead<'a> for PaintVarScaleUniformAroundCenter {
4001 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
4002 <read_fonts::tables::colr::PaintVarScaleUniformAroundCenter as FontRead>::read(data)
4003 .map(|x| x.to_owned_table())
4004 }
4005}
4006
4007#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
4009#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4010pub struct PaintRotate {
4011 pub paint: OffsetMarker<Paint, WIDTH_24>,
4013 pub angle: F2Dot14,
4016}
4017
4018impl PaintRotate {
4019 pub fn new(paint: Paint, angle: F2Dot14) -> Self {
4021 Self {
4022 paint: paint.into(),
4023 angle,
4024 }
4025 }
4026}
4027
4028impl FontWrite for PaintRotate {
4029 #[allow(clippy::unnecessary_cast)]
4030 fn write_into(&self, writer: &mut TableWriter) {
4031 (24 as u8).write_into(writer);
4032 self.paint.write_into(writer);
4033 self.angle.write_into(writer);
4034 }
4035 fn table_type(&self) -> TableType {
4036 TableType::Named("PaintRotate")
4037 }
4038}
4039
4040impl Validate for PaintRotate {
4041 fn validate_impl(&self, ctx: &mut ValidationCtx) {
4042 ctx.in_table("PaintRotate", |ctx| {
4043 ctx.in_field("paint", |ctx| {
4044 self.paint.validate_impl(ctx);
4045 });
4046 })
4047 }
4048}
4049
4050impl<'a> FromObjRef<read_fonts::tables::colr::PaintRotate<'a>> for PaintRotate {
4051 fn from_obj_ref(obj: &read_fonts::tables::colr::PaintRotate<'a>, _: FontData) -> Self {
4052 PaintRotate {
4053 paint: obj.paint().to_owned_table(),
4054 angle: obj.angle(),
4055 }
4056 }
4057}
4058
4059#[allow(clippy::needless_lifetimes)]
4060impl<'a> FromTableRef<read_fonts::tables::colr::PaintRotate<'a>> for PaintRotate {}
4061
4062impl ReadArgs for PaintRotate {
4063 type Args = ();
4064}
4065
4066impl<'a> FontRead<'a> for PaintRotate {
4067 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
4068 <read_fonts::tables::colr::PaintRotate as FontRead>::read(data).map(|x| x.to_owned_table())
4069 }
4070}
4071
4072#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
4074#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4075pub struct PaintVarRotate {
4076 pub paint: OffsetMarker<Paint, WIDTH_24>,
4078 pub angle: F2Dot14,
4081 pub var_index_base: u32,
4083}
4084
4085impl PaintVarRotate {
4086 pub fn new(paint: Paint, angle: F2Dot14, var_index_base: u32) -> Self {
4088 Self {
4089 paint: paint.into(),
4090 angle,
4091 var_index_base,
4092 }
4093 }
4094}
4095
4096impl FontWrite for PaintVarRotate {
4097 #[allow(clippy::unnecessary_cast)]
4098 fn write_into(&self, writer: &mut TableWriter) {
4099 (25 as u8).write_into(writer);
4100 self.paint.write_into(writer);
4101 self.angle.write_into(writer);
4102 self.var_index_base.write_into(writer);
4103 }
4104 fn table_type(&self) -> TableType {
4105 TableType::Named("PaintVarRotate")
4106 }
4107}
4108
4109impl Validate for PaintVarRotate {
4110 fn validate_impl(&self, ctx: &mut ValidationCtx) {
4111 ctx.in_table("PaintVarRotate", |ctx| {
4112 ctx.in_field("paint", |ctx| {
4113 self.paint.validate_impl(ctx);
4114 });
4115 })
4116 }
4117}
4118
4119impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarRotate<'a>> for PaintVarRotate {
4120 fn from_obj_ref(obj: &read_fonts::tables::colr::PaintVarRotate<'a>, _: FontData) -> Self {
4121 PaintVarRotate {
4122 paint: obj.paint().to_owned_table(),
4123 angle: obj.angle(),
4124 var_index_base: obj.var_index_base(),
4125 }
4126 }
4127}
4128
4129#[allow(clippy::needless_lifetimes)]
4130impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarRotate<'a>> for PaintVarRotate {}
4131
4132impl ReadArgs for PaintVarRotate {
4133 type Args = ();
4134}
4135
4136impl<'a> FontRead<'a> for PaintVarRotate {
4137 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
4138 <read_fonts::tables::colr::PaintVarRotate as FontRead>::read(data)
4139 .map(|x| x.to_owned_table())
4140 }
4141}
4142
4143#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
4145#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4146pub struct PaintRotateAroundCenter {
4147 pub paint: OffsetMarker<Paint, WIDTH_24>,
4149 pub angle: F2Dot14,
4152 pub center_x: FWord,
4154 pub center_y: FWord,
4156}
4157
4158impl PaintRotateAroundCenter {
4159 pub fn new(paint: Paint, angle: F2Dot14, center_x: FWord, center_y: FWord) -> Self {
4161 Self {
4162 paint: paint.into(),
4163 angle,
4164 center_x,
4165 center_y,
4166 }
4167 }
4168}
4169
4170impl FontWrite for PaintRotateAroundCenter {
4171 #[allow(clippy::unnecessary_cast)]
4172 fn write_into(&self, writer: &mut TableWriter) {
4173 (26 as u8).write_into(writer);
4174 self.paint.write_into(writer);
4175 self.angle.write_into(writer);
4176 self.center_x.write_into(writer);
4177 self.center_y.write_into(writer);
4178 }
4179 fn table_type(&self) -> TableType {
4180 TableType::Named("PaintRotateAroundCenter")
4181 }
4182}
4183
4184impl Validate for PaintRotateAroundCenter {
4185 fn validate_impl(&self, ctx: &mut ValidationCtx) {
4186 ctx.in_table("PaintRotateAroundCenter", |ctx| {
4187 ctx.in_field("paint", |ctx| {
4188 self.paint.validate_impl(ctx);
4189 });
4190 })
4191 }
4192}
4193
4194impl<'a> FromObjRef<read_fonts::tables::colr::PaintRotateAroundCenter<'a>>
4195 for PaintRotateAroundCenter
4196{
4197 fn from_obj_ref(
4198 obj: &read_fonts::tables::colr::PaintRotateAroundCenter<'a>,
4199 _: FontData,
4200 ) -> Self {
4201 PaintRotateAroundCenter {
4202 paint: obj.paint().to_owned_table(),
4203 angle: obj.angle(),
4204 center_x: obj.center_x(),
4205 center_y: obj.center_y(),
4206 }
4207 }
4208}
4209
4210#[allow(clippy::needless_lifetimes)]
4211impl<'a> FromTableRef<read_fonts::tables::colr::PaintRotateAroundCenter<'a>>
4212 for PaintRotateAroundCenter
4213{
4214}
4215
4216impl ReadArgs for PaintRotateAroundCenter {
4217 type Args = ();
4218}
4219
4220impl<'a> FontRead<'a> for PaintRotateAroundCenter {
4221 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
4222 <read_fonts::tables::colr::PaintRotateAroundCenter as FontRead>::read(data)
4223 .map(|x| x.to_owned_table())
4224 }
4225}
4226
4227#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
4229#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4230pub struct PaintVarRotateAroundCenter {
4231 pub paint: OffsetMarker<Paint, WIDTH_24>,
4233 pub angle: F2Dot14,
4236 pub center_x: FWord,
4239 pub center_y: FWord,
4242 pub var_index_base: u32,
4244}
4245
4246impl PaintVarRotateAroundCenter {
4247 pub fn new(
4249 paint: Paint,
4250 angle: F2Dot14,
4251 center_x: FWord,
4252 center_y: FWord,
4253 var_index_base: u32,
4254 ) -> Self {
4255 Self {
4256 paint: paint.into(),
4257 angle,
4258 center_x,
4259 center_y,
4260 var_index_base,
4261 }
4262 }
4263}
4264
4265impl FontWrite for PaintVarRotateAroundCenter {
4266 #[allow(clippy::unnecessary_cast)]
4267 fn write_into(&self, writer: &mut TableWriter) {
4268 (27 as u8).write_into(writer);
4269 self.paint.write_into(writer);
4270 self.angle.write_into(writer);
4271 self.center_x.write_into(writer);
4272 self.center_y.write_into(writer);
4273 self.var_index_base.write_into(writer);
4274 }
4275 fn table_type(&self) -> TableType {
4276 TableType::Named("PaintVarRotateAroundCenter")
4277 }
4278}
4279
4280impl Validate for PaintVarRotateAroundCenter {
4281 fn validate_impl(&self, ctx: &mut ValidationCtx) {
4282 ctx.in_table("PaintVarRotateAroundCenter", |ctx| {
4283 ctx.in_field("paint", |ctx| {
4284 self.paint.validate_impl(ctx);
4285 });
4286 })
4287 }
4288}
4289
4290impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarRotateAroundCenter<'a>>
4291 for PaintVarRotateAroundCenter
4292{
4293 fn from_obj_ref(
4294 obj: &read_fonts::tables::colr::PaintVarRotateAroundCenter<'a>,
4295 _: FontData,
4296 ) -> Self {
4297 PaintVarRotateAroundCenter {
4298 paint: obj.paint().to_owned_table(),
4299 angle: obj.angle(),
4300 center_x: obj.center_x(),
4301 center_y: obj.center_y(),
4302 var_index_base: obj.var_index_base(),
4303 }
4304 }
4305}
4306
4307#[allow(clippy::needless_lifetimes)]
4308impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarRotateAroundCenter<'a>>
4309 for PaintVarRotateAroundCenter
4310{
4311}
4312
4313impl ReadArgs for PaintVarRotateAroundCenter {
4314 type Args = ();
4315}
4316
4317impl<'a> FontRead<'a> for PaintVarRotateAroundCenter {
4318 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
4319 <read_fonts::tables::colr::PaintVarRotateAroundCenter as FontRead>::read(data)
4320 .map(|x| x.to_owned_table())
4321 }
4322}
4323
4324#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
4326#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4327pub struct PaintSkew {
4328 pub paint: OffsetMarker<Paint, WIDTH_24>,
4330 pub x_skew_angle: F2Dot14,
4333 pub y_skew_angle: F2Dot14,
4336}
4337
4338impl PaintSkew {
4339 pub fn new(paint: Paint, x_skew_angle: F2Dot14, y_skew_angle: F2Dot14) -> Self {
4341 Self {
4342 paint: paint.into(),
4343 x_skew_angle,
4344 y_skew_angle,
4345 }
4346 }
4347}
4348
4349impl FontWrite for PaintSkew {
4350 #[allow(clippy::unnecessary_cast)]
4351 fn write_into(&self, writer: &mut TableWriter) {
4352 (28 as u8).write_into(writer);
4353 self.paint.write_into(writer);
4354 self.x_skew_angle.write_into(writer);
4355 self.y_skew_angle.write_into(writer);
4356 }
4357 fn table_type(&self) -> TableType {
4358 TableType::Named("PaintSkew")
4359 }
4360}
4361
4362impl Validate for PaintSkew {
4363 fn validate_impl(&self, ctx: &mut ValidationCtx) {
4364 ctx.in_table("PaintSkew", |ctx| {
4365 ctx.in_field("paint", |ctx| {
4366 self.paint.validate_impl(ctx);
4367 });
4368 })
4369 }
4370}
4371
4372impl<'a> FromObjRef<read_fonts::tables::colr::PaintSkew<'a>> for PaintSkew {
4373 fn from_obj_ref(obj: &read_fonts::tables::colr::PaintSkew<'a>, _: FontData) -> Self {
4374 PaintSkew {
4375 paint: obj.paint().to_owned_table(),
4376 x_skew_angle: obj.x_skew_angle(),
4377 y_skew_angle: obj.y_skew_angle(),
4378 }
4379 }
4380}
4381
4382#[allow(clippy::needless_lifetimes)]
4383impl<'a> FromTableRef<read_fonts::tables::colr::PaintSkew<'a>> for PaintSkew {}
4384
4385impl ReadArgs for PaintSkew {
4386 type Args = ();
4387}
4388
4389impl<'a> FontRead<'a> for PaintSkew {
4390 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
4391 <read_fonts::tables::colr::PaintSkew as FontRead>::read(data).map(|x| x.to_owned_table())
4392 }
4393}
4394
4395#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
4397#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4398pub struct PaintVarSkew {
4399 pub paint: OffsetMarker<Paint, WIDTH_24>,
4401 pub x_skew_angle: F2Dot14,
4405 pub y_skew_angle: F2Dot14,
4409 pub var_index_base: u32,
4411}
4412
4413impl PaintVarSkew {
4414 pub fn new(
4416 paint: Paint,
4417 x_skew_angle: F2Dot14,
4418 y_skew_angle: F2Dot14,
4419 var_index_base: u32,
4420 ) -> Self {
4421 Self {
4422 paint: paint.into(),
4423 x_skew_angle,
4424 y_skew_angle,
4425 var_index_base,
4426 }
4427 }
4428}
4429
4430impl FontWrite for PaintVarSkew {
4431 #[allow(clippy::unnecessary_cast)]
4432 fn write_into(&self, writer: &mut TableWriter) {
4433 (29 as u8).write_into(writer);
4434 self.paint.write_into(writer);
4435 self.x_skew_angle.write_into(writer);
4436 self.y_skew_angle.write_into(writer);
4437 self.var_index_base.write_into(writer);
4438 }
4439 fn table_type(&self) -> TableType {
4440 TableType::Named("PaintVarSkew")
4441 }
4442}
4443
4444impl Validate for PaintVarSkew {
4445 fn validate_impl(&self, ctx: &mut ValidationCtx) {
4446 ctx.in_table("PaintVarSkew", |ctx| {
4447 ctx.in_field("paint", |ctx| {
4448 self.paint.validate_impl(ctx);
4449 });
4450 })
4451 }
4452}
4453
4454impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarSkew<'a>> for PaintVarSkew {
4455 fn from_obj_ref(obj: &read_fonts::tables::colr::PaintVarSkew<'a>, _: FontData) -> Self {
4456 PaintVarSkew {
4457 paint: obj.paint().to_owned_table(),
4458 x_skew_angle: obj.x_skew_angle(),
4459 y_skew_angle: obj.y_skew_angle(),
4460 var_index_base: obj.var_index_base(),
4461 }
4462 }
4463}
4464
4465#[allow(clippy::needless_lifetimes)]
4466impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarSkew<'a>> for PaintVarSkew {}
4467
4468impl ReadArgs for PaintVarSkew {
4469 type Args = ();
4470}
4471
4472impl<'a> FontRead<'a> for PaintVarSkew {
4473 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
4474 <read_fonts::tables::colr::PaintVarSkew as FontRead>::read(data).map(|x| x.to_owned_table())
4475 }
4476}
4477
4478#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
4480#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4481pub struct PaintSkewAroundCenter {
4482 pub paint: OffsetMarker<Paint, WIDTH_24>,
4484 pub x_skew_angle: F2Dot14,
4487 pub y_skew_angle: F2Dot14,
4490 pub center_x: FWord,
4492 pub center_y: FWord,
4494}
4495
4496impl PaintSkewAroundCenter {
4497 pub fn new(
4499 paint: Paint,
4500 x_skew_angle: F2Dot14,
4501 y_skew_angle: F2Dot14,
4502 center_x: FWord,
4503 center_y: FWord,
4504 ) -> Self {
4505 Self {
4506 paint: paint.into(),
4507 x_skew_angle,
4508 y_skew_angle,
4509 center_x,
4510 center_y,
4511 }
4512 }
4513}
4514
4515impl FontWrite for PaintSkewAroundCenter {
4516 #[allow(clippy::unnecessary_cast)]
4517 fn write_into(&self, writer: &mut TableWriter) {
4518 (30 as u8).write_into(writer);
4519 self.paint.write_into(writer);
4520 self.x_skew_angle.write_into(writer);
4521 self.y_skew_angle.write_into(writer);
4522 self.center_x.write_into(writer);
4523 self.center_y.write_into(writer);
4524 }
4525 fn table_type(&self) -> TableType {
4526 TableType::Named("PaintSkewAroundCenter")
4527 }
4528}
4529
4530impl Validate for PaintSkewAroundCenter {
4531 fn validate_impl(&self, ctx: &mut ValidationCtx) {
4532 ctx.in_table("PaintSkewAroundCenter", |ctx| {
4533 ctx.in_field("paint", |ctx| {
4534 self.paint.validate_impl(ctx);
4535 });
4536 })
4537 }
4538}
4539
4540impl<'a> FromObjRef<read_fonts::tables::colr::PaintSkewAroundCenter<'a>> for PaintSkewAroundCenter {
4541 fn from_obj_ref(
4542 obj: &read_fonts::tables::colr::PaintSkewAroundCenter<'a>,
4543 _: FontData,
4544 ) -> Self {
4545 PaintSkewAroundCenter {
4546 paint: obj.paint().to_owned_table(),
4547 x_skew_angle: obj.x_skew_angle(),
4548 y_skew_angle: obj.y_skew_angle(),
4549 center_x: obj.center_x(),
4550 center_y: obj.center_y(),
4551 }
4552 }
4553}
4554
4555#[allow(clippy::needless_lifetimes)]
4556impl<'a> FromTableRef<read_fonts::tables::colr::PaintSkewAroundCenter<'a>>
4557 for PaintSkewAroundCenter
4558{
4559}
4560
4561impl ReadArgs for PaintSkewAroundCenter {
4562 type Args = ();
4563}
4564
4565impl<'a> FontRead<'a> for PaintSkewAroundCenter {
4566 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
4567 <read_fonts::tables::colr::PaintSkewAroundCenter as FontRead>::read(data)
4568 .map(|x| x.to_owned_table())
4569 }
4570}
4571
4572#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
4574#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4575pub struct PaintVarSkewAroundCenter {
4576 pub paint: OffsetMarker<Paint, WIDTH_24>,
4578 pub x_skew_angle: F2Dot14,
4582 pub y_skew_angle: F2Dot14,
4586 pub center_x: FWord,
4589 pub center_y: FWord,
4592 pub var_index_base: u32,
4594}
4595
4596impl PaintVarSkewAroundCenter {
4597 pub fn new(
4599 paint: Paint,
4600 x_skew_angle: F2Dot14,
4601 y_skew_angle: F2Dot14,
4602 center_x: FWord,
4603 center_y: FWord,
4604 var_index_base: u32,
4605 ) -> Self {
4606 Self {
4607 paint: paint.into(),
4608 x_skew_angle,
4609 y_skew_angle,
4610 center_x,
4611 center_y,
4612 var_index_base,
4613 }
4614 }
4615}
4616
4617impl FontWrite for PaintVarSkewAroundCenter {
4618 #[allow(clippy::unnecessary_cast)]
4619 fn write_into(&self, writer: &mut TableWriter) {
4620 (31 as u8).write_into(writer);
4621 self.paint.write_into(writer);
4622 self.x_skew_angle.write_into(writer);
4623 self.y_skew_angle.write_into(writer);
4624 self.center_x.write_into(writer);
4625 self.center_y.write_into(writer);
4626 self.var_index_base.write_into(writer);
4627 }
4628 fn table_type(&self) -> TableType {
4629 TableType::Named("PaintVarSkewAroundCenter")
4630 }
4631}
4632
4633impl Validate for PaintVarSkewAroundCenter {
4634 fn validate_impl(&self, ctx: &mut ValidationCtx) {
4635 ctx.in_table("PaintVarSkewAroundCenter", |ctx| {
4636 ctx.in_field("paint", |ctx| {
4637 self.paint.validate_impl(ctx);
4638 });
4639 })
4640 }
4641}
4642
4643impl<'a> FromObjRef<read_fonts::tables::colr::PaintVarSkewAroundCenter<'a>>
4644 for PaintVarSkewAroundCenter
4645{
4646 fn from_obj_ref(
4647 obj: &read_fonts::tables::colr::PaintVarSkewAroundCenter<'a>,
4648 _: FontData,
4649 ) -> Self {
4650 PaintVarSkewAroundCenter {
4651 paint: obj.paint().to_owned_table(),
4652 x_skew_angle: obj.x_skew_angle(),
4653 y_skew_angle: obj.y_skew_angle(),
4654 center_x: obj.center_x(),
4655 center_y: obj.center_y(),
4656 var_index_base: obj.var_index_base(),
4657 }
4658 }
4659}
4660
4661#[allow(clippy::needless_lifetimes)]
4662impl<'a> FromTableRef<read_fonts::tables::colr::PaintVarSkewAroundCenter<'a>>
4663 for PaintVarSkewAroundCenter
4664{
4665}
4666
4667impl ReadArgs for PaintVarSkewAroundCenter {
4668 type Args = ();
4669}
4670
4671impl<'a> FontRead<'a> for PaintVarSkewAroundCenter {
4672 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
4673 <read_fonts::tables::colr::PaintVarSkewAroundCenter as FontRead>::read(data)
4674 .map(|x| x.to_owned_table())
4675 }
4676}
4677
4678#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
4680#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
4681pub struct PaintComposite {
4682 pub source_paint: OffsetMarker<Paint, WIDTH_24>,
4684 pub composite_mode: CompositeMode,
4686 pub backdrop_paint: OffsetMarker<Paint, WIDTH_24>,
4688}
4689
4690impl PaintComposite {
4691 pub fn new(source_paint: Paint, composite_mode: CompositeMode, backdrop_paint: Paint) -> Self {
4693 Self {
4694 source_paint: source_paint.into(),
4695 composite_mode,
4696 backdrop_paint: backdrop_paint.into(),
4697 }
4698 }
4699}
4700
4701impl FontWrite for PaintComposite {
4702 #[allow(clippy::unnecessary_cast)]
4703 fn write_into(&self, writer: &mut TableWriter) {
4704 (32 as u8).write_into(writer);
4705 self.source_paint.write_into(writer);
4706 self.composite_mode.write_into(writer);
4707 self.backdrop_paint.write_into(writer);
4708 }
4709 fn table_type(&self) -> TableType {
4710 TableType::Named("PaintComposite")
4711 }
4712}
4713
4714impl Validate for PaintComposite {
4715 fn validate_impl(&self, ctx: &mut ValidationCtx) {
4716 ctx.in_table("PaintComposite", |ctx| {
4717 ctx.in_field("source_paint", |ctx| {
4718 self.source_paint.validate_impl(ctx);
4719 });
4720 ctx.in_field("backdrop_paint", |ctx| {
4721 self.backdrop_paint.validate_impl(ctx);
4722 });
4723 })
4724 }
4725}
4726
4727impl<'a> FromObjRef<read_fonts::tables::colr::PaintComposite<'a>> for PaintComposite {
4728 fn from_obj_ref(obj: &read_fonts::tables::colr::PaintComposite<'a>, _: FontData) -> Self {
4729 PaintComposite {
4730 source_paint: obj.source_paint().to_owned_table(),
4731 composite_mode: obj.composite_mode(),
4732 backdrop_paint: obj.backdrop_paint().to_owned_table(),
4733 }
4734 }
4735}
4736
4737#[allow(clippy::needless_lifetimes)]
4738impl<'a> FromTableRef<read_fonts::tables::colr::PaintComposite<'a>> for PaintComposite {}
4739
4740impl ReadArgs for PaintComposite {
4741 type Args = ();
4742}
4743
4744impl<'a> FontRead<'a> for PaintComposite {
4745 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
4746 <read_fonts::tables::colr::PaintComposite as FontRead>::read(data)
4747 .map(|x| x.to_owned_table())
4748 }
4749}
4750
4751impl FontWrite for CompositeMode {
4752 fn write_into(&self, writer: &mut TableWriter) {
4753 let val = *self as u8;
4754 writer.write_slice(&val.to_be_bytes())
4755 }
4756}