ferroui_base/media/text_formatting/
text_shaper_options.rs1use std::rc::Rc;
2
3use crate::media::text_formatting::GenericTextRunProperties;
4use crate::media::{FontFeature, GlyphTypeface};
5use crate::utilities::CultureInfo;
6
7#[derive(Clone)]
9pub struct TextShaperOptions {
10 glyph_typeface: Rc<GlyphTypeface>,
11 font_rendering_em_size: f64,
12 bidi_level: i8,
13 culture: Option<CultureInfo>,
14 incremental_tab_width: f64,
15 letter_spacing: f64,
16 font_features: Option<Rc<Vec<FontFeature>>>,
17}
18
19impl TextShaperOptions {
20 pub fn new(typeface: Rc<GlyphTypeface>) -> Self {
23 Self {
24 glyph_typeface: typeface,
25 font_rendering_em_size: GenericTextRunProperties::DEFAULT_FONT_RENDERING_EM_SIZE,
26 bidi_level: 0,
27 culture: None,
28 incremental_tab_width: 0.0,
29 letter_spacing: 0.0,
30 font_features: None,
31 }
32 }
33
34 pub fn with_all(
36 typeface: Rc<GlyphTypeface>,
37 font_rendering_em_size: f64,
38 bidi_level: i8,
39 culture: Option<CultureInfo>,
40 incremental_tab_width: f64,
41 letter_spacing: f64,
42 font_features: Option<Rc<Vec<FontFeature>>>,
43 ) -> Self {
44 Self {
45 glyph_typeface: typeface,
46 font_rendering_em_size,
47 bidi_level,
48 culture,
49 incremental_tab_width,
50 letter_spacing,
51 font_features,
52 }
53 }
54
55 pub fn glyph_typeface(&self) -> &Rc<GlyphTypeface> {
57 &self.glyph_typeface
58 }
59
60 pub fn font_rendering_em_size(&self) -> f64 {
62 self.font_rendering_em_size
63 }
64
65 pub fn bidi_level(&self) -> i8 {
67 self.bidi_level
68 }
69
70 pub fn culture(&self) -> Option<&CultureInfo> {
72 self.culture.as_ref()
73 }
74
75 pub fn incremental_tab_width(&self) -> f64 {
77 self.incremental_tab_width
78 }
79
80 pub fn letter_spacing(&self) -> f64 {
82 self.letter_spacing
83 }
84
85 pub fn font_features(&self) -> Option<&Rc<Vec<FontFeature>>> {
87 self.font_features.as_ref()
88 }
89}