[librsvg: 13/37] text.rs: new MeasuredChunk, analogous to MeasuredSpan



commit 251400f56d19d7d8ffcdedc32053eb5f71d23d85
Author: Federico Mena Quintero <federico gnome org>
Date:   Tue Oct 30 18:29:30 2018 -0600

    text.rs: new MeasuredChunk, analogous to MeasuredSpan

 rsvg_internals/src/text.rs | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
---
diff --git a/rsvg_internals/src/text.rs b/rsvg_internals/src/text.rs
index 74a8228f..9627a7aa 100644
--- a/rsvg_internals/src/text.rs
+++ b/rsvg_internals/src/text.rs
@@ -53,6 +53,12 @@ impl Chunk {
     }
 }
 
+struct MeasuredChunk {
+    x: Option<Length>,
+    y: Option<Length>,
+    spans: Vec<MeasuredSpan>,
+}
+
 struct Span {
     values: ComputedValues,
     text: String,
@@ -81,6 +87,20 @@ impl Span {
     }
 }
 
+impl MeasuredChunk {
+    fn from_chunk(chunk: &Chunk, draw_ctx: &DrawingCtx<'_>) -> MeasuredChunk {
+        MeasuredChunk {
+            x: chunk.x,
+            y: chunk.y,
+            spans: chunk
+                .spans
+                .iter()
+                .map(|span| MeasuredSpan::from_span(span, draw_ctx))
+                .collect(),
+        }
+    }
+}
+
 impl MeasuredSpan {
     fn from_span(span: &Span, draw_ctx: &DrawingCtx) -> MeasuredSpan {
         let values = span.values.clone();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]