summaryrefslogtreecommitdiff
path: root/src/eval
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-08-24 00:39:43 +0200
committerLaurenz <laurmaedje@gmail.com>2021-08-24 00:41:15 +0200
commit148a06c070e6376e6f86b878d08dfd4f0aef8a73 (patch)
tree7330ecae5fa3dbb79c3bb3ce6a099205ec92d2c9 /src/eval
parentd546453880721d7a12ea228e5c1ed6c65b653ca2 (diff)
Switch from state to decorations for underline/strikethrough/overline
Diffstat (limited to 'src/eval')
-rw-r--r--src/eval/state.rs25
-rw-r--r--src/eval/template.rs12
2 files changed, 3 insertions, 34 deletions
diff --git a/src/eval/state.rs b/src/eval/state.rs
index 05558915..d7ca014d 100644
--- a/src/eval/state.rs
+++ b/src/eval/state.rs
@@ -140,12 +140,6 @@ pub struct FontState {
/// A list of font families with generic class definitions (the final
/// family list also depends on `monospace`).
pub families: Rc<FamilyState>,
- /// The specifications for a strikethrough line, if any.
- pub strikethrough: Option<Rc<LineState>>,
- /// The specifications for a underline, if any.
- pub underline: Option<Rc<LineState>>,
- /// The specifications for a overline line, if any.
- pub overline: Option<Rc<LineState>>,
}
impl FontState {
@@ -212,9 +206,6 @@ impl Default for FontState {
top_edge: VerticalFontMetric::CapHeight,
bottom_edge: VerticalFontMetric::Baseline,
fill: Paint::Color(Color::Rgba(RgbaColor::BLACK)),
- strikethrough: None,
- underline: None,
- overline: None,
}
}
}
@@ -248,19 +239,3 @@ impl Default for FamilyState {
}
}
}
-
-/// Defines a line that is positioned over, under or on top of text.
-#[derive(Debug, Clone, Eq, PartialEq, Hash)]
-pub struct LineState {
- /// Stroke color of the line, defaults to the text color if `None`.
- pub stroke: Option<Paint>,
- /// Thickness of the line's strokes (dependent on scaled font size), read
- /// from the font tables if `None`.
- pub thickness: Option<Linear>,
- /// Position of the line relative to the baseline (dependent on scaled font
- /// size), read from the font tables if `None`.
- pub offset: Option<Linear>,
- /// Amount that the line will be longer or shorter than its associated text
- /// (dependent on scaled font size).
- pub extent: Linear,
-}
diff --git a/src/eval/template.rs b/src/eval/template.rs
index 0ab49d04..4fc6985a 100644
--- a/src/eval/template.rs
+++ b/src/eval/template.rs
@@ -8,7 +8,8 @@ use super::{State, Str};
use crate::diag::StrResult;
use crate::geom::{Align, Dir, Gen, GenAxis, Length, Linear, Sides, Size};
use crate::layout::{
- LayoutNode, LayoutTree, PadNode, PageRun, ParChild, ParNode, StackChild, StackNode,
+ Decoration, LayoutNode, LayoutTree, PadNode, PageRun, ParChild, ParNode, StackChild,
+ StackNode,
};
use crate::util::EcoString;
@@ -43,13 +44,6 @@ enum TemplateNode {
Modify(Rc<dyn Fn(&mut State)>),
}
-/// A template node decoration.
-#[derive(Debug, Clone, Eq, PartialEq, Hash)]
-pub enum Decoration {
- /// A link.
- Link(EcoString),
-}
-
impl Template {
/// Create a new, empty template.
pub fn new() -> Self {
@@ -114,7 +108,7 @@ impl Template {
self.make_mut().push(TemplateNode::Spacing(axis, spacing));
}
- /// Add a decoration to the last template node.
+ /// Add a decoration to all contained nodes.
pub fn decorate(&mut self, deco: Decoration) {
for node in self.make_mut() {
let decos = match node {