Skip to main content

EncodingPlanner

Struct EncodingPlanner 

Source
pub(crate) struct EncodingPlanner {
    used: HashMap<Base14Font, BTreeSet<char>>,
}
Expand description

Two-phase encoding planner: caller streams every (face, ch) in through Self::observe, then calls Self::finalize to get one DocEncoding per Latin Core 14 face that participated.

Fields§

§used: HashMap<Base14Font, BTreeSet<char>>

Observed chars per face. BTreeSet for deterministic order during finalize, which keeps /Differences arrays byte-stable between runs. (Base14Font doesn’t derive Ord, so the outer container is a HashMap: finalize sorts what matters.)

Implementations§

Source§

impl EncodingPlanner

Source

pub(crate) fn new() -> Self

Source

pub(crate) fn observe(&mut self, face: Base14Font, ch: char)

Record that face will need to render ch. Idempotent. Symbol and ZapfDingbats are silently ignored; those faces don’t participate in /Differences planning (their encodings are different category entirely; see crate-level pdf-base14-metrics docs).

Source

pub(crate) fn observe_runs(&mut self, runs: &[TextRun])

Convenience: feed every char of every text run. Embedded-font runs are skipped; they take the Type 0 CID path and don’t participate in /Differences planning.

Source

pub(crate) fn finalize( self, diagnostics: &mut Vec<Diagnostic>, ) -> HashMap<Font, DocEncoding>

Compute the per-face encoding plan. Any face never observed is absent from the returned map; callers should fall back to the predefined WinAnsiEncoding shortcut for those.

Pushes a MOS0032 diagnostic when a face’s extended-glyph budget overflows the 256-slot single-byte ceiling.

Trait Implementations§

Source§

impl Debug for EncodingPlanner

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EncodingPlanner

Source§

fn default() -> EncodingPlanner

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Finish for T

§

fn finish(self)

Does nothing but move self, equivalent to drop.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<U, T> ToOwnedObj<U> for T
where U: FromObjRef<T>,

§

fn to_owned_obj(&self, data: FontData<'_>) -> U

Convert this type into T, using the provided data to resolve any offsets.
§

impl<U, T> ToOwnedTable<U> for T
where U: FromTableRef<T>,

§

fn to_owned_table(&self) -> U

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.