#[allow(unused_imports)]
use crate::codegen_prelude::*;
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Vorg {
pub default_vert_origin_y: i16,
pub vert_origin_y_metrics: Vec<VertOriginYMetrics>,
}
impl Vorg {
pub fn new(default_vert_origin_y: i16, vert_origin_y_metrics: Vec<VertOriginYMetrics>) -> Self {
Self {
default_vert_origin_y,
vert_origin_y_metrics,
}
}
}
impl FontWrite for Vorg {
#[allow(clippy::unnecessary_cast)]
fn write_into(&self, writer: &mut TableWriter) {
(MajorMinor::VERSION_1_0 as MajorMinor).write_into(writer);
self.default_vert_origin_y.write_into(writer);
(u16::try_from(array_len(&self.vert_origin_y_metrics)).unwrap()).write_into(writer);
self.vert_origin_y_metrics.write_into(writer);
}
fn table_type(&self) -> TableType {
TableType::TopLevel(Vorg::TAG)
}
}
impl Validate for Vorg {
fn validate_impl(&self, ctx: &mut ValidationCtx) {
ctx.in_table("Vorg", |ctx| {
ctx.in_field("vert_origin_y_metrics", |ctx| {
if self.vert_origin_y_metrics.len() > (u16::MAX as usize) {
ctx.report("array exceeds max length");
}
self.vert_origin_y_metrics.validate_impl(ctx);
});
})
}
}
impl TopLevelTable for Vorg {
const TAG: Tag = Tag::new(b"VORG");
}
impl<'a> FromObjRef<read_fonts::tables::vorg::Vorg<'a>> for Vorg {
fn from_obj_ref(obj: &read_fonts::tables::vorg::Vorg<'a>, _: FontData) -> Self {
let offset_data = obj.offset_data();
Vorg {
default_vert_origin_y: obj.default_vert_origin_y(),
vert_origin_y_metrics: obj.vert_origin_y_metrics().to_owned_obj(offset_data),
}
}
}
#[allow(clippy::needless_lifetimes)]
impl<'a> FromTableRef<read_fonts::tables::vorg::Vorg<'a>> for Vorg {}
impl<'a> FontRead<'a> for Vorg {
fn read(data: FontData<'a>) -> Result<Self, ReadError> {
<read_fonts::tables::vorg::Vorg as FontRead>::read(data).map(|x| x.to_owned_table())
}
}
#[derive(Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct VertOriginYMetrics {
pub glyph_index: GlyphId16,
pub vert_origin_y: i16,
}
impl VertOriginYMetrics {
pub fn new(glyph_index: GlyphId16, vert_origin_y: i16) -> Self {
Self {
glyph_index,
vert_origin_y,
}
}
}
impl FontWrite for VertOriginYMetrics {
fn write_into(&self, writer: &mut TableWriter) {
self.glyph_index.write_into(writer);
self.vert_origin_y.write_into(writer);
}
fn table_type(&self) -> TableType {
TableType::Named("VertOriginYMetrics")
}
}
impl Validate for VertOriginYMetrics {
fn validate_impl(&self, _ctx: &mut ValidationCtx) {}
}
impl FromObjRef<read_fonts::tables::vorg::VertOriginYMetrics> for VertOriginYMetrics {
fn from_obj_ref(obj: &read_fonts::tables::vorg::VertOriginYMetrics, _: FontData) -> Self {
VertOriginYMetrics {
glyph_index: obj.glyph_index(),
vert_origin_y: obj.vert_origin_y(),
}
}
}