summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-11-10 22:25:23 -0500
committerMatthias Clasen <mclasen@redhat.com>2021-11-11 20:23:47 -0500
commit7b688167a30fe9861bd896c8ab317483daf8286b (patch)
tree14a1f36f92fe886444c80345070a1f943d0de6b4
parent430f105d81ff4ba8e7dce73910c77459cfcb5b3f (diff)
downloadpango-7b688167a30fe9861bd896c8ab317483daf8286b.tar.gz
pango-view: Add --pango-units
This can make it easier to reproduce problems.
-rw-r--r--utils/viewer-render.c32
1 files 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,