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 const fn new() -> FontFeatures
pub const fn new() -> FontFeatures
No features: the font’s own defaults.
Sourcepub fn set(self, tag: &str, value: u32) -> FontFeatures
pub fn set(self, tag: &str, value: u32) -> FontFeatures
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) -> FontFeatures
pub fn parse(s: &str) -> FontFeatures
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
Source§fn clone(&self) -> FontFeatures
fn clone(&self) -> FontFeatures
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for FontFeatures
Source§impl Debug for FontFeatures
impl Debug for FontFeatures
Source§impl Default for FontFeatures
impl Default for FontFeatures
Source§fn default() -> FontFeatures
fn default() -> 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<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<S, T> Duplex<S> for Twhere
T: FromSample<S> + ToSample<S>,
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.