1#[allow(unused_imports)]
6use crate::codegen_prelude::*;
7
8pub use read_fonts::tables::gdef::GlyphClassDef;
9
10#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
12#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
13pub struct Gdef {
14 pub glyph_class_def: NullableOffsetMarker<ClassDef>,
17 pub attach_list: NullableOffsetMarker<AttachList>,
20 pub lig_caret_list: NullableOffsetMarker<LigCaretList>,
23 pub mark_attach_class_def: NullableOffsetMarker<ClassDef>,
26 pub mark_glyph_sets_def: NullableOffsetMarker<MarkGlyphSets>,
29 pub item_var_store: NullableOffsetMarker<ItemVariationStore, WIDTH_32>,
32}
33
34impl Gdef {
35 pub fn new(
37 glyph_class_def: Option<ClassDef>,
38 attach_list: Option<AttachList>,
39 lig_caret_list: Option<LigCaretList>,
40 mark_attach_class_def: Option<ClassDef>,
41 ) -> Self {
42 Self {
43 glyph_class_def: glyph_class_def.into(),
44 attach_list: attach_list.into(),
45 lig_caret_list: lig_caret_list.into(),
46 mark_attach_class_def: mark_attach_class_def.into(),
47 ..Default::default()
48 }
49 }
50}
51
52impl FontWrite for Gdef {
53 #[allow(clippy::unnecessary_cast)]
54 fn write_into(&self, writer: &mut TableWriter) {
55 let version = self.compute_version() as MajorMinor;
56 version.write_into(writer);
57 self.glyph_class_def.write_into(writer);
58 self.attach_list.write_into(writer);
59 self.lig_caret_list.write_into(writer);
60 self.mark_attach_class_def.write_into(writer);
61 version
62 .compatible((1u16, 2u16))
63 .then(|| self.mark_glyph_sets_def.write_into(writer));
64 version
65 .compatible((1u16, 3u16))
66 .then(|| self.item_var_store.write_into(writer));
67 }
68 fn table_type(&self) -> TableType {
69 TableType::TopLevel(Gdef::TAG)
70 }
71}
72
73impl Validate for Gdef {
74 fn validate_impl(&self, ctx: &mut ValidationCtx) {
75 ctx.in_table("Gdef", |ctx| {
76 ctx.in_field("glyph_class_def", |ctx| {
77 self.glyph_class_def.validate_impl(ctx);
78 });
79 ctx.in_field("attach_list", |ctx| {
80 self.attach_list.validate_impl(ctx);
81 });
82 ctx.in_field("lig_caret_list", |ctx| {
83 self.lig_caret_list.validate_impl(ctx);
84 });
85 ctx.in_field("mark_attach_class_def", |ctx| {
86 self.mark_attach_class_def.validate_impl(ctx);
87 });
88 ctx.in_field("mark_glyph_sets_def", |ctx| {
89 self.mark_glyph_sets_def.validate_impl(ctx);
90 });
91 ctx.in_field("item_var_store", |ctx| {
92 self.item_var_store.validate_impl(ctx);
93 });
94 })
95 }
96}
97
98impl TopLevelTable for Gdef {
99 const TAG: Tag = Tag::new(b"GDEF");
100}
101
102impl<'a> FromObjRef<read_fonts::tables::gdef::Gdef<'a>> for Gdef {
103 fn from_obj_ref(obj: &read_fonts::tables::gdef::Gdef<'a>, _: FontData) -> Self {
104 Gdef {
105 glyph_class_def: obj.glyph_class_def().to_owned_table(),
106 attach_list: obj.attach_list().to_owned_table(),
107 lig_caret_list: obj.lig_caret_list().to_owned_table(),
108 mark_attach_class_def: obj.mark_attach_class_def().to_owned_table(),
109 mark_glyph_sets_def: obj.mark_glyph_sets_def().to_owned_table(),
110 item_var_store: obj.item_var_store().to_owned_table(),
111 }
112 }
113}
114
115#[allow(clippy::needless_lifetimes)]
116impl<'a> FromTableRef<read_fonts::tables::gdef::Gdef<'a>> for Gdef {}
117
118impl ReadArgs for Gdef {
119 type Args = ();
120}
121
122impl<'a> FontRead<'a> for Gdef {
123 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
124 <read_fonts::tables::gdef::Gdef as FontRead>::read(data).map(|x| x.to_owned_table())
125 }
126}
127
128impl FontWrite for GlyphClassDef {
129 fn write_into(&self, writer: &mut TableWriter) {
130 let val = *self as u16;
131 writer.write_slice(&val.to_be_bytes())
132 }
133}
134
135#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
137#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
138pub struct AttachList {
139 pub coverage: OffsetMarker<CoverageTable>,
141 pub attach_points: Vec<OffsetMarker<AttachPoint>>,
144}
145
146impl AttachList {
147 pub fn new(coverage: CoverageTable, attach_points: Vec<AttachPoint>) -> Self {
149 Self {
150 coverage: coverage.into(),
151 attach_points: attach_points.into_iter().map(Into::into).collect(),
152 }
153 }
154}
155
156impl FontWrite for AttachList {
157 #[allow(clippy::unnecessary_cast)]
158 fn write_into(&self, writer: &mut TableWriter) {
159 self.coverage.write_into(writer);
160 (u16::try_from(array_len(&self.attach_points)).unwrap()).write_into(writer);
161 self.attach_points.write_into(writer);
162 }
163 fn table_type(&self) -> TableType {
164 TableType::Named("AttachList")
165 }
166}
167
168impl Validate for AttachList {
169 fn validate_impl(&self, ctx: &mut ValidationCtx) {
170 ctx.in_table("AttachList", |ctx| {
171 ctx.in_field("coverage", |ctx| {
172 self.coverage.validate_impl(ctx);
173 });
174 ctx.in_field("attach_points", |ctx| {
175 if self.attach_points.len() > to_usize(u16::MAX) {
176 ctx.report("array exceeds max length");
177 }
178 self.attach_points.validate_impl(ctx);
179 });
180 })
181 }
182}
183
184impl<'a> FromObjRef<read_fonts::tables::gdef::AttachList<'a>> for AttachList {
185 fn from_obj_ref(obj: &read_fonts::tables::gdef::AttachList<'a>, _: FontData) -> Self {
186 AttachList {
187 coverage: obj.coverage().to_owned_table(),
188 attach_points: obj.attach_points().to_owned_table(),
189 }
190 }
191}
192
193#[allow(clippy::needless_lifetimes)]
194impl<'a> FromTableRef<read_fonts::tables::gdef::AttachList<'a>> for AttachList {}
195
196impl ReadArgs for AttachList {
197 type Args = ();
198}
199
200impl<'a> FontRead<'a> for AttachList {
201 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
202 <read_fonts::tables::gdef::AttachList as FontRead>::read(data).map(|x| x.to_owned_table())
203 }
204}
205
206#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
208#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
209pub struct AttachPoint {
210 pub point_indices: Vec<u16>,
212}
213
214impl AttachPoint {
215 pub fn new(point_indices: Vec<u16>) -> Self {
217 Self { point_indices }
218 }
219}
220
221impl FontWrite for AttachPoint {
222 #[allow(clippy::unnecessary_cast)]
223 fn write_into(&self, writer: &mut TableWriter) {
224 (u16::try_from(array_len(&self.point_indices)).unwrap()).write_into(writer);
225 self.point_indices.write_into(writer);
226 }
227 fn table_type(&self) -> TableType {
228 TableType::Named("AttachPoint")
229 }
230}
231
232impl Validate for AttachPoint {
233 fn validate_impl(&self, ctx: &mut ValidationCtx) {
234 ctx.in_table("AttachPoint", |ctx| {
235 ctx.in_field("point_indices", |ctx| {
236 if self.point_indices.len() > to_usize(u16::MAX) {
237 ctx.report("array exceeds max length");
238 }
239 });
240 })
241 }
242}
243
244impl<'a> FromObjRef<read_fonts::tables::gdef::AttachPoint<'a>> for AttachPoint {
245 fn from_obj_ref(obj: &read_fonts::tables::gdef::AttachPoint<'a>, _: FontData) -> Self {
246 let offset_data = obj.offset_data();
247 AttachPoint {
248 point_indices: obj.point_indices().to_owned_obj(offset_data),
249 }
250 }
251}
252
253#[allow(clippy::needless_lifetimes)]
254impl<'a> FromTableRef<read_fonts::tables::gdef::AttachPoint<'a>> for AttachPoint {}
255
256impl ReadArgs for AttachPoint {
257 type Args = ();
258}
259
260impl<'a> FontRead<'a> for AttachPoint {
261 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
262 <read_fonts::tables::gdef::AttachPoint as FontRead>::read(data).map(|x| x.to_owned_table())
263 }
264}
265
266#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
268#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
269pub struct LigCaretList {
270 pub coverage: OffsetMarker<CoverageTable>,
272 pub lig_glyphs: Vec<OffsetMarker<LigGlyph>>,
275}
276
277impl LigCaretList {
278 pub fn new(coverage: CoverageTable, lig_glyphs: Vec<LigGlyph>) -> Self {
280 Self {
281 coverage: coverage.into(),
282 lig_glyphs: lig_glyphs.into_iter().map(Into::into).collect(),
283 }
284 }
285}
286
287impl FontWrite for LigCaretList {
288 #[allow(clippy::unnecessary_cast)]
289 fn write_into(&self, writer: &mut TableWriter) {
290 self.coverage.write_into(writer);
291 (u16::try_from(array_len(&self.lig_glyphs)).unwrap()).write_into(writer);
292 self.lig_glyphs.write_into(writer);
293 }
294 fn table_type(&self) -> TableType {
295 TableType::Named("LigCaretList")
296 }
297}
298
299impl Validate for LigCaretList {
300 fn validate_impl(&self, ctx: &mut ValidationCtx) {
301 ctx.in_table("LigCaretList", |ctx| {
302 ctx.in_field("coverage", |ctx| {
303 self.coverage.validate_impl(ctx);
304 });
305 ctx.in_field("lig_glyphs", |ctx| {
306 if self.lig_glyphs.len() > to_usize(u16::MAX) {
307 ctx.report("array exceeds max length");
308 }
309 self.lig_glyphs.validate_impl(ctx);
310 });
311 })
312 }
313}
314
315impl<'a> FromObjRef<read_fonts::tables::gdef::LigCaretList<'a>> for LigCaretList {
316 fn from_obj_ref(obj: &read_fonts::tables::gdef::LigCaretList<'a>, _: FontData) -> Self {
317 LigCaretList {
318 coverage: obj.coverage().to_owned_table(),
319 lig_glyphs: obj.lig_glyphs().to_owned_table(),
320 }
321 }
322}
323
324#[allow(clippy::needless_lifetimes)]
325impl<'a> FromTableRef<read_fonts::tables::gdef::LigCaretList<'a>> for LigCaretList {}
326
327impl ReadArgs for LigCaretList {
328 type Args = ();
329}
330
331impl<'a> FontRead<'a> for LigCaretList {
332 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
333 <read_fonts::tables::gdef::LigCaretList as FontRead>::read(data).map(|x| x.to_owned_table())
334 }
335}
336
337#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
339#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
340pub struct LigGlyph {
341 pub caret_values: Vec<OffsetMarker<CaretValue>>,
344}
345
346impl LigGlyph {
347 pub fn new(caret_values: Vec<CaretValue>) -> Self {
349 Self {
350 caret_values: caret_values.into_iter().map(Into::into).collect(),
351 }
352 }
353}
354
355impl FontWrite for LigGlyph {
356 #[allow(clippy::unnecessary_cast)]
357 fn write_into(&self, writer: &mut TableWriter) {
358 (u16::try_from(array_len(&self.caret_values)).unwrap()).write_into(writer);
359 self.caret_values.write_into(writer);
360 }
361 fn table_type(&self) -> TableType {
362 TableType::Named("LigGlyph")
363 }
364}
365
366impl Validate for LigGlyph {
367 fn validate_impl(&self, ctx: &mut ValidationCtx) {
368 ctx.in_table("LigGlyph", |ctx| {
369 ctx.in_field("caret_values", |ctx| {
370 if self.caret_values.len() > to_usize(u16::MAX) {
371 ctx.report("array exceeds max length");
372 }
373 self.caret_values.validate_impl(ctx);
374 });
375 })
376 }
377}
378
379impl<'a> FromObjRef<read_fonts::tables::gdef::LigGlyph<'a>> for LigGlyph {
380 fn from_obj_ref(obj: &read_fonts::tables::gdef::LigGlyph<'a>, _: FontData) -> Self {
381 LigGlyph {
382 caret_values: obj.caret_values().to_owned_table(),
383 }
384 }
385}
386
387#[allow(clippy::needless_lifetimes)]
388impl<'a> FromTableRef<read_fonts::tables::gdef::LigGlyph<'a>> for LigGlyph {}
389
390impl ReadArgs for LigGlyph {
391 type Args = ();
392}
393
394impl<'a> FontRead<'a> for LigGlyph {
395 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
396 <read_fonts::tables::gdef::LigGlyph as FontRead>::read(data).map(|x| x.to_owned_table())
397 }
398}
399
400#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
402#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
403pub enum CaretValue {
404 Format1(CaretValueFormat1),
405 Format2(CaretValueFormat2),
406 Format3(CaretValueFormat3),
407}
408
409impl CaretValue {
410 pub fn format_1(coordinate: i16) -> Self {
412 Self::Format1(CaretValueFormat1::new(coordinate))
413 }
414
415 pub fn format_2(caret_value_point_index: u16) -> Self {
417 Self::Format2(CaretValueFormat2::new(caret_value_point_index))
418 }
419
420 pub fn format_3(coordinate: i16, device: DeviceOrVariationIndex) -> Self {
422 Self::Format3(CaretValueFormat3::new(coordinate, device))
423 }
424}
425
426impl Default for CaretValue {
427 fn default() -> Self {
428 Self::Format1(Default::default())
429 }
430}
431
432impl FontWrite for CaretValue {
433 fn write_into(&self, writer: &mut TableWriter) {
434 match self {
435 Self::Format1(item) => item.write_into(writer),
436 Self::Format2(item) => item.write_into(writer),
437 Self::Format3(item) => item.write_into(writer),
438 }
439 }
440 fn table_type(&self) -> TableType {
441 match self {
442 Self::Format1(item) => item.table_type(),
443 Self::Format2(item) => item.table_type(),
444 Self::Format3(item) => item.table_type(),
445 }
446 }
447}
448
449impl Validate for CaretValue {
450 fn validate_impl(&self, ctx: &mut ValidationCtx) {
451 match self {
452 Self::Format1(item) => item.validate_impl(ctx),
453 Self::Format2(item) => item.validate_impl(ctx),
454 Self::Format3(item) => item.validate_impl(ctx),
455 }
456 }
457}
458
459impl FromObjRef<read_fonts::tables::gdef::CaretValue<'_>> for CaretValue {
460 fn from_obj_ref(obj: &read_fonts::tables::gdef::CaretValue, _: FontData) -> Self {
461 use read_fonts::tables::gdef::CaretValue as ObjRefType;
462 match obj {
463 ObjRefType::Format1(item) => CaretValue::Format1(item.to_owned_table()),
464 ObjRefType::Format2(item) => CaretValue::Format2(item.to_owned_table()),
465 ObjRefType::Format3(item) => CaretValue::Format3(item.to_owned_table()),
466 }
467 }
468}
469
470impl FromTableRef<read_fonts::tables::gdef::CaretValue<'_>> for CaretValue {}
471
472impl ReadArgs for CaretValue {
473 type Args = ();
474}
475
476impl<'a> FontRead<'a> for CaretValue {
477 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
478 <read_fonts::tables::gdef::CaretValue as FontRead>::read(data).map(|x| x.to_owned_table())
479 }
480}
481
482impl From<CaretValueFormat1> for CaretValue {
483 fn from(src: CaretValueFormat1) -> CaretValue {
484 CaretValue::Format1(src)
485 }
486}
487
488impl From<CaretValueFormat2> for CaretValue {
489 fn from(src: CaretValueFormat2) -> CaretValue {
490 CaretValue::Format2(src)
491 }
492}
493
494impl From<CaretValueFormat3> for CaretValue {
495 fn from(src: CaretValueFormat3) -> CaretValue {
496 CaretValue::Format3(src)
497 }
498}
499
500#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
502#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
503pub struct CaretValueFormat1 {
504 pub coordinate: i16,
506}
507
508impl CaretValueFormat1 {
509 pub fn new(coordinate: i16) -> Self {
511 Self { coordinate }
512 }
513}
514
515impl FontWrite for CaretValueFormat1 {
516 #[allow(clippy::unnecessary_cast)]
517 fn write_into(&self, writer: &mut TableWriter) {
518 (1 as u16).write_into(writer);
519 self.coordinate.write_into(writer);
520 }
521 fn table_type(&self) -> TableType {
522 TableType::Named("CaretValueFormat1")
523 }
524}
525
526impl Validate for CaretValueFormat1 {
527 fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
528}
529
530impl<'a> FromObjRef<read_fonts::tables::gdef::CaretValueFormat1<'a>> for CaretValueFormat1 {
531 fn from_obj_ref(obj: &read_fonts::tables::gdef::CaretValueFormat1<'a>, _: FontData) -> Self {
532 CaretValueFormat1 {
533 coordinate: obj.coordinate(),
534 }
535 }
536}
537
538#[allow(clippy::needless_lifetimes)]
539impl<'a> FromTableRef<read_fonts::tables::gdef::CaretValueFormat1<'a>> for CaretValueFormat1 {}
540
541impl ReadArgs for CaretValueFormat1 {
542 type Args = ();
543}
544
545impl<'a> FontRead<'a> for CaretValueFormat1 {
546 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
547 <read_fonts::tables::gdef::CaretValueFormat1 as FontRead>::read(data)
548 .map(|x| x.to_owned_table())
549 }
550}
551
552#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
554#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
555pub struct CaretValueFormat2 {
556 pub caret_value_point_index: u16,
558}
559
560impl CaretValueFormat2 {
561 pub fn new(caret_value_point_index: u16) -> Self {
563 Self {
564 caret_value_point_index,
565 }
566 }
567}
568
569impl FontWrite for CaretValueFormat2 {
570 #[allow(clippy::unnecessary_cast)]
571 fn write_into(&self, writer: &mut TableWriter) {
572 (2 as u16).write_into(writer);
573 self.caret_value_point_index.write_into(writer);
574 }
575 fn table_type(&self) -> TableType {
576 TableType::Named("CaretValueFormat2")
577 }
578}
579
580impl Validate for CaretValueFormat2 {
581 fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
582}
583
584impl<'a> FromObjRef<read_fonts::tables::gdef::CaretValueFormat2<'a>> for CaretValueFormat2 {
585 fn from_obj_ref(obj: &read_fonts::tables::gdef::CaretValueFormat2<'a>, _: FontData) -> Self {
586 CaretValueFormat2 {
587 caret_value_point_index: obj.caret_value_point_index(),
588 }
589 }
590}
591
592#[allow(clippy::needless_lifetimes)]
593impl<'a> FromTableRef<read_fonts::tables::gdef::CaretValueFormat2<'a>> for CaretValueFormat2 {}
594
595impl ReadArgs for CaretValueFormat2 {
596 type Args = ();
597}
598
599impl<'a> FontRead<'a> for CaretValueFormat2 {
600 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
601 <read_fonts::tables::gdef::CaretValueFormat2 as FontRead>::read(data)
602 .map(|x| x.to_owned_table())
603 }
604}
605
606#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
608#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
609pub struct CaretValueFormat3 {
610 pub coordinate: i16,
612 pub device: OffsetMarker<DeviceOrVariationIndex>,
616}
617
618impl CaretValueFormat3 {
619 pub fn new(coordinate: i16, device: DeviceOrVariationIndex) -> Self {
621 Self {
622 coordinate,
623 device: device.into(),
624 }
625 }
626}
627
628impl FontWrite for CaretValueFormat3 {
629 #[allow(clippy::unnecessary_cast)]
630 fn write_into(&self, writer: &mut TableWriter) {
631 (3 as u16).write_into(writer);
632 self.coordinate.write_into(writer);
633 self.device.write_into(writer);
634 }
635 fn table_type(&self) -> TableType {
636 TableType::Named("CaretValueFormat3")
637 }
638}
639
640impl Validate for CaretValueFormat3 {
641 fn validate_impl(&self, ctx: &mut ValidationCtx) {
642 ctx.in_table("CaretValueFormat3", |ctx| {
643 ctx.in_field("device", |ctx| {
644 self.device.validate_impl(ctx);
645 });
646 })
647 }
648}
649
650impl<'a> FromObjRef<read_fonts::tables::gdef::CaretValueFormat3<'a>> for CaretValueFormat3 {
651 fn from_obj_ref(obj: &read_fonts::tables::gdef::CaretValueFormat3<'a>, _: FontData) -> Self {
652 CaretValueFormat3 {
653 coordinate: obj.coordinate(),
654 device: obj.device().to_owned_table(),
655 }
656 }
657}
658
659#[allow(clippy::needless_lifetimes)]
660impl<'a> FromTableRef<read_fonts::tables::gdef::CaretValueFormat3<'a>> for CaretValueFormat3 {}
661
662impl ReadArgs for CaretValueFormat3 {
663 type Args = ();
664}
665
666impl<'a> FontRead<'a> for CaretValueFormat3 {
667 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
668 <read_fonts::tables::gdef::CaretValueFormat3 as FontRead>::read(data)
669 .map(|x| x.to_owned_table())
670 }
671}
672
673#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
675#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
676pub struct MarkGlyphSets {
677 pub coverages: Vec<OffsetMarker<CoverageTable, WIDTH_32>>,
680}
681
682impl MarkGlyphSets {
683 pub fn new(coverages: Vec<CoverageTable>) -> Self {
685 Self {
686 coverages: coverages.into_iter().map(Into::into).collect(),
687 }
688 }
689}
690
691impl FontWrite for MarkGlyphSets {
692 #[allow(clippy::unnecessary_cast)]
693 fn write_into(&self, writer: &mut TableWriter) {
694 (1 as u16).write_into(writer);
695 (u16::try_from(array_len(&self.coverages)).unwrap()).write_into(writer);
696 self.coverages.write_into(writer);
697 }
698 fn table_type(&self) -> TableType {
699 TableType::Named("MarkGlyphSets")
700 }
701}
702
703impl Validate for MarkGlyphSets {
704 fn validate_impl(&self, ctx: &mut ValidationCtx) {
705 ctx.in_table("MarkGlyphSets", |ctx| {
706 ctx.in_field("coverages", |ctx| {
707 if self.coverages.len() > to_usize(u16::MAX) {
708 ctx.report("array exceeds max length");
709 }
710 self.coverages.validate_impl(ctx);
711 });
712 })
713 }
714}
715
716impl<'a> FromObjRef<read_fonts::tables::gdef::MarkGlyphSets<'a>> for MarkGlyphSets {
717 fn from_obj_ref(obj: &read_fonts::tables::gdef::MarkGlyphSets<'a>, _: FontData) -> Self {
718 MarkGlyphSets {
719 coverages: obj.coverages().to_owned_table(),
720 }
721 }
722}
723
724#[allow(clippy::needless_lifetimes)]
725impl<'a> FromTableRef<read_fonts::tables::gdef::MarkGlyphSets<'a>> for MarkGlyphSets {}
726
727impl ReadArgs for MarkGlyphSets {
728 type Args = ();
729}
730
731impl<'a> FontRead<'a> for MarkGlyphSets {
732 fn read_with_args(data: FontData<'a>, _: ()) -> Result<Self, ReadError> {
733 <read_fonts::tables::gdef::MarkGlyphSets as FontRead>::read(data)
734 .map(|x| x.to_owned_table())
735 }
736}