diff options
author | Behdad Esfahbod <behdad@gnome.org> | 2006-08-15 11:51:37 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@src.gnome.org> | 2006-08-15 11:51:37 +0000 |
commit | 8de44f9dc7712a7ce258b70a7b8283b3ebca094e (patch) | |
tree | f19a8eeb43df4d8f0ec8ffda31f6f2c0ad29bece /examples/renderdemo.c | |
parent | a79ad88362620acce4cdbebac12f049b83a1a396 (diff) | |
download | pango-8de44f9dc7712a7ce258b70a7b8283b3ebca094e.tar.gz |
Support --gravity.
2006-08-15 Behdad Esfahbod <behdad@gnome.org>
* examples/renderdemo.c (do_output), (parse_gravity),
(parse_options): Support --gravity.
* pango/pangocairo-fcfont.c (pango_cairo_fc_font_get_scaled_font),
(compute_glyph_extents), (_pango_cairo_fc_font_new): Load rotated
scaled_fonts to handle gravity.
* pango/pangofc-fontmap.c (pango_fc_make_pattern),
(pango_fc_font_map_get_patterns), (pango_fc_font_map_load_fontset):
Set FC_VERTICAL_LAYOUT on West and East gravity.
Diffstat (limited to 'examples/renderdemo.c')
-rw-r--r-- | examples/renderdemo.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/examples/renderdemo.c b/examples/renderdemo.c index 5a38ffd2..13781614 100644 --- a/examples/renderdemo.c +++ b/examples/renderdemo.c @@ -56,6 +56,7 @@ int opt_width = -1; int opt_indent = 0; int opt_runs = 1; PangoEllipsizeMode opt_ellipsize = PANGO_ELLIPSIZE_NONE; +PangoGravity opt_gravity = PANGO_GRAVITY_NORTH; HintMode opt_hinting = HINT_DEFAULT; PangoWrapMode opt_wrap = PANGO_WRAP_WORD_CHAR; gboolean opt_wrap_set = FALSE; @@ -276,6 +277,7 @@ do_output (PangoContext *context, pango_context_set_language (context, pango_language_from_string ("en_US")); pango_context_set_base_dir (context, opt_rtl ? PANGO_DIRECTION_RTL : PANGO_DIRECTION_LTR); + pango_context_set_base_gravity (context, opt_gravity); if (opt_header) { @@ -379,6 +381,34 @@ parse_ellipsis (const char *name, } static gboolean +parse_gravity (const char *name, + const char *arg, + gpointer data, + GError **error) +{ + static GEnumClass *class = NULL; + gboolean ret = TRUE; + GEnumValue *value; + + if (!class) + class = g_type_class_ref (PANGO_TYPE_GRAVITY); + + value = g_enum_get_value_by_nick (class, arg); + if (value) + opt_gravity = value->value; + else + { + g_set_error(error, + G_OPTION_ERROR, + G_OPTION_ERROR_BAD_VALUE, + "Argument for --gravity must be one of north/west/south/east"); + ret = FALSE; + } + + return ret; +} + +static gboolean parse_hinting (const char *name, const char *arg, gpointer data, @@ -551,6 +581,8 @@ parse_options (int argc, char *argv[]) "Ellipsization mode", "start/middle/end"}, {"font", 0, 0, G_OPTION_ARG_STRING, &opt_font, "Set the font description", "description"}, + {"gravity", 0, 0, G_OPTION_ARG_CALLBACK, &parse_gravity, + "Gravity", "north/west/south/east"}, {"header", 0, 0, G_OPTION_ARG_NONE, &opt_header, "Display the options in the output", NULL}, {"hinting", 0, 0, G_OPTION_ARG_CALLBACK, &parse_hinting, |