summaryrefslogtreecommitdiff
path: root/pango-view
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2008-01-15 01:20:44 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2008-01-15 01:20:44 +0000
commit0946d48d16c30e5b64e3ad946454324a3628be08 (patch)
tree8e77638d0945c3e92d8435710bd683861014394f /pango-view
parent7f7dbc1ecc87f11c03aea4a37e2011af3dd9b308 (diff)
downloadpango-0946d48d16c30e5b64e3ad946454324a3628be08.tar.gz
Bug 469313 – Add pango_layout_set_height() Bug 508179 – PangoGlyphUnit
2008-01-14 Behdad Esfahbod <behdad@gnome.org> Bug 469313 – Add pango_layout_set_height() Bug 508179 – PangoGlyphUnit confusion * pango/pango-layout.h: * pango/pango-layout-private.h: * pango/pango-layout.c: * pango/ellipsize.c (_pango_layout_line_ellipsize): New public API: pango_layout_set_height() See docs for semantics. Currently only negative height values (number of lines) is implemented. * pango-view/viewer-render.c (make_layout), (output_body), (parse_options): Implement --height. * pango/pango.def: * docs/pango-sections.txt: * docs/tmpl/layout.sgml: Update. 2008-01-14 Behdad Esfahbod <behdad@gnome.org> Bug 508179 – PangoGlyphUnit confusion * pango/pangowin32.c: * pango/glyphstring.c: * pango/pango-layout.c (process_item): Remove all traces of #PangoGlyphUnit svn path=/trunk/; revision=2542
Diffstat (limited to 'pango-view')
-rw-r--r--pango-view/viewer-render.c33
1 files changed, 17 insertions, 16 deletions
diff --git a/pango-view/viewer-render.c b/pango-view/viewer-render.c
index bc98da85..c0ecf054 100644
--- a/pango-view/viewer-render.c
+++ b/pango-view/viewer-render.c
@@ -53,6 +53,7 @@ gboolean opt_auto_dir = TRUE;
const char *opt_text = NULL;
gboolean opt_waterfall = FALSE;
int opt_width = -1;
+int opt_height = -1;
int opt_indent = 0;
gboolean opt_justify = 0;
int opt_runs = 1;
@@ -117,16 +118,19 @@ make_layout(PangoContext *context,
pango_layout_set_ellipsize (layout, opt_ellipsize);
pango_layout_set_justify (layout, opt_justify);
pango_layout_set_single_paragraph_mode (layout, opt_single_par);
+ pango_layout_set_wrap (layout, opt_wrap);
font_description = get_font_description ();
if (size > 0)
pango_font_description_set_size (font_description, size * PANGO_SCALE);
if (opt_width > 0)
- {
- pango_layout_set_wrap (layout, opt_wrap);
- pango_layout_set_width (layout, (opt_width * opt_dpi * PANGO_SCALE + 36) / 72);
- }
+ 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);
+ 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);
@@ -220,14 +224,16 @@ output_body (PangoLayout *layout,
pango_font_description_free (desc);
}
- pango_layout_get_extents (layout, NULL, &logical_rect);
+ pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
if (render_cb)
(*render_cb) (layout, x, y+*height, cb_context, cb_data);
- *width = MAX (*width, PANGO_PIXELS (logical_rect.x + logical_rect.width));
- *width = MAX (*width, PANGO_PIXELS (pango_layout_get_width (layout)));
- *height += PANGO_PIXELS (logical_rect.height);
+ *width = MAX (*width,
+ MAX (logical_rect.x + logical_rect.width,
+ PANGO_PIXELS (pango_layout_get_width (layout))));
+ *height += MAX (logical_rect.y + logical_rect.height,
+ PANGO_PIXELS (pango_layout_get_height (layout)));
}
}
@@ -516,7 +522,6 @@ backend_description (void)
}
-
static gboolean
parse_backend (const char *name,
const char *arg,
@@ -592,6 +597,8 @@ parse_options (int argc, char *argv[])
"Gravity hint", "natural/strong/line"},
{"header", 0, 0, G_OPTION_ARG_NONE, &opt_header,
"Display the options in the output", NULL},
+ {"height", 0, 0, G_OPTION_ARG_INT, &opt_height,
+ "Height in points (positive) or number of lines (negative) for ellipsizing", "+points/-numlines"},
{"hinting", 0, 0, G_OPTION_ARG_CALLBACK, &parse_hinting,
"Hinting style", "none/auto/full"},
{"indent", 0, 0, G_OPTION_ARG_INT, &opt_indent,
@@ -623,7 +630,7 @@ parse_options (int argc, char *argv[])
{"waterfall", 0, 0, G_OPTION_ARG_NONE, &opt_waterfall,
"Create a waterfall display", NULL},
{"width", 'w', 0, G_OPTION_ARG_INT, &opt_width,
- "Width in points to which to wrap output", "points"},
+ "Width in points to which to wrap lines or ellipsize", "points"},
{"wrap", 0, 0, G_OPTION_ARG_CALLBACK, &parse_wrap,
"Text wrapping mode (needs a width to be set)", "word/char/word-char"},
{NULL}
@@ -665,12 +672,6 @@ parse_options (int argc, char *argv[])
fail ("No viewer backend found");
}
- /* if wrap mode is set then width must be set */
- if (opt_width < 0 && opt_wrap_set)
- {
- g_printerr ("The wrap mode only has effect if a width is set\n");
- }
-
/* Get the text
*/
if (opt_text)