pub struct GlyphRemapper(/* private fields */);
Expand description
A remapper that allows to assign a new ordering to a subset of glyphs.
For example, let’s say that we want to subset a font that only contains the glyphs 4, 9 and 16. In this case, the remapper could yield a remapping that assigns the following glyph IDs:
- 0 -> 0 (The .notdef glyph will always be included)
- 4 -> 1
- 9 -> 2
- 16 -> 3
This is necessary because a font needs to have a contiguous sequence of glyph IDs that start from 0, so we cannot just reuse the old ones, but we need to define a mapping.
Implementations§
Source§impl GlyphRemapper
impl GlyphRemapper
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new instance of a glyph remapper. .notdef
will always be a member
of the subset.
Sourcepub fn new_from_glyphs(glyphs: &[u16]) -> Self
pub fn new_from_glyphs(glyphs: &[u16]) -> Self
Create a remapper from an existing set of glyphs
Sourcepub fn new_from_glyphs_sorted(glyphs: &[u16]) -> Self
pub fn new_from_glyphs_sorted(glyphs: &[u16]) -> Self
Create a remapper from an existing set of glyphs. The method will ensure that the mapping is monotonically increasing.
Sourcepub fn remap(&mut self, old: u16) -> u16
pub fn remap(&mut self, old: u16) -> u16
Remap a glyph ID, or return the existing mapping if the glyph ID has already been remapped before.
Sourcepub fn get(&self, old: u16) -> Option<u16>
pub fn get(&self, old: u16) -> Option<u16>
Get the mapping of a glyph ID, if it has been remapped before.
Sourcepub fn remapped_gids(&self) -> impl Iterator<Item = u16> + '_
pub fn remapped_gids(&self) -> impl Iterator<Item = u16> + '_
Return an iterator that yields the old glyphs, in ascending order that is defined by the remapping. For example, if we perform the following remappings: 3, 39, 8, 3, 10, 2
Then the iterator will yield the following items in the order below. The order also implicitly defines the glyph IDs in the new mapping:
0 (0), 3 (1), 39 (2), 8 (3), 10 (4), 2 (5)
Trait Implementations§
Source§impl Clone for GlyphRemapper
impl Clone for GlyphRemapper
Source§fn clone(&self) -> GlyphRemapper
fn clone(&self) -> GlyphRemapper
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for GlyphRemapper
impl Debug for GlyphRemapper
Source§impl Default for GlyphRemapper
impl Default for GlyphRemapper
Source§impl Hash for GlyphRemapper
impl Hash for GlyphRemapper
Source§impl PartialEq for GlyphRemapper
impl PartialEq for GlyphRemapper
impl Eq for GlyphRemapper
impl StructuralPartialEq for GlyphRemapper
Auto Trait Implementations§
impl Freeze for GlyphRemapper
impl RefUnwindSafe for GlyphRemapper
impl Send for GlyphRemapper
impl Sync for GlyphRemapper
impl Unpin for GlyphRemapper
impl UnwindSafe for GlyphRemapper
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
impl<U, T> ToOwnedObj<U> for Twhere
U: FromObjRef<T>,
Source§fn to_owned_obj(&self, data: FontData<'_>) -> U
fn to_owned_obj(&self, data: FontData<'_>) -> U
T
, using the provided data to resolve any offsets.