Struct rckive_genpdf::style::Style
source · pub struct Style { /* private fields */ }
Expand description
A style annotation for a string.
The annotation consists of:
- a font family, see
FontFamily
(defaults to theFontCache
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§
source§impl Style
impl Style
sourcepub fn and(self, style: impl Into<Style>) -> Style
pub fn and(self, style: impl Into<Style>) -> Style
Combines this style and the given style and returns the result.
sourcepub fn combine(left: impl Into<Style>, right: impl Into<Style>) -> Style
pub fn combine(left: impl Into<Style>, right: impl Into<Style>) -> Style
Creates a new style by combining the given styles.
sourcepub fn font_size(&self) -> u8
pub fn font_size(&self) -> u8
Returns the font size for this style in points, or 12 if no font size is set.
sourcepub fn line_spacing(&self) -> f64
pub fn line_spacing(&self) -> f64
Returns the line spacing factor for this style, or 1 if no line spacing factor is set.
sourcepub fn set_italic(&mut self)
pub fn set_italic(&mut self)
Sets the italic effect for this style.
sourcepub fn set_font_family(&mut self, font_family: FontFamily<Font>)
pub fn set_font_family(&mut self, font_family: FontFamily<Font>)
Sets the font family for this style.
sourcepub fn with_font_family(self, font_family: FontFamily<Font>) -> Style
pub fn with_font_family(self, font_family: FontFamily<Font>) -> Style
Sets the font family for this style and returns it.
sourcepub fn set_line_spacing(&mut self, line_spacing: f64)
pub fn set_line_spacing(&mut self, line_spacing: f64)
Sets the line spacing factor for this style.
sourcepub fn with_line_spacing(self, line_spacing: f64) -> Style
pub fn with_line_spacing(self, line_spacing: f64) -> Style
Sets the line spacing factor for this style and returns it.
sourcepub fn set_font_size(&mut self, font_size: u8)
pub fn set_font_size(&mut self, font_size: u8)
Sets the font size in points for this style.
sourcepub fn with_font_size(self, font_size: u8) -> Style
pub fn with_font_size(self, font_size: u8) -> Style
Sets the font size in points for this style and returns it.
sourcepub fn with_color(self, color: Color) -> Self
pub fn with_color(self, color: Color) -> Self
Sets the outline color for this style and returns it.
sourcepub fn char_width(&self, font_cache: &FontCache, c: char) -> Mm
pub fn char_width(&self, font_cache: &FontCache, c: char) -> Mm
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
.
sourcepub fn char_left_side_bearing(&self, font_cache: &FontCache, c: char) -> Mm
pub fn char_left_side_bearing(&self, font_cache: &FontCache, c: char) -> Mm
Returns the width of the empty space between the origin of the glyph bounding box and the leftmost edge of the character, for this style using the given font cache.
If the font family is set, it must have been created by the given FontCache
.
sourcepub fn str_width(&self, font_cache: &FontCache, s: &str) -> Mm
pub fn str_width(&self, font_cache: &FontCache, s: &str) -> Mm
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
.
sourcepub fn font_family(&self, font_cache: &FontCache) -> FontFamily<Font>
pub fn font_family(&self, font_cache: &FontCache) -> FontFamily<Font>
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
.
sourcepub fn font(&self, font_cache: &FontCache) -> Font
pub fn font(&self, font_cache: &FontCache) -> Font
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
.
sourcepub fn line_height(&self, font_cache: &FontCache) -> Mm
pub fn line_height(&self, font_cache: &FontCache) -> Mm
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§
source§impl<T: Into<Style>> Extend<T> for Style
impl<T: Into<Style>> Extend<T> for Style
source§fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
fn extend<I: IntoIterator<Item = T>>(&mut self, iter: I)
source§fn extend_one(&mut self, item: A)
fn extend_one(&mut self, item: A)
extend_one
)source§fn extend_reserve(&mut self, additional: usize)
fn extend_reserve(&mut self, additional: usize)
extend_one
)