pub struct Text {
pub position: Point,
pub content: String,
pub height: f64,
pub rotation: f64,
pub halign: HAlign,
pub valign: VAlign,
}Expand description
Text annotation. Height is the cap-to-descender line height in model units.
Fields§
§position: PointInsertion point.
content: StringUTF-8 content; \n separates lines.
height: f64Text height in model units.
rotation: f64Rotation in radians.
halign: HAlignHorizontal alignment.
valign: VAlignVertical alignment.
Implementations§
Source§impl Text
impl Text
Sourcepub const LINE_SPACING: f64 = 1.2
pub const LINE_SPACING: f64 = 1.2
Line spacing relative to height.
Sourcepub const TOP_ABOVE_BASELINE: f64 = 0.8
pub const TOP_ABOVE_BASELINE: f64 = 0.8
Top of the text block above the first baseline (relative to height) for
Top, Middle and Bottom alignment — the renderer’s layout contract.
Sourcepub const FONT_UNITS_PER_EM: f64 = fm::UNITS_PER_EM
pub const FONT_UNITS_PER_EM: f64 = fm::UNITS_PER_EM
Font units per em of the renderer’s default font (the unit of
Text::line_pens).
Sourcepub fn em_size(height: f64) -> f64
pub fn em_size(height: f64) -> f64
Model units per em for text of height (for renderers that place glyph
outlines with Text::line_pens).
Sourcepub fn line_pens(line: &str) -> (Vec<(char, f64)>, f64)
pub fn line_pens(line: &str) -> (Vec<(char, f64)>, f64)
Pen positions of one line laid out with the renderer’s default font: each
drawn character (after the renderer’s substitutions: tabs and no-break
spaces become spaces, control characters are dropped) with its pen position
in font units from the line start — advance widths plus pair kerning — and
the line’s total advance in font units. The renderer places glyphs with
exactly these positions, so drawn text and Text::layout_box agree.
Sourcepub fn line_width(line: &str, height: f64) -> f64
pub fn line_width(line: &str, height: f64) -> f64
Advance width of one line in model units, measured with the renderer’s default font (advance widths and pair kerning — exactly how it is drawn). Tabs count as spaces; control characters are skipped.
Sourcepub fn layout_box(&self) -> Aabb
pub fn layout_box(&self) -> Aabb
Layout box (before rotation) relative to position: each line’s advance
width with its alignment, from the ascender of the first line to the
descender of the last. Matches the renderer’s layout of the default font.
Sourcepub fn layout_corners(&self) -> [Point; 4]
pub fn layout_corners(&self) -> [Point; 4]
The four corners of the layout box in model space.