summaryrefslogtreecommitdiff
path: root/src/layout/shaping.rs
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2021-07-08 21:42:36 +0200
committerLaurenz <laurmaedje@gmail.com>2021-07-08 21:42:36 +0200
commit7e2c217cbc3805c4cae613baf4149cc82e10d503 (patch)
tree66c36a7cff800bc0b6b4ddcd2e85112219cd830d /src/layout/shaping.rs
parent551e3af9d09a03aaa246cac46b98124bc10835ba (diff)
Rename some library arguments
- font - color -> fill - shorthands for families and size - decoration functions - color -> stroke - strength -> thickness - position -> offset - invert offsets: now positive goes downwards just like the rest of typst
Diffstat (limited to 'src/layout/shaping.rs')
-rw-r--r--src/layout/shaping.rs19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/layout/shaping.rs b/src/layout/shaping.rs
index 2496aae0..c37300f7 100644
--- a/src/layout/shaping.rs
+++ b/src/layout/shaping.rs
@@ -396,23 +396,24 @@ fn decorate(
let mut apply = |substate: &LineState, metrics: fn(&Face) -> &LineMetrics| {
let metrics = metrics(&ctx.cache.font.get(face_id));
- let strength = substate
- .strength
+ let stroke = substate.stroke.unwrap_or(state.fill);
+
+ let thickness = substate
+ .thickness
.map(|s| s.resolve(state.size))
.unwrap_or(metrics.strength.to_length(state.size));
- let position = substate
- .position
+ let offset = substate
+ .offset
.map(|s| s.resolve(state.size))
- .unwrap_or(metrics.position.to_length(state.size));
+ .unwrap_or(-metrics.position.to_length(state.size));
let extent = substate.extent.resolve(state.size);
- let fill = substate.fill.unwrap_or(state.fill);
- let pos = Point::new(pos.x - extent, pos.y - position);
+ let pos = Point::new(pos.x - extent, pos.y + offset);
let target = Point::new(width + 2.0 * extent, Length::zero());
- let shape = Shape::Line(target, strength);
- let element = Element::Geometry(shape, fill);
+ let shape = Shape::Line(target, thickness);
+ let element = Element::Geometry(shape, stroke);
frame.push(pos, element);
};