pub struct TextRun {Show 14 fields
pub index: ObjectIndex,
pub font: Arc<Font>,
pub font_size: f32,
pub font_size_h: f32,
pub char_space: f32,
pub word_space: f32,
pub items: Vec<Item>,
pub kernings: Vec<f32>,
pub position: Point,
pub text_matrix: Affine,
pub rect: Rect,
pub advance: f64,
pub marks: ContentMarks,
pub type3: BTreeMap<u32, Type3Metrics>,
}Expand description
A text object with everything the heuristics ask of it.
Built once per object per page and then read many times, because almost every decision in the pipeline needs at least the first and last item.
Fields§
§index: ObjectIndexWhere this object sits in the page’s flattened walk.
font: Arc<Font>The font, shared with every other object using the same resource — duplicate suppression compares fonts by this pointer’s identity.
font_size: f32The font size. May be negative, and is never rescued.
font_size_h: f32|hypot(a, b)| * font_size of the composed matrix: “the horizontal
scale of the font in device units”, which every space threshold is
measured in.
char_space: f32Tc, the character spacing.
word_space: f32Tw, the word spacing.
items: Vec<Item>One entry per glyph, in content order.
kernings: Vec<f32>The adjustment following each glyph, in thousandths of a text-space
unit. Same length as items; the last is always zero.
position: PointThe object’s position in page space.
text_matrix: AffineThe composed text matrix: the object’s linear transform with its position as the translation.
rect: RectThe object’s bounding box in page space, stroke-inflated when the render mode strokes.
advance: f64Total advance width in page space: w0 summed over the object’s
glyphs (ISO 32000-1 §9.4.3), measured through the same text matrix the
bounding box goes through, so the two are comparable against one
epsilon.
§9.2.2 keeps the glyph bounding box and the §9.4.3 displacement
distinct, and only the displacement says whether the pen moved. A
space, and any glyph whose outline is empty, has an empty box and a
non-zero w0; a zero-width space has both empty.
marks: ContentMarksThe marks enclosing the object.
type3: BTreeMap<u32, Type3Metrics>What each shown character’s Type 3 glyph procedure declared, empty for every other kind of font. A Type 3 glyph’s box and advance live inside a content stream, so they arrive from the page layer rather than from the font.
Implementations§
Source§impl TextRun
impl TextRun
Sourcepub fn kerning(&self, index: usize) -> f32
pub fn kerning(&self, index: usize) -> f32
The adjustment following a glyph; zero past the end.
Sourcepub fn scaled_char_width(&self, code: CharCode) -> f32
pub fn scaled_char_width(&self, code: CharCode) -> f32
The advance width of one character code, already scaled by
font_size / 1000.
A vertical CID font reports its (negative) vertical advance instead.
Sourcepub fn glyph_width(&self, code: CharCode) -> f32
pub fn glyph_width(&self, code: CharCode) -> f32
The advance width of one character code in glyph units.
A Type 3 font whose /Widths said nothing defers to what the glyph
procedure’s d0/d1 declared, which is the only place the number
exists.
Sourcepub fn glyph_bbox(&self, code: CharCode) -> Rect
pub fn glyph_bbox(&self, code: CharCode) -> Rect
The bounding box of one character code in glyph units, y-up.