pub struct Pango<'a> { /* private fields */ }
Expand description
Structure for writing Pango markup spans
Implementations§
source§impl<'a> Pango<'a>
impl<'a> Pango<'a>
sourcepub fn new(content: &'a str) -> Pango<'_>
pub fn new(content: &'a str) -> Pango<'_>
Generate a new pango class
Usage
use rofi::pango;
let t = pango::Pango::new("test").build();
assert_eq!(t, "test");
sourcepub fn with_capacity(content: &'a str, size: usize) -> Pango<'_>
pub fn with_capacity(content: &'a str, size: usize) -> Pango<'_>
Generate a new pango class with options capacity
Usage
use rofi::pango;
let t = pango::Pango::with_capacity("test", 0).build();
assert_eq!(t, "test");
sourcepub fn build(&mut self) -> String
pub fn build(&mut self) -> String
Generate the pango string
Usage
use rofi::pango;
let t = pango::Pango::new("test")
.slant_style(pango::SlantStyle::Italic)
.size(pango::FontSize::Small)
.build();
assert!(t == "<span style='italic' size='small'>test</span>" ||
t == "<span size='small' style='italic'>test</span>");
sourcepub fn build_content(&self, content: &str) -> String
pub fn build_content(&self, content: &str) -> String
Generates a pango string based on the options, but with a different content.
use rofi::pango;
let mut p = pango::Pango::new("");
p.slant_style(pango::SlantStyle::Italic);
p.size(pango::FontSize::Small);
let t = p.build_content("test");
assert!(t == "<span style='italic' size='small'>test</span>" ||
t == "<span size='small' style='italic'>test</span>");
sourcepub fn font_description(&mut self, font: &'a str) -> &mut Self
pub fn font_description(&mut self, font: &'a str) -> &mut Self
Set the font
Usage
use rofi::pango;
let t = pango::Pango::new("test")
.font_description("Sans Italic 12")
.build();
assert_eq!(t, "<span font_desc='Sans Italic 12'>test</span>");
sourcepub fn font_family(&mut self, family: FontFamily) -> &mut Self
pub fn font_family(&mut self, family: FontFamily) -> &mut Self
set the font family
Usage
use rofi::pango;
let t = pango::Pango::new("test")
.font_family(pango::FontFamily::Monospace)
.build();
assert_eq!(t, "<span face='monospace'>test</span>");
sourcepub fn size(&mut self, size: FontSize) -> &mut Self
pub fn size(&mut self, size: FontSize) -> &mut Self
Set the size of the font, relative to the configured font size
Usage
use rofi::pango;
let t = pango::Pango::new("test")
.size(pango::FontSize::Huge)
.build();
assert_eq!(t, "<span size='x-large'>test</span>");
sourcepub fn slant_style(&mut self, style: SlantStyle) -> &mut Self
pub fn slant_style(&mut self, style: SlantStyle) -> &mut Self
Set the slant style (italic / oblique / normal)
Usage
use rofi::pango;
let t = pango::Pango::new("test")
.slant_style(pango::SlantStyle::Oblique)
.build();
assert_eq!(t, "<span style='oblique'>test</span>");
sourcepub fn weight(&mut self, weight: Weight) -> &mut Self
pub fn weight(&mut self, weight: Weight) -> &mut Self
Set the font weight
Usage
use rofi::pango;
let t = pango::Pango::new("test")
.weight(pango::Weight::Bold)
.build();
assert_eq!(t, "<span weight='bold'>test</span>");
sourcepub fn alpha(&mut self, alpha: &'a str) -> &mut Self
pub fn alpha(&mut self, alpha: &'a str) -> &mut Self
Set the alpha of the text Important: alpha must be fo the form: XX%, where XX is a number between 0 and 100.
Usage
use rofi::pango;
let t = pango::Pango::new("test")
.alpha("50%")
.build();
assert_eq!(t, "<span alpha='50%'>test</span>");
sourcepub fn small_caps(&mut self) -> &mut Self
pub fn small_caps(&mut self) -> &mut Self
Use smallcaps
Usage
use rofi::pango;
let t = pango::Pango::new("test")
.small_caps()
.build();
assert_eq!(t, "<span variant='smallcaps'>test</span>");
sourcepub fn stretch(&mut self, stretch: FontStretch) -> &mut Self
pub fn stretch(&mut self, stretch: FontStretch) -> &mut Self
Set the stretch (expanded or condensed)
Usage
use rofi::pango;
let t = pango::Pango::new("test")
.stretch(pango::FontStretch::Condensed)
.build();
assert_eq!(t, "<span stretch='condensed'>test</span>");
sourcepub fn fg_color(&mut self, color: &'a str) -> &mut Self
pub fn fg_color(&mut self, color: &'a str) -> &mut Self
Set the foreground color
Usage
use rofi::pango;
let t = pango::Pango::new("test")
.fg_color("#00FF00")
.build();
assert_eq!(t, "<span foreground='#00FF00'>test</span>");
sourcepub fn bg_color(&mut self, color: &'a str) -> &mut Self
pub fn bg_color(&mut self, color: &'a str) -> &mut Self
Set the background color
Usage
use rofi::pango;
let t = pango::Pango::new("test")
.bg_color("#00FF00")
.build();
assert_eq!(t, "<span background='#00FF00'>test</span>");
sourcepub fn underline(&mut self, underline: Underline) -> &mut Self
pub fn underline(&mut self, underline: Underline) -> &mut Self
Set the underline style
Usage
use rofi::pango;
let t = pango::Pango::new("test")
.underline(pango::Underline::Double)
.build();
assert_eq!(t, "<span underline='double'>test</span>");
sourcepub fn strike_through(&mut self) -> &mut Self
pub fn strike_through(&mut self) -> &mut Self
set the font to strike through
Usage
use rofi::pango;
let t = pango::Pango::new("test")
.strike_through()
.build();
assert_eq!(t, "<span strikethrough='true'>test</span>");
Trait Implementations§
Auto Trait Implementations§
impl<'a> RefUnwindSafe for Pango<'a>
impl<'a> Send for Pango<'a>
impl<'a> Sync for Pango<'a>
impl<'a> Unpin for Pango<'a>
impl<'a> UnwindSafe for Pango<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more