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}
15
16impl Default for LayoutOptions {
17 fn default() -> Self {
18 Self {
19 style: MathStyle::Display,
20 color: Color::BLACK,
21 align_relation_spacing: None,
22 leftright_delim_height: None,
23 }
24 }
25}
26
27impl LayoutOptions {
28 pub fn metrics(&self) -> &'static MathConstants {
29 get_global_metrics(self.style.size_index())
30 }
31
32 pub fn size_multiplier(&self) -> f64 {
33 self.style.size_multiplier()
34 }
35
36 pub fn with_style(&self, style: MathStyle) -> Self {
37 Self {
38 style,
39 color: self.color,
40 align_relation_spacing: self.align_relation_spacing,
41 leftright_delim_height: self.leftright_delim_height,
42 }
43 }
44
45 pub fn with_color(&self, color: Color) -> Self {
46 Self {
47 style: self.style,
48 color,
49 align_relation_spacing: self.align_relation_spacing,
50 leftright_delim_height: self.leftright_delim_height,
51 }
52 }
53}