[librsvg: 4/20] Collect the advance of a chunk's spans until PositionedChunk::from_measured
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 4/20] Collect the advance of a chunk's spans until PositionedChunk::from_measured
- Date: Thu, 21 Oct 2021 00:26:07 +0000 (UTC)
commit 890436a91d0989e3f0bba7ab5b7961b5949452e1
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Oct 19 18:24:31 2021 -0500
Collect the advance of a chunk's spans until PositionedChunk::from_measured
I.e. don't store the collected advance of a chunk's spans in
MeasuredChunk. That advance does not make sense; it's just the way
the code computes things right now. Let's move it to the place that
can do anything meaningful with that information, and refactor from there.
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/616>
src/text.rs | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
---
diff --git a/src/text.rs b/src/text.rs
index c2159d47..cf0c2f5e 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -48,7 +48,6 @@ struct MeasuredChunk {
values: Rc<ComputedValues>,
x: Option<f64>,
y: Option<f64>,
- advance: (f64, f64),
spans: Vec<MeasuredSpan>,
link: Option<String>,
}
@@ -128,15 +127,10 @@ impl MeasuredChunk {
.map(|span| MeasuredSpan::from_span(span, text_writing_mode, draw_ctx))
.collect();
- let advance = measured_spans.iter().fold((0.0, 0.0), |acc, measured| {
- (acc.0 + measured.advance.0, acc.1 + measured.advance.1)
- });
-
MeasuredChunk {
values: chunk.values.clone(),
x: chunk.x,
y: chunk.y,
- advance,
spans: measured_spans,
link: chunk.link.clone(),
}
@@ -153,13 +147,17 @@ impl PositionedChunk {
) -> PositionedChunk {
let mut positioned = Vec::new();
+ let advance = measured.spans.iter().fold((0.0, 0.0), |acc, measured| {
+ (acc.0 + measured.advance.0, acc.1 + measured.advance.1)
+ });
+
// measured.advance is the size of the chunk. Compute the offsets needed to align
// it per the text-anchor property (start, middle, end):
let anchor_offset = text_anchor_offset(
measured.values.text_anchor(),
measured.values.direction(),
text_writing_mode,
- measured.advance,
+ advance,
);
let mut x = x + anchor_offset.0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]