pub struct Outline<S: Scale> {
points: Vec<Point<S::Coord>>,
flags: Vec<PointFlags>,
contours: Vec<u16>,
phantom: [Point<S::Coord>; 4],
unscaled: Vec<Point<i32>>,
deltas: Vec<Point<S::Delta>>,
iup: Vec<Point<S::Delta>>,
composite_deltas: Vec<Point<S::Delta>>,
point_count: u32,
contour_count: u32,
}Expand description
An outline and the buffers that hold it.
OutlinePlan::load requires the caller to size and supply seven
buffers. This owns them, grows them as needed and reuses them across
glyphs, so loading stops allocating after the first few.
Loading returns an OutlineRef borrowing those buffers. The same data is
reachable through points and its neighbours once that
borrow ends.
use read_fonts::{
tables::glyf::outline::{Outline, OutlineTables, Scale26Dot6},
types::GlyphId,
FontRef,
};
let font = FontRef::new(font_test_data::COLRV0V1_VARIABLE)?;
let tables = OutlineTables::new(&font)?;
let mut outline = Outline::<Scale26Dot6>::new();
// Borrows `outline`'s buffers for as long as it is held.
let loaded = outline.load(&tables, GlyphId::new(1), Some(16.0))?;
for (point, flags) in loaded.points().iter().zip(loaded.flags()) {
let _ = (point, flags.is_off_curve_quad());
}
// Once it is dropped, the outline can be read through its accessors.
assert_eq!(outline.points().len(), outline.flags().len());Fields§
§points: Vec<Point<S::Coord>>§flags: Vec<PointFlags>§contours: Vec<u16>§phantom: [Point<S::Coord>; 4]§unscaled: Vec<Point<i32>>§deltas: Vec<Point<S::Delta>>§iup: Vec<Point<S::Delta>>§composite_deltas: Vec<Point<S::Delta>>§point_count: u32§contour_count: u32Implementations§
Source§impl<S: Scale> Outline<S>
impl<S: Scale> Outline<S>
Sourcepub fn flags(&self) -> &[PointFlags]
pub fn flags(&self) -> &[PointFlags]
The flag for each point in Self::points.
Sourcepub fn phantom_points(&self) -> &[Point<S::Coord>; 4]
pub fn phantom_points(&self) -> &[Point<S::Coord>; 4]
The four phantom points, after scaling, variation and hinting.
Sourcepub fn adjusted_lsb(&self) -> S::Coord
pub fn adjusted_lsb(&self) -> S::Coord
The left side bearing after scaling, variation and hinting.
Sourcepub fn adjusted_advance_width(&self) -> S::Coord
pub fn adjusted_advance_width(&self) -> S::Coord
The advance width after scaling, variation and hinting.
Sourcepub fn to_path(&self, start: PathContourStart, sink: &mut impl PathSink) -> bool
pub fn to_path(&self, start: PathContourStart, sink: &mut impl PathSink) -> bool
Converts the outline to path commands, calling sink for each.
See OutlineRef::to_path for what start decides and when this
returns false.
Sourcepub fn load_with<'a>(
&mut self,
context: &'a dyn OutlineContext<'a>,
glyph: GlyphId,
scale: &S,
hinter: Option<&mut dyn Hinter<S::Coord>>,
) -> Result<OutlineRef<'_, S::Coord>, Error>
pub fn load_with<'a>( &mut self, context: &'a dyn OutlineContext<'a>, glyph: GlyphId, scale: &S, hinter: Option<&mut dyn Hinter<S::Coord>>, ) -> Result<OutlineRef<'_, S::Coord>, Error>
Loads glyph at scale, replacing any previous contents.
The per-scale load methods build the scale. Use this to supply a
hinter, or to drive a scale generically.
Source§impl Outline<Scale26Dot6>
impl Outline<Scale26Dot6>
Sourcepub fn load<'a>(
&mut self,
context: &'a dyn OutlineContext<'a>,
glyph: GlyphId,
ppem: Option<f32>,
) -> Result<OutlineRef<'_, F26Dot6>, Error>
pub fn load<'a>( &mut self, context: &'a dyn OutlineContext<'a>, glyph: GlyphId, ppem: Option<f32>, ) -> Result<OutlineRef<'_, F26Dot6>, Error>
Loads glyph at ppem, in 26.6 pixel coordinates.
A ppem of None leaves the result in font units, shifted left by
six. The location comes from context.
Sourcepub fn load_hinted<'a>(
&mut self,
context: &'a dyn OutlineContext<'a>,
glyph: GlyphId,
ppem: Option<f32>,
hinter: &mut dyn Hinter<F26Dot6>,
) -> Result<OutlineRef<'_, F26Dot6>, Error>
pub fn load_hinted<'a>( &mut self, context: &'a dyn OutlineContext<'a>, glyph: GlyphId, ppem: Option<f32>, hinter: &mut dyn Hinter<F26Dot6>, ) -> Result<OutlineRef<'_, F26Dot6>, Error>
Loads glyph at ppem, running the glyph’s TrueType
instructions through hinter.
Source§impl Outline<ScaleF32>
impl Outline<ScaleF32>
Sourcepub fn load<'a>(
&mut self,
context: &'a dyn OutlineContext<'a>,
glyph: GlyphId,
ppem: Option<f32>,
) -> Result<OutlineRef<'_, f32>, Error>
pub fn load<'a>( &mut self, context: &'a dyn OutlineContext<'a>, glyph: GlyphId, ppem: Option<f32>, ) -> Result<OutlineRef<'_, f32>, Error>
Loads glyph at ppem, in floating point pixel coordinates.
A ppem of None leaves the result in font units. The location comes
from context.
Source§impl Outline<Unscaled>
impl Outline<Unscaled>
Sourcepub fn load<'a>(
&mut self,
context: &'a dyn OutlineContext<'a>,
glyph: GlyphId,
) -> Result<OutlineRef<'_, i32>, Error>
pub fn load<'a>( &mut self, context: &'a dyn OutlineContext<'a>, glyph: GlyphId, ) -> Result<OutlineRef<'_, i32>, Error>
Loads glyph in font units.
There is no size to pass: variations apply and components are placed,
but nothing is scaled. The location comes from context.