From 2b2a7cb1e712b5a6ad88819ff8b26bb4e91b6ea3 Mon Sep 17 00:00:00 2001 From: Chad Brokaw Date: Tue, 10 Dec 2024 12:24:40 -0500 Subject: [PATCH 1/3] [skrifa] remove ugly OutlinesCommon abstraction Just embeds the `FontRef` and a new `GlyphHMetrics` type for common access to horizontal glyph metrics. Also adds a method to retrieving the cvt to `TableProvider`. No functional changes. --- read-fonts/src/table_provider.rs | 9 +++- skrifa/src/outline/autohint/instance.rs | 11 +++-- skrifa/src/outline/cff/hint.rs | 8 ++-- skrifa/src/outline/cff/mod.rs | 40 +++++++++--------- skrifa/src/outline/glyf/hint/instance.rs | 12 ++---- skrifa/src/outline/glyf/mod.rs | 43 +++++++++++--------- skrifa/src/outline/hint.rs | 2 +- skrifa/src/outline/{common.rs => metrics.rs} | 29 +++---------- skrifa/src/outline/mod.rs | 39 ++++++++---------- 9 files changed, 88 insertions(+), 105 deletions(-) rename skrifa/src/outline/{common.rs => metrics.rs} (64%) diff --git a/read-fonts/src/table_provider.rs b/read-fonts/src/table_provider.rs index 6a9191a86..5d6f1f5b7 100644 --- a/read-fonts/src/table_provider.rs +++ b/read-fonts/src/table_provider.rs @@ -1,6 +1,6 @@ //! a trait for things that can serve font tables -use types::Tag; +use types::{BigEndian, Tag}; use crate::{tables, FontData, FontRead, ReadError}; @@ -120,6 +120,13 @@ pub trait TableProvider<'a> { self.expect_table() } + /// Returns the array of entries for the control value table which is used + /// for TrueType hinting. + fn cvt(&self) -> Result<&'a [BigEndian], ReadError> { + let table_data = self.expect_data_for_tag(Tag::new(b"cvt "))?; + table_data.read_array(0..table_data.len()) + } + fn cvar(&self) -> Result, ReadError> { self.expect_table() } diff --git a/skrifa/src/outline/autohint/instance.rs b/skrifa/src/outline/autohint/instance.rs index e81b106f4..cf1e408b7 100644 --- a/skrifa/src/outline/autohint/instance.rs +++ b/skrifa/src/outline/autohint/instance.rs @@ -36,13 +36,12 @@ pub struct GlyphStyles(Arc); impl GlyphStyles { /// Precomputes the full set of glyph styles for the given outlines. pub fn new(outlines: &OutlineGlyphCollection) -> Self { - if let Some(outlines) = outlines.common() { - let glyph_count = outlines - .font + if let Some(font) = outlines.font() { + let glyph_count = font .maxp() .map(|maxp| maxp.num_glyphs() as u32) .unwrap_or_default(); - let shaper = Shaper::new(&outlines.font, SHAPER_MODE); + let shaper = Shaper::new(font, SHAPER_MODE); Self(Arc::new(GlyphStyleMap::new(glyph_count, &shaper))) } else { Self(Default::default()) @@ -99,7 +98,7 @@ impl Instance { path_style: PathStyle, pen: &mut impl OutlinePen, ) -> Result { - let common = glyph.outlines_common(); + let font = glyph.font(); let glyph_id = glyph.glyph_id(); let style = self .styles @@ -108,7 +107,7 @@ impl Instance { .ok_or(DrawError::GlyphNotFound(glyph_id))?; let metrics = self .metrics - .get(&common.font, coords, SHAPER_MODE, &self.styles.0, glyph_id) + .get(font, coords, SHAPER_MODE, &self.styles.0, glyph_id) .ok_or(DrawError::GlyphNotFound(glyph_id))?; let units_per_em = glyph.units_per_em() as i32; let scale = Scale::new( diff --git a/skrifa/src/outline/cff/hint.rs b/skrifa/src/outline/cff/hint.rs index d8d55a9fe..26fcf07ef 100644 --- a/skrifa/src/outline/cff/hint.rs +++ b/skrifa/src/outline/cff/hint.rs @@ -1108,9 +1108,8 @@ mod tests { use read_fonts::{tables::postscript::charstring::CommandSink, types::F2Dot14, FontRef}; use super::{ - super::OutlinesCommon, BlueZone, Blues, Fixed, Hint, HintMap, HintMask, HintParams, - HintState, HintingSink, StemHint, GHOST_BOTTOM, GHOST_TOP, HINT_MASK_SIZE, LOCKED, - PAIR_BOTTOM, PAIR_TOP, + BlueZone, Blues, Fixed, Hint, HintMap, HintMask, HintParams, HintState, HintingSink, + StemHint, GHOST_BOTTOM, GHOST_TOP, HINT_MASK_SIZE, LOCKED, PAIR_BOTTOM, PAIR_TOP, }; fn make_hint_state() -> HintState { @@ -1306,8 +1305,7 @@ mod tests { #[test] fn hint_mapping() { let font = FontRef::new(font_test_data::CANTARELL_VF_TRIMMED).unwrap(); - let base = OutlinesCommon::new(&font).unwrap(); - let cff_font = super::super::Outlines::new(&base).unwrap(); + let cff_font = super::super::Outlines::new(&font).unwrap(); let state = cff_font .subfont(0, Some(8.0), &[F2Dot14::from_f32(-1.0); 2]) .unwrap() diff --git a/skrifa/src/outline/cff/mod.rs b/skrifa/src/outline/cff/mod.rs index 03d8fb4e3..cc71eaac3 100644 --- a/skrifa/src/outline/cff/mod.rs +++ b/skrifa/src/outline/cff/mod.rs @@ -2,8 +2,9 @@ mod hint; -use super::{common::OutlinesCommon, OutlinePen}; +use super::{GlyphHMetrics, OutlinePen}; use hint::{HintParams, HintState, HintingSink}; +use raw::FontRef; use read_fonts::{ tables::{ postscript::{ @@ -36,7 +37,8 @@ use std::ops::Range; /// subfont for that glyph. #[derive(Clone)] pub(crate) struct Outlines<'a> { - pub(crate) common: OutlinesCommon<'a>, + pub(crate) font: FontRef<'a>, + pub(crate) glyph_metrics: GlyphHMetrics<'a>, offset_data: FontData<'a>, global_subrs: Index<'a>, top_dict: TopDict<'a>, @@ -49,13 +51,14 @@ impl<'a> Outlines<'a> { /// /// This will choose an underlying CFF2 or CFF table from the font, in that /// order. - pub fn new(common: &OutlinesCommon<'a>) -> Option { - let units_per_em = common.font.head().ok()?.units_per_em(); - Self::from_cff2(common, units_per_em).or_else(|| Self::from_cff(common, units_per_em)) + pub fn new(font: &FontRef<'a>) -> Option { + let units_per_em = font.head().ok()?.units_per_em(); + Self::from_cff2(font, units_per_em).or_else(|| Self::from_cff(font, units_per_em)) } - pub fn from_cff(common: &OutlinesCommon<'a>, units_per_em: u16) -> Option { - let cff1 = common.font.cff().ok()?; + pub fn from_cff(font: &FontRef<'a>, units_per_em: u16) -> Option { + let cff1 = font.cff().ok()?; + let glyph_metrics = GlyphHMetrics::new(font)?; // "The Name INDEX in the CFF data must contain only one entry; // that is, there must be only one font in the CFF FontSet" // So we always pass 0 for Top DICT index when reading from an @@ -64,7 +67,8 @@ impl<'a> Outlines<'a> { let top_dict_data = cff1.top_dicts().get(0).ok()?; let top_dict = TopDict::new(cff1.offset_data().as_bytes(), top_dict_data, false).ok()?; Some(Self { - common: common.clone(), + font: font.clone(), + glyph_metrics, offset_data: cff1.offset_data(), global_subrs: cff1.global_subrs().into(), top_dict, @@ -73,12 +77,14 @@ impl<'a> Outlines<'a> { }) } - pub fn from_cff2(common: &OutlinesCommon<'a>, units_per_em: u16) -> Option { - let cff2 = common.font.cff2().ok()?; + pub fn from_cff2(font: &FontRef<'a>, units_per_em: u16) -> Option { + let cff2 = font.cff2().ok()?; + let glyph_metrics = GlyphHMetrics::new(font)?; let table_data = cff2.offset_data().as_bytes(); let top_dict = TopDict::new(table_data, cff2.top_dict_data(), true).ok()?; Some(Self { - common: common.clone(), + font: font.clone(), + glyph_metrics, offset_data: cff2.offset_data(), global_subrs: cff2.global_subrs().into(), top_dict, @@ -656,8 +662,7 @@ mod tests { #[test] fn read_cff_static() { let font = FontRef::new(font_test_data::NOTO_SERIF_DISPLAY_TRIMMED).unwrap(); - let base = OutlinesCommon::new(&font).unwrap(); - let cff = Outlines::new(&base).unwrap(); + let cff = Outlines::new(&font).unwrap(); assert!(!cff.is_cff2()); assert!(cff.top_dict.var_store.is_none()); assert!(cff.top_dict.font_dicts.count() == 0); @@ -671,8 +676,7 @@ mod tests { #[test] fn read_cff2_static() { let font = FontRef::new(font_test_data::CANTARELL_VF_TRIMMED).unwrap(); - let base = OutlinesCommon::new(&font).unwrap(); - let cff = Outlines::new(&base).unwrap(); + let cff = Outlines::new(&font).unwrap(); assert!(cff.is_cff2()); assert!(cff.top_dict.var_store.is_some()); assert!(cff.top_dict.font_dicts.count() != 0); @@ -741,8 +745,7 @@ mod tests { #[test] fn empty_private_dict() { let font = FontRef::new(font_test_data::MATERIAL_ICONS_SUBSET).unwrap(); - let common = OutlinesCommon::new(&font).unwrap(); - let outlines = super::Outlines::new(&common).unwrap(); + let outlines = super::Outlines::new(&font).unwrap(); assert!(outlines.top_dict.private_dict_range.is_empty()); assert!(outlines.private_dict_range(0).unwrap().is_empty()); } @@ -810,8 +813,7 @@ mod tests { use super::super::testing; let font = FontRef::new(font_data).unwrap(); let expected_outlines = testing::parse_glyph_outlines(expected_outlines); - let base = OutlinesCommon::new(&font).unwrap(); - let outlines = super::Outlines::new(&base).unwrap(); + let outlines = super::Outlines::new(&font).unwrap(); let mut path = testing::Path::default(); for expected_outline in &expected_outlines { if expected_outline.size == 0.0 && !expected_outline.coords.is_empty() { diff --git a/skrifa/src/outline/glyf/hint/instance.rs b/skrifa/src/outline/glyf/hint/instance.rs index 714feca95..dc61136dc 100644 --- a/skrifa/src/outline/glyf/hint/instance.rs +++ b/skrifa/src/outline/glyf/hint/instance.rs @@ -191,8 +191,8 @@ impl HintInstance { Definition::default(), ); self.cvt.clear(); - let cvt = outlines.common.cvt(); - if let Ok(cvar) = outlines.common.font.cvar() { + let cvt = outlines.font.cvt().unwrap_or_default(); + if let Ok(cvar) = outlines.font.cvar() { // First accumulate all the deltas in 16.16 self.cvt.resize(cvt.len(), 0); let _ = cvar.deltas(axis_count, coords, &mut self.cvt); @@ -237,17 +237,13 @@ impl HintInstance { #[cfg(test)] mod tests { - use super::{ - super::super::{Outlines, OutlinesCommon}, - HintInstance, - }; + use super::{super::super::Outlines, HintInstance}; use read_fonts::{types::F2Dot14, FontRef}; #[test] fn scaled_cvar_cvt() { let font = FontRef::new(font_test_data::CVAR).unwrap(); - let base = OutlinesCommon::new(&font).unwrap(); - let outlines = Outlines::new(&base).unwrap(); + let outlines = Outlines::new(&font).unwrap(); let mut instance = HintInstance::default(); let coords = [0.5, -0.5].map(F2Dot14::from_f32); let ppem = 16; diff --git a/skrifa/src/outline/glyf/mod.rs b/skrifa/src/outline/glyf/mod.rs index ff35fcf25..0bf650f79 100644 --- a/skrifa/src/outline/glyf/mod.rs +++ b/skrifa/src/outline/glyf/mod.rs @@ -11,8 +11,9 @@ use core_maths::CoreFloat; pub use hint::{HintError, HintInstance, HintOutline}; pub use outline::{Outline, ScaledOutline}; +use raw::FontRef; -use super::{common::OutlinesCommon, DrawError, Hinting}; +use super::{DrawError, GlyphHMetrics, Hinting}; use crate::GLYF_COMPOSITE_RECURSION_LIMIT; use memory::{FreeTypeOutlineMemory, HarfBuzzOutlineMemory}; @@ -35,7 +36,8 @@ pub const PHANTOM_POINT_COUNT: usize = 4; /// Scaler state for TrueType outlines. #[derive(Clone)] pub struct Outlines<'a> { - pub(crate) common: OutlinesCommon<'a>, + pub(crate) font: FontRef<'a>, + pub(crate) glyph_metrics: GlyphHMetrics<'a>, loca: Loca<'a>, glyf: Glyf<'a>, gvar: Option>, @@ -56,9 +58,11 @@ pub struct Outlines<'a> { } impl<'a> Outlines<'a> { - pub fn new(common: &OutlinesCommon<'a>) -> Option { - let font = &common.font; - let has_var_lsb = common + pub fn new(font: &FontRef<'a>) -> Option { + let loca = font.loca(None).ok()?; + let glyf = font.glyf().ok()?; + let glyph_metrics = GlyphHMetrics::new(font)?; + let has_var_lsb = glyph_metrics .hvar .as_ref() .map(|hvar| hvar.lsb_mapping().is_some()) @@ -108,11 +112,12 @@ impl<'a> Outlines<'a> { // Copy FreeType's logic on whether to use the interpreter: // let prefer_interpreter = !(max_instructions == 0 && fpgm.is_empty() && prep.is_empty()); - let cvt_len = common.cvt().len() as u32; + let cvt_len = font.cvt().map(|cvt| cvt.len() as u32).unwrap_or_default(); Some(Self { - common: common.clone(), - loca: font.loca(None).ok()?, - glyf: font.glyf().ok()?, + font: font.clone(), + glyph_metrics, + loca, + glyf, gvar: font.gvar().ok(), hdmx: font.hdmx().ok(), fpgm, @@ -286,8 +291,8 @@ trait Scaler { }; let outlines = self.outlines(); let coords: &[F2Dot14] = self.coords(); - let lsb = outlines.common.lsb(glyph_id, coords); - let advance = outlines.common.advance_width(glyph_id, coords); + let lsb = outlines.glyph_metrics.lsb(glyph_id, coords); + let advance = outlines.glyph_metrics.advance_width(glyph_id, coords); let [ascent, descent] = outlines.os2_vmetrics.map(|x| x as i32); let tsb = ascent - bounds[3] as i32; let vadvance = ascent - descent; @@ -494,7 +499,7 @@ impl Scaler for FreeTypeScaler<'_> { // let scale = self.scale; let mut unscaled = self.phantom.map(|point| point.map(|x| x.to_bits())); - if self.outlines.common.hvar.is_none() + if self.outlines.glyph_metrics.hvar.is_none() && self.outlines.gvar.is_some() && !self.coords.is_empty() { @@ -646,7 +651,7 @@ impl Scaler for FreeTypeScaler<'_> { } } // Commit our potentially modified phantom points. - if self.outlines.common.hvar.is_some() && self.is_hinted { + if self.outlines.glyph_metrics.hvar.is_some() && self.is_hinted { self.phantom[0] *= self.scale; self.phantom[1] *= self.scale; } else { @@ -1015,7 +1020,7 @@ impl Scaler for HarfBuzzScaler<'_> { // FreeType version above but changed to use floating point let scale = self.scale.to_f32(); let mut unscaled = self.phantom; - if self.outlines.common.hvar.is_none() + if self.outlines.glyph_metrics.hvar.is_none() && self.outlines.gvar.is_some() && !self.coords.is_empty() { @@ -1284,7 +1289,7 @@ mod tests { #[test] fn overlap_flags() { let font = FontRef::new(font_test_data::VAZIRMATN_VAR).unwrap(); - let scaler = Outlines::new(&OutlinesCommon::new(&font).unwrap()).unwrap(); + let scaler = Outlines::new(&font).unwrap(); let glyph_count = font.maxp().unwrap().num_glyphs(); // GID 2 is a composite glyph with the overlap bit on a component // GID 3 is a simple glyph with the overlap bit on the first flag @@ -1301,12 +1306,12 @@ mod tests { fn interpreter_preference() { // no instructions in this font... let font = FontRef::new(font_test_data::COLRV0V1).unwrap(); - let outlines = Outlines::new(&OutlinesCommon::new(&font).unwrap()).unwrap(); + let outlines = Outlines::new(&font).unwrap(); // thus no preference for the interpreter assert!(!outlines.prefer_interpreter()); // but this one has instructions... let font = FontRef::new(font_test_data::TTHINT_SUBSET).unwrap(); - let outlines = Outlines::new(&OutlinesCommon::new(&font).unwrap()).unwrap(); + let outlines = Outlines::new(&font).unwrap(); // so let's use it assert!(outlines.prefer_interpreter()); } @@ -1314,7 +1319,7 @@ mod tests { #[test] fn empty_glyph_advance() { let font = FontRef::new(font_test_data::HVAR_WITH_TRUNCATED_ADVANCE_INDEX_MAP).unwrap(); - let mut outlines = Outlines::new(&OutlinesCommon::new(&font).unwrap()).unwrap(); + let mut outlines = Outlines::new(&font).unwrap(); let coords = [F2Dot14::from_f32(0.5)]; let ppem = Some(24.0); let gid = font.charmap().map(' ').unwrap(); @@ -1325,7 +1330,7 @@ mod tests { let scaled = scaler.scale(&outline.glyph, gid).unwrap(); let advance_hvar = scaled.adjusted_advance_width(); // Set HVAR table to None to force loading metrics from gvar - outlines.common.hvar = None; + outlines.glyph_metrics.hvar = None; let scaler = FreeTypeScaler::unhinted(&outlines, &outline, &mut [], ppem, &coords).unwrap(); let scaled = scaler.scale(&outline.glyph, gid).unwrap(); let advance_gvar = scaled.adjusted_advance_width(); diff --git a/skrifa/src/outline/hint.rs b/skrifa/src/outline/hint.rs index b5ffe94ee..37eb6965a 100644 --- a/skrifa/src/outline/hint.rs +++ b/skrifa/src/outline/hint.rs @@ -368,7 +368,7 @@ impl HintingInstance { OutlineCollectionKind::None => {} }, Engine::Auto(styles) => { - let Some(font) = outlines.common().map(|scaler| &scaler.font) else { + let Some(font) = outlines.font() else { return Ok(()); }; let instance = autohint::Instance::new( diff --git a/skrifa/src/outline/common.rs b/skrifa/src/outline/metrics.rs similarity index 64% rename from skrifa/src/outline/common.rs rename to skrifa/src/outline/metrics.rs index 8e98f4a7c..7e2eb6b22 100644 --- a/skrifa/src/outline/common.rs +++ b/skrifa/src/outline/metrics.rs @@ -1,32 +1,24 @@ -//! Common functionality for glyf, cff and autohinting scalers. -//! -//! Currently this includes the font reference as well as horizontal glyph -//! metrics and access to the control value table. +//! Helper for loading (possibly variable) horizontal glyph metrics. use raw::{ tables::{hmtx::Hmtx, hvar::Hvar}, - types::{BigEndian, F2Dot14, GlyphId, Tag}, + types::{F2Dot14, GlyphId}, FontRef, TableProvider, }; -/// Common functionality for glyf, cff and autohinting scalers. +/// Access to horizontal glyph metrics. #[derive(Clone)] -pub(crate) struct OutlinesCommon<'a> { - pub font: FontRef<'a>, +pub(crate) struct GlyphHMetrics<'a> { pub hmtx: Hmtx<'a>, pub hvar: Option>, } -impl<'a> OutlinesCommon<'a> { +impl<'a> GlyphHMetrics<'a> { pub fn new(font: &FontRef<'a>) -> Option { // Note: hmtx is required and HVAR is optional let hmtx = font.hmtx().ok()?; let hvar = font.hvar().ok(); - Some(Self { - font: font.clone(), - hmtx, - hvar, - }) + Some(Self { hmtx, hvar }) } /// Returns the advance width (in font units) for the given glyph and @@ -56,13 +48,4 @@ impl<'a> OutlinesCommon<'a> { } lsb } - - /// Returns the array of entries for the control value table which is used - /// for TrueType hinting. - pub fn cvt(&self) -> &[BigEndian] { - self.font - .data_for_tag(Tag::new(b"cvt ")) - .and_then(|d| d.read_array(0..d.len()).ok()) - .unwrap_or_default() - } } diff --git a/skrifa/src/outline/mod.rs b/skrifa/src/outline/mod.rs index 63f641c3d..c63602a33 100644 --- a/skrifa/src/outline/mod.rs +++ b/skrifa/src/outline/mod.rs @@ -80,9 +80,9 @@ mod autohint; mod cff; -mod common; mod glyf; mod hint; +mod metrics; mod path; mod unscaled; @@ -92,12 +92,11 @@ mod testing; pub mod error; pub mod pen; -use common::OutlinesCommon; - pub use autohint::GlyphStyles; pub use hint::{ Engine, HintingInstance, HintingMode, HintingOptions, LcdLayout, SmoothMode, Target, }; +use metrics::GlyphHMetrics; use raw::FontRef; #[doc(inline)] pub use {error::DrawError, pen::OutlinePen}; @@ -469,17 +468,16 @@ impl<'a> OutlineGlyph<'a> { let mut adapter = unscaled::UnscaledPenAdapter::new(sink); cff.draw(&subfont, *glyph_id, coords, false, &mut adapter)?; adapter.finish()?; - let advance = cff.common.advance_width(*glyph_id, coords); + let advance = cff.glyph_metrics.advance_width(*glyph_id, coords); Ok(advance) } } } - #[allow(dead_code)] - pub(crate) fn outlines_common(&self) -> &OutlinesCommon<'a> { + pub(crate) fn font(&self) -> &FontRef<'a> { match &self.kind { - OutlineKind::Glyf(glyf, ..) => &glyf.common, - OutlineKind::Cff(cff, ..) => &cff.common, + OutlineKind::Glyf(glyf, ..) => &glyf.font, + OutlineKind::Cff(cff, ..) => &cff.font, } } @@ -520,14 +518,10 @@ pub struct OutlineGlyphCollection<'a> { impl<'a> OutlineGlyphCollection<'a> { /// Creates a new outline collection for the given font. pub fn new(font: &FontRef<'a>) -> Self { - let kind = if let Some(common) = OutlinesCommon::new(font) { - if let Some(glyf) = glyf::Outlines::new(&common) { - OutlineCollectionKind::Glyf(glyf) - } else if let Some(cff) = cff::Outlines::new(&common) { - OutlineCollectionKind::Cff(cff) - } else { - OutlineCollectionKind::None - } + let kind = if let Some(glyf) = glyf::Outlines::new(font) { + OutlineCollectionKind::Glyf(glyf) + } else if let Some(cff) = cff::Outlines::new(font) { + OutlineCollectionKind::Cff(cff) } else { OutlineCollectionKind::None }; @@ -540,16 +534,15 @@ impl<'a> OutlineGlyphCollection<'a> { /// Returns `None` if the font does not contain outlines in the requested /// format. pub fn with_format(font: &FontRef<'a>, format: OutlineGlyphFormat) -> Option { - let common = OutlinesCommon::new(font)?; let kind = match format { - OutlineGlyphFormat::Glyf => OutlineCollectionKind::Glyf(glyf::Outlines::new(&common)?), + OutlineGlyphFormat::Glyf => OutlineCollectionKind::Glyf(glyf::Outlines::new(font)?), OutlineGlyphFormat::Cff => { let upem = font.head().ok()?.units_per_em(); - OutlineCollectionKind::Cff(cff::Outlines::from_cff(&common, upem)?) + OutlineCollectionKind::Cff(cff::Outlines::from_cff(font, upem)?) } OutlineGlyphFormat::Cff2 => { let upem = font.head().ok()?.units_per_em(); - OutlineCollectionKind::Cff(cff::Outlines::from_cff2(&common, upem)?) + OutlineCollectionKind::Cff(cff::Outlines::from_cff2(font, upem)?) } }; Some(Self { kind }) @@ -615,10 +608,10 @@ impl<'a> OutlineGlyphCollection<'a> { } } - pub(crate) fn common(&self) -> Option<&OutlinesCommon<'a>> { + pub(crate) fn font(&self) -> Option<&FontRef<'a>> { match &self.kind { - OutlineCollectionKind::Glyf(glyf) => Some(&glyf.common), - OutlineCollectionKind::Cff(cff) => Some(&cff.common), + OutlineCollectionKind::Glyf(glyf) => Some(&glyf.font), + OutlineCollectionKind::Cff(cff) => Some(&cff.font), _ => None, } } From c2136003ee219350b2700673a5318b919c43b929 Mon Sep 17 00:00:00 2001 From: Chad Brokaw Date: Wed, 11 Dec 2024 14:35:59 -0500 Subject: [PATCH 2/3] fix rebase --- skrifa/src/outline/glyf/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/skrifa/src/outline/glyf/mod.rs b/skrifa/src/outline/glyf/mod.rs index e60422f90..cd6754004 100644 --- a/skrifa/src/outline/glyf/mod.rs +++ b/skrifa/src/outline/glyf/mod.rs @@ -1330,7 +1330,7 @@ mod tests { let advance_hvar = scaled.adjusted_advance_width(); // Set HVAR table to None to force loading metrics from gvar outlines.glyph_metrics.hvar = None; - let scaler = FreeTypeScaler::unhinted(&outlines, &outline, &mut [], ppem, &coords).unwrap(); + let scaler = FreeTypeScaler::unhinted(&outlines, &outline, &mut buf, ppem, &coords).unwrap(); let scaled = scaler.scale(&outline.glyph, gid).unwrap(); let advance_gvar = scaled.adjusted_advance_width(); // Make sure we have an advance and that the two are the same From e93238686ba7890ae6b66df86488678c01d7df11 Mon Sep 17 00:00:00 2001 From: Chad Brokaw Date: Wed, 11 Dec 2024 14:45:30 -0500 Subject: [PATCH 3/3] and... fmt --- skrifa/src/outline/glyf/mod.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/skrifa/src/outline/glyf/mod.rs b/skrifa/src/outline/glyf/mod.rs index cd6754004..31c228fdb 100644 --- a/skrifa/src/outline/glyf/mod.rs +++ b/skrifa/src/outline/glyf/mod.rs @@ -1330,7 +1330,8 @@ mod tests { let advance_hvar = scaled.adjusted_advance_width(); // Set HVAR table to None to force loading metrics from gvar outlines.glyph_metrics.hvar = None; - let scaler = FreeTypeScaler::unhinted(&outlines, &outline, &mut buf, ppem, &coords).unwrap(); + let scaler = + FreeTypeScaler::unhinted(&outlines, &outline, &mut buf, ppem, &coords).unwrap(); let scaled = scaler.scale(&outline.glyph, gid).unwrap(); let advance_gvar = scaled.adjusted_advance_width(); // Make sure we have an advance and that the two are the same