summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@gnome.org>2007-01-16 00:23:59 +0000
committerBehdad Esfahbod <behdad@src.gnome.org>2007-01-16 00:23:59 +0000
commit7a102793913cb7a1a0eefbbfc9d5c0d04c9eb868 (patch)
treed614b6941c83927af97a818fde59841499dd7917 /examples
parentfd7ecbb0203d89f31e9b9b7c10147fa2a3864513 (diff)
downloadpango-7a102793913cb7a1a0eefbbfc9d5c0d04c9eb868.tar.gz
Bug 323173 – Add layout of mixed direction text for vertical layout
2007-01-15 Behdad Esfahbod <behdad@gnome.org> Bug 323173 – Add layout of mixed direction text for vertical layout * pango/pango-gravity.h: * pango/pango-gravity.c: Moved gravity stuff here. New public API: PangoGravityHint pango_gravity_get_for_matrix() pango_gravity_get_for_script() * pango/pango-context.h: * pango/pango-context.c (pango_context_init), (update_resolved_gravity), (itemize_state_update_for_new_run): Support gravity hint. New public API: pango_context_set_gravity_hint() pango_context_get_gravity_hint() * pango/pango-utils.c: * pango/pango-matrix.c: * pango/pango-matrix.h: * pango/pango-types.h: Moved gravity and matrix stuff into its own header. pango-types.h includes both pango-matrix.h and pango-gravity.h * pango/pango.h: Include new headers. * pango/pango.def: * pango/Makefile.am: Update. * docs/pango-docs.sgml: * docs/pango-sections.txt: * docs/tmpl/glyphs.sgml: * docs/tmpl/main.sgml: * docs/tmpl/vertical.sgml: Add a section for Vertical Text. * examples/renderdemo.c (do_output), (parse_gravity_hint), (parse_options): Support gravity hint. * examples/test-mixed.txt: New test, mixed Latin, Arabic, Chinese text. svn path=/trunk/; revision=2144
Diffstat (limited to 'examples')
-rw-r--r--examples/renderdemo.c34
-rw-r--r--examples/test-mixed.txt8
2 files changed, 41 insertions, 1 deletions
diff --git a/examples/renderdemo.c b/examples/renderdemo.c
index 9fd16ff0..21773e4e 100644
--- a/examples/renderdemo.c
+++ b/examples/renderdemo.c
@@ -57,6 +57,7 @@ int opt_indent = 0;
int opt_runs = 1;
PangoEllipsizeMode opt_ellipsize = PANGO_ELLIPSIZE_NONE;
PangoGravity opt_gravity = PANGO_GRAVITY_SOUTH;
+PangoGravityHint opt_gravity_hint = PANGO_GRAVITY_HINT_NATURAL;
HintMode opt_hinting = HINT_DEFAULT;
PangoWrapMode opt_wrap = PANGO_WRAP_WORD_CHAR;
gboolean opt_wrap_set = FALSE;
@@ -289,6 +290,7 @@ do_output (PangoContext *context,
}
pango_context_set_base_gravity (context, opt_gravity);
+ pango_context_set_gravity_hint (context, opt_gravity_hint);
set_transform (context, transform_cb, cb_context, cb_data, &matrix);
@@ -389,6 +391,34 @@ parse_gravity (const char *name,
}
static gboolean
+parse_gravity_hint (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_HINT);
+
+ value = g_enum_get_value_by_nick (class, arg);
+ if (value)
+ opt_gravity_hint = value->value;
+ else
+ {
+ g_set_error(error,
+ G_OPTION_ERROR,
+ G_OPTION_ERROR_BAD_VALUE,
+ "Argument for --gravity-hint must be one of natural/strong/line");
+ ret = FALSE;
+ }
+
+ return ret;
+}
+
+static gboolean
parse_hinting (const char *name,
const char *arg,
gpointer data,
@@ -566,7 +596,9 @@ parse_options (int argc, char *argv[])
{"font", 0, 0, G_OPTION_ARG_STRING, &opt_font,
"Set the font description", "description"},
{"gravity", 0, 0, G_OPTION_ARG_CALLBACK, &parse_gravity,
- "Gravity: glyph rotation", "south/east/north/west/auto"},
+ "Base gravity: glyph rotation", "south/east/north/west/auto"},
+ {"gravity-hint", 0, 0, G_OPTION_ARG_CALLBACK, &parse_gravity_hint,
+ "Gravity hint", "natural/strong/line"},
{"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,
diff --git a/examples/test-mixed.txt b/examples/test-mixed.txt
new file mode 100644
index 00000000..5c3f1a2f
--- /dev/null
+++ b/examples/test-mixed.txt
@@ -0,0 +1,8 @@
+你好,这是中文竖排测试。
+欢迎来到中国北京。
+白日依山尽,
+Roses are Red,
+Grass is Green. 2006
+Arabic is گل‌ها قرمزند،‏
+چمن سبز. ۲۰۰۶
+白日依山尽, 2006