ratex_layout/
layout_options.rs1use ratex_font::{get_global_metrics, MathConstants};
2use ratex_types::color::Color;
3use ratex_types::math_style::MathStyle;
4
5#[derive(Debug, Clone)]
7pub struct LayoutOptions {
8 pub style: MathStyle,
9 pub color: Color,
10 pub align_relation_spacing: Option<f64>,
12 pub leftright_delim_height: Option<f64>,
14 pub inter_glyph_kern_em: f64,
16}
17
18impl Default for LayoutOptions {
19 fn default() -> Self {
20 Self {
21 style: MathStyle::Display,
22 color: Color::BLACK,
23 align_relation_spacing: None,
24 leftright_delim_height: None,
25 inter_glyph_kern_em: 0.0,
26 }
27 }
28}
29
30impl LayoutOptions {
31 pub fn metrics(&self) -> &'static MathConstants {
32 get_global_metrics(self.style.size_index())
33 }
34
35 pub fn size_multiplier(&self) -> f64 {
36 self.style.size_multiplier()
37 }
38
39 pub fn with_style(&self, style: MathStyle) -> Self {
40 Self {
41 style,
42 color: self.color,
43 align_relation_spacing: self.align_relation_spacing,
44 leftright_delim_height: self.leftright_delim_height,
45 inter_glyph_kern_em: self.inter_glyph_kern_em,
46 }
47 }
48
49 pub fn with_color(&self, color: Color) -> Self {
50 Self {
51 style: self.style,
52 color,
53 align_relation_spacing: self.align_relation_spacing,
54 leftright_delim_height: self.leftright_delim_height,
55 inter_glyph_kern_em: self.inter_glyph_kern_em,
56 }
57 }
58
59 pub fn with_inter_glyph_kern(&self, em: f64) -> Self {
60 Self {
61 inter_glyph_kern_em: em,
62 ..self.clone()
63 }
64 }
65}