[][src]Struct genpdf::style::StyledString

pub struct StyledString {
    pub s: String,
    pub style: Style,
}

A String with a Style annotation.

Example

use genpdf::style;
let ss1 = style::StyledString::new("bold".to_owned(), style::Effect::Bold);
let ss2 = style::StyledString::new("red".to_owned(), style::Color::Rgb(255, 0, 0));

Fields

s: String

The annotated string.

style: Style

The style annotation.

Implementations

impl StyledString[src]

pub fn new(s: impl Into<String>, style: impl Into<Style>) -> StyledString[src]

Creates a new styled string from the given string and style.

pub fn width(&self, font_cache: &FontCache) -> Mm[src]

Calculates the width of the this string with this style using the data in the given font cache.

If the font family is set for the style, it must have been created by the given FontCache.

Trait Implementations

impl Clone for StyledString[src]

impl Debug for StyledString[src]

impl Default for StyledString[src]

impl<'a> From<&'a String> for StyledString[src]

impl<'a> From<&'a str> for StyledString[src]

impl<'s> From<&'s StyledString> for StyledStr<'s>[src]

impl From<String> for StyledString[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.