[pango/fix-cluster-accounting: 1/4] pango-view: Add --pango-units
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/fix-cluster-accounting: 1/4] pango-view: Add --pango-units
- Date: Thu, 11 Nov 2021 04:48:22 +0000 (UTC)
commit bbbdc707f3c568e5a642afe6342b45654f8f332f
Author: Matthias Clasen <mclasen redhat com>
Date: Wed Nov 10 22:25:23 2021 -0500
pango-view: Add --pango-units
This can make it easier to reproduce problems.
utils/viewer-render.c | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
---
diff --git a/utils/viewer-render.c b/utils/viewer-render.c
index 6f7e96c5..ab0da2dd 100644
--- a/utils/viewer-render.c
+++ b/utils/viewer-render.c
@@ -35,6 +35,7 @@
gboolean opt_display = TRUE;
int opt_dpi = 96;
gboolean opt_pixels = FALSE;
+gboolean opt_pango_units = FALSE;
const char *opt_font = "";
gboolean opt_header = FALSE;
const char *opt_output = NULL;
@@ -120,19 +121,37 @@ make_layout(PangoContext *context,
pango_font_description_set_size (font_description, size * PANGO_SCALE);
if (opt_width > 0)
- pango_layout_set_width (layout, (opt_width * opt_dpi * PANGO_SCALE + 36) / 72);
+ {
+ if (opt_pango_units)
+ pango_layout_set_width (layout, opt_width);
+ else
+ pango_layout_set_width (layout, (opt_width * opt_dpi * PANGO_SCALE + 36) / 72);
+ }
if (opt_height > 0)
- pango_layout_set_height (layout, (opt_height * opt_dpi * PANGO_SCALE + 36) / 72);
+ {
+ if (opt_pango_units)
+ pango_layout_set_width (layout, opt_height);
+ else
+ pango_layout_set_height (layout, (opt_height * opt_dpi * PANGO_SCALE + 36) / 72);
+ }
else
pango_layout_set_height (layout, opt_height);
if (opt_indent != 0)
- pango_layout_set_indent (layout, (opt_indent * opt_dpi * PANGO_SCALE + 36) / 72);
+ {
+ if (opt_pango_units)
+ pango_layout_set_indent (layout, opt_indent);
+ else
+ pango_layout_set_indent (layout, (opt_indent * opt_dpi * PANGO_SCALE + 36) / 72);
+ }
if (opt_spacing != 0)
{
- pango_layout_set_spacing (layout, (opt_spacing * opt_dpi * PANGO_SCALE + 36) / 72);
+ if (opt_pango_units)
+ pango_layout_set_spacing (layout, opt_spacing);
+ else
+ pango_layout_set_spacing (layout, (opt_spacing * opt_dpi * PANGO_SCALE + 36) / 72);
pango_layout_set_line_spacing (layout, 0.0);
}
if (opt_line_spacing >= 0.0)
@@ -360,6 +379,9 @@ do_output (PangoContext *context,
pango_context_set_matrix (context, orig_matrix);
pango_matrix_free (orig_matrix);
+ int w, h;
+ pango_layout_get_size (layout, &w, &h);
+ g_print ("layout %d %d\n", w, h);
g_object_unref (layout);
}
@@ -829,6 +851,8 @@ parse_options (int argc, char *argv[])
"Deprecated", "file"},
{"pixels", 0, 0, G_OPTION_ARG_NONE, &opt_pixels,
"Use pixel units instead of points (sets dpi to 72)", NULL},
+ {"pango-units", 0, 0, G_OPTION_ARG_NONE, &opt_pango_units,
+ "Use Pango units instead of points", NULL},
{"rtl", 0, 0, G_OPTION_ARG_NONE, &opt_rtl,
"Set base direction to right-to-left", NULL},
{"rotate", 0, 0, G_OPTION_ARG_DOUBLE, &opt_rotate,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]