[][src]Struct genpdf::style::Style

pub struct Style { /* fields omitted */ }

A style annotation for a string.

The annotation consists of:

  • a font family, see FontFamily (defaults to the FontCache default)
  • a font size in points (defaults to 12)
  • a line spacing factor, with 1 meaning single line spacing (defaults to 1)
  • an outline color, see Color (defaults to black)
  • a combination of text effects, see Effect (defaults to none)

All properties are optional. If they are not set, they can be inferred from parent styles or from the defaults.

Implementations

impl Style[src]

pub fn new() -> Style[src]

Creates a new style without settings.

pub fn merge(&mut self, style: impl Into<Style>)[src]

Merges the given style into this style.

pub fn and(self, style: impl Into<Style>) -> Style[src]

Combines this style and the given style and returns the result.

pub fn combine(left: impl Into<Style>, right: impl Into<Style>) -> Style[src]

Creates a new style by combining the given styles.

pub fn color(&self) -> Option<Color>[src]

Returns the outline color for this style, if set.

pub fn is_bold(&self) -> bool[src]

Returns whether the bold text effect is set.

pub fn is_italic(&self) -> bool[src]

Returns whether the italic text effect is set.

pub fn font_size(&self) -> u8[src]

Returns the font size for this style in points, or 12 if no font size is set.

pub fn line_spacing(&self) -> f64[src]

Returns the line spacing factor for this style, or 1 if no line spacing factor is set.

pub fn set_bold(&mut self)[src]

Sets the bold effect for this style.

pub fn bold(self) -> Style[src]

Sets the bold effect for this style and returns it.

pub fn set_italic(&mut self)[src]

Sets the italic effect for this style.

pub fn italic(self) -> Style[src]

Sets the italic effect for this style and returns it.

pub fn set_font_family(&mut self, font_family: FontFamily)[src]

Sets the font family for this style.

pub fn with_font_family(self, font_family: FontFamily) -> Style[src]

Sets the font family for this style and returns it.

pub fn set_line_spacing(&mut self, line_spacing: f64)[src]

Sets the line spacing factor for this style.

pub fn with_line_spacing(self, line_spacing: f64) -> Style[src]

Sets the line spacing factor for this style and returns it.

pub fn set_font_size(&mut self, font_size: u8)[src]

Sets the font size in points for this style.

pub fn with_font_size(self, font_size: u8) -> Style[src]

Sets the font size in points for this style and returns it.

pub fn set_color(&mut self, color: Color)[src]

Sets the outline color for this style.

pub fn with_color(self, color: Color) -> Self[src]

Sets the outline color for this style and returns it.

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

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

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

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

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

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

pub fn font_family(&self, font_cache: &FontCache) -> FontFamily[src]

Returns the font family for this style or the default font family using the given font cache.

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

pub fn font(&self, font_cache: &FontCache) -> Font[src]

Returns the font for this style using the given font cache.

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

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

Calculates the line height for strings with this style using the data in the given font cache.

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

Trait Implementations

impl Clone for Style[src]

impl Copy for Style[src]

impl Debug for Style[src]

impl Default for Style[src]

impl<T: Into<Style>> Extend<T> for Style[src]

impl From<Color> for Style[src]

impl From<Effect> for Style[src]

impl From<FontFamily> for Style[src]

impl<T: Into<Style>> FromIterator<T> for Style[src]

impl PartialEq<Style> for Style[src]

impl StructuralPartialEq for Style[src]

Auto Trait Implementations

impl RefUnwindSafe for Style

impl Send for Style

impl Sync for Style

impl Unpin for Style

impl UnwindSafe for Style

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.