Struct rofi::pango::Pango

source ·
pub struct Pango<'a> { /* private fields */ }
Expand description

Structure for writing Pango markup spans

Implementations§

source§

impl<'a> Pango<'a>

source

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");
source

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");
source

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>");
source

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>");
source

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>");
source

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>");
source

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>");
source

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>");
source

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>");
source

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>");
source

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>");
source

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>");
source

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>");
source

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>");
source

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>");
source

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§

source§

impl<'a> Clone for Pango<'a>

source§

fn clone(&self) -> Pango<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for Pango<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'a> Display for Pango<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.