#[allow(unused_imports)]
use crate::codegen_prelude::*;
#[derive(Clone, Debug, Default)]
pub struct Vmtx {
pub v_metrics: Vec<LongMetric>,
pub top_side_bearings: Vec<i16>,
}
impl Vmtx {
pub fn new(v_metrics: Vec<LongMetric>, top_side_bearings: Vec<i16>) -> Self {
Self {
v_metrics: v_metrics.into_iter().map(Into::into).collect(),
top_side_bearings: top_side_bearings.into_iter().map(Into::into).collect(),
}
}
}
impl FontWrite for Vmtx {
fn write_into(&self, writer: &mut TableWriter) {
self.v_metrics.write_into(writer);
self.top_side_bearings.write_into(writer);
}
}
impl Validate for Vmtx {
fn validate_impl(&self, ctx: &mut ValidationCtx) {
ctx.in_table("Vmtx", |ctx| {
ctx.in_field("v_metrics", |ctx| {
if self.v_metrics.len() > (u16::MAX as usize) {
ctx.report("array excedes max length");
}
self.v_metrics.validate_impl(ctx);
});
})
}
}
impl TopLevelTable for Vmtx {
const TAG: Tag = Tag::new(b"vmtx");
}
impl<'a> FromObjRef<read_fonts::tables::vmtx::Vmtx<'a>> for Vmtx {
fn from_obj_ref(obj: &read_fonts::tables::vmtx::Vmtx<'a>, _: FontData) -> Self {
let offset_data = obj.offset_data();
Vmtx {
v_metrics: obj.v_metrics().to_owned_obj(offset_data),
top_side_bearings: obj.top_side_bearings().to_owned_obj(offset_data),
}
}
}
impl<'a> FromTableRef<read_fonts::tables::vmtx::Vmtx<'a>> for Vmtx {}