Skip to main content

GsvText

Struct GsvText 

Source
pub struct GsvText { /* private fields */ }
Expand description

Geometric stroke vector text renderer.

Renders text using a built-in stroke-based font. Each character is described as a series of stroked line segments, making the output resolution-independent.

Port of C++ gsv_text.

Implementations§

Source§

impl GsvText

Source

pub fn new() -> Self

Source

pub fn set_font(&mut self, font: Option<&'static [u8]>)

Set the font data. If None, uses the loaded font (if any).

Source

pub fn flip(&mut self, flip_y: bool)

Source

pub fn size(&mut self, height: f64, width: f64)

Source

pub fn space(&mut self, space: f64)

Source

pub fn line_space(&mut self, line_space: f64)

Source

pub fn start_point(&mut self, x: f64, y: f64)

Source

pub fn text(&mut self, text: &str)

Source

pub fn load_font_data(&mut self, data: &[u8])

Load font data from a byte slice (replaces C++ file-based load_font).

Source

pub fn text_width(&mut self) -> f64

Compute the bounding width of the current text.

Trait Implementations§

Source§

impl Default for GsvText

Source§

fn default() -> Self

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

impl VertexSource for GsvText

Source§

fn rewind(&mut self, _path_id: u32)

Reset the vertex source to the beginning of the given path. path_id selects which sub-path to iterate (0 for the first/only path).
Source§

fn vertex(&mut self, x: &mut f64, y: &mut f64) -> u32

Return the next vertex. Writes coordinates to x and y, returns a path command. Returns PATH_CMD_STOP when iteration is complete.

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
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.

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.