-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[skrifa] autohint: public GlyphStyles type (#1086)
Exposes the glyph style map as a public type and wrapped in an `Arc` to make it shareable among multiple autohinting instances.
- Loading branch information
Showing
4 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
//! Autohinting state for a font instance. | ||
|
||
use super::{super::OutlineGlyphCollection, style::GlyphStyleMap}; | ||
use crate::MetadataProvider; | ||
use alloc::sync::Arc; | ||
use raw::TableProvider; | ||
|
||
/// Set of derived glyph styles that are used for automatic hinting. | ||
/// | ||
/// These are invariant per font so can be precomputed and reused for multiple | ||
/// instances when requesting automatic hinting. | ||
#[derive(Clone, Debug)] | ||
pub struct GlyphStyles(Arc<GlyphStyleMap>); | ||
|
||
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 | ||
.maxp() | ||
.map(|maxp| maxp.num_glyphs() as u32) | ||
.unwrap_or_default(); | ||
Self(Arc::new(GlyphStyleMap::new( | ||
glyph_count, | ||
&outlines.font.charmap(), | ||
))) | ||
} else { | ||
Self(Default::default()) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters