[librsvg: 7/20] Get the chunk_direction only once
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 7/20] Get the chunk_direction only once
- Date: Thu, 21 Oct 2021 00:26:07 +0000 (UTC)
commit 3f4e3952df02ad89059fda78876ac1659484528c
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Oct 19 18:43:28 2021 -0500
Get the chunk_direction only once
Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/616>
src/text.rs | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
---
diff --git a/src/text.rs b/src/text.rs
index 73c010a0..3fd9f0a2 100644
--- a/src/text.rs
+++ b/src/text.rs
@@ -147,6 +147,8 @@ impl PositionedChunk {
) -> PositionedChunk {
let mut positioned = Vec::new();
+ let chunk_direction = measured.values.direction();
+
let advance = measured.spans.iter().fold((0.0, 0.0), |acc, measured| {
(acc.0 + measured.advance.0, acc.1 + measured.advance.1)
});
@@ -155,7 +157,7 @@ impl PositionedChunk {
// it per the text-anchor property (start, middle, end):
let anchor_offset = text_anchor_offset(
measured.values.text_anchor(),
- measured.values.direction(),
+ chunk_direction,
text_writing_mode,
advance,
);
@@ -176,12 +178,12 @@ impl PositionedChunk {
let baseline_offset = compute_baseline_offset(&layout, &values, ¶ms);
- let start_pos = match measured.values.direction() {
+ let start_pos = match chunk_direction {
Direction::Ltr => (x, y),
Direction::Rtl => (x - advance.0, y),
};
- let span_advance = match measured.values.direction() {
+ let span_advance = match chunk_direction {
Direction::Ltr => (advance.0, advance.1),
Direction::Rtl => (-advance.0, advance.1),
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]