[librsvg: 2/3] (#310): Respect dpi in font-size
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg: 2/3] (#310): Respect dpi in font-size
- Date: Mon, 9 Jul 2018 10:06:23 +0000 (UTC)
commit bf2f86892ebc864e658b86c35a8566e9426074f9
Author: Mike Marcacci <mike marcacci gmail com>
Date: Mon Jul 9 00:52:21 2018 -0600
(#310): Respect dpi in font-size
rsvg_internals/src/text.rs | 3 +-
.../reftests/bugs/310-font-size-at-48dpi-ref.png | Bin 0 -> 5818 bytes
.../reftests/bugs/310-font-size-at-48dpi.svg | 62 +++++++++++++++++++++
tests/rsvg-test.c | 5 +-
4 files changed, 67 insertions(+), 3 deletions(-)
---
diff --git a/rsvg_internals/src/text.rs b/rsvg_internals/src/text.rs
index 7a6a3c86..b4bfcc62 100644
--- a/rsvg_internals/src/text.rs
+++ b/rsvg_internals/src/text.rs
@@ -505,9 +505,8 @@ fn create_pango_layout(
font_desc.set_stretch(pango::Stretch::from(values.font_stretch));
- let (_, dpi_y) = draw_ctx.get_dpi();
font_desc.set_size(to_pango_units(
- values.font_size.0.normalize(values, draw_ctx) / dpi_y * 72.0,
+ values.font_size.0.normalize(values, draw_ctx),
));
let layout = pango::Layout::new(&pango_context);
diff --git a/tests/fixtures/reftests/bugs/310-font-size-at-48dpi-ref.png
b/tests/fixtures/reftests/bugs/310-font-size-at-48dpi-ref.png
new file mode 100644
index 00000000..dd7d7eaf
Binary files /dev/null and b/tests/fixtures/reftests/bugs/310-font-size-at-48dpi-ref.png differ
diff --git a/tests/fixtures/reftests/bugs/310-font-size-at-48dpi.svg
b/tests/fixtures/reftests/bugs/310-font-size-at-48dpi.svg
new file mode 100644
index 00000000..c495db96
--- /dev/null
+++ b/tests/fixtures/reftests/bugs/310-font-size-at-48dpi.svg
@@ -0,0 +1,62 @@
+<svg
+ version="1.1"
+ xmlns="http://www.w3.org/2000/svg"
+ width="512"
+ height="512"
+ >
+ <g>
+ <rect
+ x="0"
+ y="0"
+ width="256"
+ height="128"
+ fill="orange"
+ ></rect>
+ <rect
+ x="191"
+ y="108"
+ width="130"
+ height="40"
+ rx="20"
+ ry="20"
+ stroke="rgb(209, 237, 255)"
+ stroke-width="4"
+ fill="rgb(0, 154, 255)"
+ ></rect>
+ <text
+ font-size="20"
+ x="255"
+ y="135"
+ text-anchor="middle"
+ fill="white"
+ >I Love Lamp</text>
+ </g>
+
+ <g transform="translate(0 160)">
+ <rect
+ x="0pt"
+ y="0pt"
+ width="256pt"
+ height="128pt"
+ fill="orange"
+ ></rect>
+ <rect
+ x="191pt"
+ y="108pt"
+ width="130pt"
+ height="40pt"
+ rx="20pt"
+ ry="20pt"
+ stroke="rgb(209, 237, 255)"
+ stroke-width="4pt"
+ fill="rgb(0, 154, 255)"
+ ></rect>
+ <text
+ font-size="20pt"
+ x="255pt"
+ y="135pt"
+ text-anchor="middle"
+ fill="white"
+ >I Love Lamp</text>
+ </g>
+</svg>
\ No newline at end of file
diff --git a/tests/rsvg-test.c b/tests/rsvg-test.c
index 93c38709..011db122 100644
--- a/tests/rsvg-test.c
+++ b/tests/rsvg-test.c
@@ -310,7 +310,10 @@ rsvg_cairo_check (gconstpointer data)
rsvg_handle_internal_set_testing (rsvg, TRUE);
- rsvg_handle_set_dpi_x_y (rsvg, 72.0, 72.0);
+ if (g_str_has_suffix (test_file_base, "-48dpi"))
+ rsvg_handle_set_dpi_x_y (rsvg, 48.0, 48.0);
+ else
+ rsvg_handle_set_dpi_x_y (rsvg, 72.0, 72.0);
rsvg_handle_get_dimensions (rsvg, &dimensions);
g_assert (dimensions.width > 0);
g_assert (dimensions.height > 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]