[librsvg: 2/5] Factor out some duplicated code
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 2/5] Factor out some duplicated code
- Date: Wed, 24 Oct 2018 13:14:39 +0000 (UTC)
commit f535e2475172c6cee8d03faa795ec5749f86ec8a
Author: Federico Mena Quintero <federico gnome org>
Date: Tue Oct 23 11:50:41 2018 -0500
Factor out some duplicated code
rsvg_internals/src/text.rs | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
---
diff --git a/rsvg_internals/src/text.rs b/rsvg_internals/src/text.rs
index 437ca5ed..05cb4331 100644
--- a/rsvg_internals/src/text.rs
+++ b/rsvg_internals/src/text.rs
@@ -74,6 +74,13 @@ impl NodeChars {
}
}
+ fn create_layout(&self, values: &ComputedValues, draw_ctx: &DrawingCtx<'_>) -> pango::Layout {
+ self.ensure_normalized_string(values);
+ let norm = self.space_normalized.borrow();
+ let s = norm.as_ref().unwrap();
+ create_pango_layout(draw_ctx, values, &s)
+ }
+
fn measure(
&self,
_node: &RsvgNode,
@@ -81,10 +88,7 @@ impl NodeChars {
draw_ctx: &DrawingCtx<'_>,
length: &mut f64,
) {
- self.ensure_normalized_string(values);
- let norm = self.space_normalized.borrow();
- let s = norm.as_ref().unwrap();
- let layout = create_pango_layout(draw_ctx, values, &s);
+ let layout = self.create_layout(values, draw_ctx);
let (width, _) = layout.get_size();
*length = f64::from(width) / f64::from(pango::SCALE);
@@ -99,10 +103,7 @@ impl NodeChars {
y: &mut f64,
clipping: bool,
) -> Result<(), RenderingError> {
- self.ensure_normalized_string(values);
- let norm = self.space_normalized.borrow();
- let s = norm.as_ref().unwrap();
- let layout = create_pango_layout(draw_ctx, values, &s);
+ let layout = self.create_layout(values, draw_ctx);
let (width, _) = layout.get_size();
let baseline = f64::from(layout.get_baseline()) / f64::from(pango::SCALE);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]