pub struct FontFeatures { /* private fields */ }Expand description
The OpenType features a style asks the shaper for: up to
FontFeatures::MAX four-letter tags with a value each. liga 0
keeps a coding font from joining ->, tnum 1 gives tabular figures,
ss01 1 turns on a stylistic set. Plain data and Copy, since a
TextStyle is; the spelling every binding shares is
FontFeatures::parse’s.
use kui_core::{FontFeatures, TextStyle};
let code = TextStyle::new(13.0).mono().features(FontFeatures::parse("-liga -calt tnum"));
assert_eq!(code.features.len(), 3);
assert_eq!(code.features.to_string_spelling(), "liga=0 calt=0 tnum=1");Implementations§
Source§impl FontFeatures
impl FontFeatures
Sourcepub const MAX: usize = 8
pub const MAX: usize = 8
How many features a style can carry. Eight is more than any one text asks for and keeps the style small.
Sourcepub fn set(self, tag: &str, value: u32) -> Self
pub fn set(self, tag: &str, value: u32) -> Self
Adds or replaces tag (four ASCII characters; shorter is padded
with spaces, longer is cut) with value. Past MAX the feature is
dropped rather than the style refused.
Sourcepub fn parse(s: &str) -> Self
pub fn parse(s: &str) -> Self
The spelling every binding shares: tags separated by whitespace or
commas, each tag=value, a bare tag meaning 1 and -tag meaning
0 — "liga=0 calt=0 tnum", "-liga,-calt". Anything else in the
string is skipped.
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
Sourcepub fn iter(&self) -> impl Iterator<Item = (&[u8; 4], u32)> + '_
pub fn iter(&self) -> impl Iterator<Item = (&[u8; 4], u32)> + '_
Every feature, in the order set, as (tag, value).
Sourcepub fn to_string_spelling(&self) -> String
pub fn to_string_spelling(&self) -> String
What parse reads: tag=value pairs joined by spaces.
Trait Implementations§
Source§impl Clone for FontFeatures
impl Clone for FontFeatures
impl Copy for FontFeatures
Source§impl Debug for FontFeatures
impl Debug for FontFeatures
Source§impl Default for FontFeatures
impl Default for FontFeatures
impl Eq for FontFeatures
Source§impl PartialEq for FontFeatures
impl PartialEq for FontFeatures
impl StructuralPartialEq for FontFeatures
Auto Trait Implementations§
impl Freeze for FontFeatures
impl RefUnwindSafe for FontFeatures
impl Send for FontFeatures
impl Sync for FontFeatures
impl Unpin for FontFeatures
impl UnsafeUnpin for FontFeatures
impl UnwindSafe for FontFeatures
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.