pub struct UnicodeEncoder { /* private fields */ }font-subset only.Expand description
Accumulates glyph usage for one page, then writes the font.
Encoding and embedding are deliberately one object: the character codes written into the content stream are post-subset glyph indices, so they are only meaningful next to the font program produced by the same remapper.
Implementations§
Source§impl UnicodeEncoder
impl UnicodeEncoder
Sourcepub fn new(font: UnicodeFont) -> UnicodeEncoder
pub fn new(font: UnicodeFont) -> UnicodeEncoder
Start accumulating for font.
Sourcepub fn encode(&mut self, text: &str) -> Result<Vec<u8>, ManipError>
pub fn encode(&mut self, text: &str) -> Result<Vec<u8>, ManipError>
Encode text as Identity-H character codes (2 bytes per glyph,
big-endian), registering every glyph it uses.
Fails if the font has no glyph for a character, naming the characters
rather than silently substituting .notdef — a row of blank boxes in
a translated document is worse than a refusal the caller can act on.
Sourcepub fn width_em(&self, text: &str) -> f64
pub fn width_em(&self, text: &str) -> f64
Advance width of text in em units (1.0 = the font size), using this
font’s own metrics.
Used to decide whether a replacement fits where the original sat. The substitute font is never exactly as wide as the one it replaces, so a translated block needs measuring rather than assuming.
Auto Trait Implementations§
impl Freeze for UnicodeEncoder
impl RefUnwindSafe for UnicodeEncoder
impl Send for UnicodeEncoder
impl Sync for UnicodeEncoder
impl Unpin for UnicodeEncoder
impl UnsafeUnpin for UnicodeEncoder
impl UnwindSafe for UnicodeEncoder
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
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.