summaryrefslogtreecommitdiff
path: root/library/src/math
diff options
context:
space:
mode:
Diffstat (limited to 'library/src/math')
-rw-r--r--library/src/math/ctx.rs23
-rw-r--r--library/src/math/frac.rs2
-rw-r--r--library/src/math/fragment.rs4
-rw-r--r--library/src/math/matrix.rs6
-rw-r--r--library/src/math/mod.rs21
-rw-r--r--library/src/math/root.rs2
-rw-r--r--library/src/math/row.rs4
7 files changed, 31 insertions, 31 deletions
diff --git a/library/src/math/ctx.rs b/library/src/math/ctx.rs
index a3aa4047..991d582c 100644
--- a/library/src/math/ctx.rs
+++ b/library/src/math/ctx.rs
@@ -49,7 +49,7 @@ impl<'a, 'b, 'v> MathContext<'a, 'b, 'v> {
) -> Self {
let table = font.ttf().tables().math.unwrap();
let constants = table.constants.unwrap();
- let size = styles.get(TextNode::SIZE);
+ let size = TextNode::size_in(styles);
let ttf = font.ttf();
let space_width = ttf
.glyph_index(' ')
@@ -175,21 +175,20 @@ impl<'a, 'b, 'v> MathContext<'a, 'b, 'v> {
pub fn style(&mut self, style: MathStyle) {
self.style_stack.push((self.style, self.size));
- let base_size = self.styles().get(TextNode::SIZE) / self.style.size.factor(self);
+ let base_size = TextNode::size_in(self.styles()) / self.style.size.factor(self);
self.size = base_size * style.size.factor(self);
- self.map.set(TextNode::SIZE, TextSize(self.size.into()));
- self.map.set(
- TextNode::STYLE,
- if style.italic == Smart::Custom(true) {
+ self.map.set(TextNode::set_size(TextSize(self.size.into())));
+ self.map
+ .set(TextNode::set_style(if style.italic == Smart::Custom(true) {
FontStyle::Italic
} else {
FontStyle::Normal
- },
- );
- self.map.set(
- TextNode::WEIGHT,
- if style.bold { FontWeight::BOLD } else { FontWeight::REGULAR },
- );
+ }));
+ self.map.set(TextNode::set_weight(if style.bold {
+ FontWeight::BOLD
+ } else {
+ FontWeight::REGULAR
+ }));
self.style = style;
}
diff --git a/library/src/math/frac.rs b/library/src/math/frac.rs
index ea647fc5..c1f4065b 100644
--- a/library/src/math/frac.rs
+++ b/library/src/math/frac.rs
@@ -133,7 +133,7 @@ fn layout(
line_pos,
Element::Shape(
Geometry::Line(Point::with_x(line_width)).stroked(Stroke {
- paint: ctx.styles().get(TextNode::FILL),
+ paint: TextNode::fill_in(ctx.styles()),
thickness,
}),
),
diff --git a/library/src/math/fragment.rs b/library/src/math/fragment.rs
index 93c5946b..73daa4b2 100644
--- a/library/src/math/fragment.rs
+++ b/library/src/math/fragment.rs
@@ -180,8 +180,8 @@ impl GlyphFragment {
id,
c,
font: ctx.font.clone(),
- lang: ctx.styles().get(TextNode::LANG),
- fill: ctx.styles().get(TextNode::FILL),
+ lang: TextNode::lang_in(ctx.styles()),
+ fill: TextNode::fill_in(ctx.styles()),
style: ctx.style,
font_size: ctx.size,
width,
diff --git a/library/src/math/matrix.rs b/library/src/math/matrix.rs
index c7303735..d4bf52f3 100644
--- a/library/src/math/matrix.rs
+++ b/library/src/math/matrix.rs
@@ -35,7 +35,7 @@ pub struct VecNode {
impl LayoutMath for VecNode {
fn layout_math(&self, ctx: &mut MathContext) -> SourceResult<()> {
- let delim = ctx.styles().get(Self::DELIM);
+ let delim = Self::delim_in(ctx.styles());
let frame = layout_vec_body(ctx, &self.children(), Align::Center)?;
layout_delimiters(ctx, frame, Some(delim.open()), Some(delim.close()))
}
@@ -115,7 +115,7 @@ impl Construct for MatNode {
impl LayoutMath for MatNode {
fn layout_math(&self, ctx: &mut MathContext) -> SourceResult<()> {
- let delim = ctx.styles().get(Self::DELIM);
+ let delim = Self::delim_in(ctx.styles());
let frame = layout_mat_body(ctx, &self.rows())?;
layout_delimiters(ctx, frame, Some(delim.open()), Some(delim.close()))
}
@@ -156,7 +156,7 @@ pub struct CasesNode {
impl LayoutMath for CasesNode {
fn layout_math(&self, ctx: &mut MathContext) -> SourceResult<()> {
- let delim = ctx.styles().get(Self::DELIM);
+ let delim = Self::delim_in(ctx.styles());
let frame = layout_vec_body(ctx, &self.children(), Align::Left)?;
layout_delimiters(ctx, frame, Some(delim.open()), None)
}
diff --git a/library/src/math/mod.rs b/library/src/math/mod.rs
index 6f5e5907..3f0b0607 100644
--- a/library/src/math/mod.rs
+++ b/library/src/math/mod.rs
@@ -158,11 +158,10 @@ impl Show for FormulaNode {
impl Finalize for FormulaNode {
fn finalize(&self, realized: Content) -> Content {
realized
- .styled(TextNode::WEIGHT, FontWeight::from_number(450))
- .styled(
- TextNode::FONT,
- FontList(vec![FontFamily::new("New Computer Modern Math")]),
- )
+ .styled(TextNode::set_weight(FontWeight::from_number(450)))
+ .styled(TextNode::set_font(FontList(vec![FontFamily::new(
+ "New Computer Modern Math",
+ )])))
}
}
@@ -196,10 +195,10 @@ impl Layout for FormulaNode {
let mut frame = ctx.layout_frame(self)?;
if !block {
- let slack = styles.get(ParNode::LEADING) * 0.7;
- let top_edge = styles.get(TextNode::TOP_EDGE).resolve(styles, font.metrics());
+ let slack = ParNode::leading_in(styles) * 0.7;
+ let top_edge = TextNode::top_edge_in(styles).resolve(styles, font.metrics());
let bottom_edge =
- -styles.get(TextNode::BOTTOM_EDGE).resolve(styles, font.metrics());
+ -TextNode::bottom_edge_in(styles).resolve(styles, font.metrics());
let ascent = top_edge.max(frame.ascent() - slack);
let descent = bottom_edge.max(frame.descent() - slack);
@@ -232,7 +231,9 @@ impl LayoutMath for Content {
if let Some(styled) = self.to::<StyledNode>() {
let map = styled.map();
- if map.contains(TextNode::FONT) {
+ if TextNode::font_in(ctx.styles().chain(&map))
+ != TextNode::font_in(ctx.styles())
+ {
let frame = ctx.layout_content(self)?;
ctx.push(FrameFragment::new(ctx, frame).with_spaced(true));
return Ok(());
@@ -241,7 +242,7 @@ impl LayoutMath for Content {
let prev_map = std::mem::replace(&mut ctx.map, map);
let prev_size = ctx.size;
ctx.map.apply(prev_map.clone());
- ctx.size = ctx.styles().get(TextNode::SIZE);
+ ctx.size = TextNode::size_in(ctx.styles());
styled.body().layout_math(ctx)?;
ctx.size = prev_size;
ctx.map = prev_map;
diff --git a/library/src/math/root.rs b/library/src/math/root.rs
index 191acb94..e190c65f 100644
--- a/library/src/math/root.rs
+++ b/library/src/math/root.rs
@@ -128,7 +128,7 @@ fn layout(
line_pos,
Element::Shape(
Geometry::Line(Point::with_x(radicand.width()))
- .stroked(Stroke { paint: ctx.styles().get(TextNode::FILL), thickness }),
+ .stroked(Stroke { paint: TextNode::fill_in(ctx.styles()), thickness }),
),
);
diff --git a/library/src/math/row.rs b/library/src/math/row.rs
index b7720c14..ecb2e31e 100644
--- a/library/src/math/row.rs
+++ b/library/src/math/row.rs
@@ -103,7 +103,7 @@ impl MathRow {
pub fn to_frame(self, ctx: &MathContext) -> Frame {
let styles = ctx.styles();
- let align = styles.get(AlignNode::ALIGNMENT).x.resolve(styles);
+ let align = AlignNode::alignment_in(styles).x.resolve(styles);
self.to_aligned_frame(ctx, &[], align)
}
@@ -124,7 +124,7 @@ impl MathRow {
if self.iter().any(|frag| matches!(frag, MathFragment::Linebreak)) {
let fragments: Vec<_> = std::mem::take(&mut self.0);
let leading = if ctx.style.size >= MathSize::Text {
- ctx.styles().get(ParNode::LEADING)
+ ParNode::leading_in(ctx.styles())
} else {
TIGHT_LEADING.scaled(ctx)
};