Skip to main content

evaluate_width

Function evaluate_width 

Source
pub fn evaluate_width<'a>(
    context: &'a impl CharstringContext,
    blend_state: Option<BlendState<'a>>,
    charstring_data: &[u8],
) -> Result<Option<Fixed>, Error>
Expand description

Returns the advance width the charstring states, without drawing it.

A charstring states its width before it draws anything: Type 1 in the hsbw or sbw that must open it, Type 2 as an optional extra argument on the first operator that clears the stack. Evaluation therefore stops as soon as that operator has been seen, which for most glyphs is a handful of bytes out of hundreds.

None where the charstring states no width of its own. For Type 2 that is the common case and means the font’s default width applies; the caller supplies it, since the charstring does not know it.