diff options
-rw-r--r-- | ChangeLog | 24 | ||||
-rw-r--r-- | docs/pango-sections.txt | 1 | ||||
-rw-r--r-- | docs/tmpl/main.sgml | 10 | ||||
-rw-r--r-- | examples/renderdemo.c | 4 | ||||
-rw-r--r-- | pango/pango-context.c | 44 | ||||
-rw-r--r-- | pango/pango-context.h | 1 | ||||
-rw-r--r-- | pango/pango-layout.c | 2 | ||||
-rw-r--r-- | pango/pango-matrix.c | 14 | ||||
-rw-r--r-- | pango/pango-types.h | 8 | ||||
-rw-r--r-- | pango/pango.def | 1 | ||||
-rw-r--r-- | pango/pangocairo-fcfont.c | 4 | ||||
-rw-r--r-- | pango/pangofc-fontmap.c | 3 |
12 files changed, 102 insertions, 14 deletions
@@ -1,5 +1,29 @@ 2006-08-20 Behdad Esfahbod <behdad@gnome.org> + * pango/pango-matrix.c (pango_matrix_to_gravity): Correct switched + return value of EAST/WEST. + + * pango/pango-types.h (PangoGravity): Add PANGO_GRAVITY_AUTO. + * pango/pango-context.h: Add pango_context_get_gravity(). + + * examples/renderdemo.c (parse_gravity), (parse_options): + * pango/pango-context.c (pango_context_init), + (update_resolved_gravity), (pango_context_set_matrix), + (pango_context_set_base_gravity), (pango_context_get_gravity), + (itemize_state_init), (get_shaper_and_font): + * pango/pango-layout.c (line_set_resolved_dir): + * pango/pangocairo-fcfont.c (pango_cairo_fc_font_get_metrics), + (pango_cairo_fc_font_glyph_extents_cache_init), + (_pango_cairo_fc_font_new): + * pango/pangofc-fontmap.c (pango_fc_make_pattern), + (pango_fc_font_map_load_fontset): + * pango/pango.def: + * docs/pango-sections.txt: + * docs/tmpl/main.sgml: + Update to above. + +2006-08-20 Behdad Esfahbod <behdad@gnome.org> + * examples/renderdemo.c (parse_options): * examples/renderdemo.h: Change the --rotate parameter to double now that we depend on a recent-enough glib. diff --git a/docs/pango-sections.txt b/docs/pango-sections.txt index eb67adef..010abd77 100644 --- a/docs/pango-sections.txt +++ b/docs/pango-sections.txt @@ -29,6 +29,7 @@ pango_context_get_base_dir pango_context_set_base_dir pango_context_get_base_gravity pango_context_set_base_gravity +pango_context_get_gravity pango_context_get_matrix pango_context_set_matrix pango_context_load_font diff --git a/docs/tmpl/main.sgml b/docs/tmpl/main.sgml index 24487182..0d948601 100644 --- a/docs/tmpl/main.sgml +++ b/docs/tmpl/main.sgml @@ -83,6 +83,7 @@ The #GObject type for #PangoDirection. @PANGO_GRAVITY_EAST: @PANGO_GRAVITY_NORTH: @PANGO_GRAVITY_WEST: +@PANGO_GRAVITY_AUTO: <!-- ##### MACRO PANGO_TYPE_GRAVITY ##### --> <para> @@ -263,6 +264,15 @@ The #GObject type for #PangoGravity. @gravity: +<!-- ##### FUNCTION pango_context_get_gravity ##### --> +<para> + +</para> + +@context: +@Returns: + + <!-- ##### FUNCTION pango_context_get_matrix ##### --> <para> diff --git a/examples/renderdemo.c b/examples/renderdemo.c index 0d989064..17b50612 100644 --- a/examples/renderdemo.c +++ b/examples/renderdemo.c @@ -403,7 +403,7 @@ parse_gravity (const char *name, g_set_error(error, G_OPTION_ERROR, G_OPTION_ERROR_BAD_VALUE, - "Argument for --gravity must be one of south/east/north/west"); + "Argument for --gravity must be one of south/east/north/west/auto"); ret = FALSE; } @@ -584,7 +584,7 @@ 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", "south/east/north/west"}, + "Gravity", "south/east/north/west/auto"}, {"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/pango/pango-context.c b/pango/pango-context.c index ac6db552..b3dec728 100644 --- a/pango/pango-context.c +++ b/pango/pango-context.c @@ -37,6 +37,7 @@ struct _PangoContext PangoLanguage *language; PangoDirection base_dir; PangoGravity base_gravity; + PangoGravity resolved_gravity; PangoFontDescription *font_desc; @@ -59,7 +60,7 @@ static void pango_context_init (PangoContext *context) { context->base_dir = PANGO_DIRECTION_WEAK_LTR; - context->base_gravity = PANGO_GRAVITY_SOUTH; + context->resolved_gravity = context->base_gravity = PANGO_GRAVITY_SOUTH; context->language = NULL; context->font_map = NULL; @@ -128,6 +129,15 @@ pango_context_new (void) return context; } +static void +update_resolved_gravity (PangoContext *context) +{ + if (context->base_gravity == PANGO_GRAVITY_AUTO) + context->resolved_gravity = pango_matrix_to_gravity (context->matrix); + else + context->resolved_gravity = context->base_gravity; +} + /** * pango_context_set_matrix: * @context: a #PangoContext @@ -155,6 +165,8 @@ pango_context_set_matrix (PangoContext *context, context->matrix = pango_matrix_copy (matrix); else context->matrix = NULL; + + update_resolved_gravity (context); } /** @@ -423,6 +435,8 @@ pango_context_set_base_gravity (PangoContext *context, g_return_if_fail (context != NULL); context->base_gravity = gravity; + + update_resolved_gravity (context); } /** @@ -444,6 +458,27 @@ pango_context_get_base_gravity (PangoContext *context) return context->base_gravity; } +/** + * pango_context_get_gravity: + * @context: a #PangoContext + * + * Retrieves the gravity for the context. This is similar to + * pango_context_get_base_gravity(), except for when the base gravity + * is %PANGO_GRAVITY_AUTO for which pango_matrix_to_gravity() is used + * to return the gravity from the current context matrix. + * + * Return value: the resolved gravity for the context. + * + * Since: 1.16 + **/ +PangoGravity +pango_context_get_gravity (PangoContext *context) +{ + g_return_val_if_fail (context != NULL, PANGO_GRAVITY_SOUTH); + + return context->resolved_gravity; +} + /**********************************************************************/ static gboolean @@ -711,10 +746,10 @@ itemize_state_init (ItemizeState *state, /* FIXME: Set gravity to base gravity for now, until we do * proper gravity assignment. */ - state->gravity = context->base_gravity; + state->gravity = context->resolved_gravity; - state->centered_baseline = context->base_gravity == PANGO_GRAVITY_EAST - || context->base_gravity == PANGO_GRAVITY_WEST; + state->centered_baseline = context->resolved_gravity == PANGO_GRAVITY_EAST + || context->resolved_gravity == PANGO_GRAVITY_WEST; /* Initialize the attribute iterator */ @@ -1014,6 +1049,7 @@ get_shaper_and_font (ItemizeState *state, { case PANGO_GRAVITY_SOUTH: case PANGO_GRAVITY_NORTH: + case PANGO_GRAVITY_AUTO: default: script = state->script; break; diff --git a/pango/pango-context.h b/pango/pango-context.h index 97af918c..25bdf4ab 100644 --- a/pango/pango-context.h +++ b/pango/pango-context.h @@ -81,6 +81,7 @@ PangoDirection pango_context_get_base_dir (PangoContext void pango_context_set_base_gravity (PangoContext *context, PangoGravity gravity); PangoGravity pango_context_get_base_gravity (PangoContext *context); +PangoGravity pango_context_get_gravity (PangoContext *context); void pango_context_set_matrix (PangoContext *context, const PangoMatrix *matrix); diff --git a/pango/pango-layout.c b/pango/pango-layout.c index 4c9ec92f..1a5917ba 100644 --- a/pango/pango-layout.c +++ b/pango/pango-layout.c @@ -3028,7 +3028,7 @@ line_set_resolved_dir (PangoLayoutLine *line, * A similar dance is performed in pango-context.c: * itemize_state_add_character(). Keep in synch. */ - switch (pango_context_get_base_gravity (line->layout->context)) + switch (pango_context_get_gravity (line->layout->context)) { case PANGO_GRAVITY_SOUTH: default: diff --git a/pango/pango-matrix.c b/pango/pango-matrix.c index 322a4931..e63ecab1 100644 --- a/pango/pango-matrix.c +++ b/pango/pango-matrix.c @@ -258,7 +258,7 @@ pango_matrix_get_font_scale_factor (const PangoMatrix *matrix) * in a #PangoMatrix. * * Return value: the gravity of @matrix, which will never be - * %PANGO_GRAVITY_AUTO + * %PANGO_GRAVITY_AUTO, or PANGO_GRAVITY_SOUTH if @matrix is %NULL * * Since: 1.16 */ @@ -266,11 +266,17 @@ PangoGravity pango_matrix_to_gravity (const PangoMatrix *matrix) { PangoGravity gravity; - double x = matrix->xy; - double y = matrix->yy; + double x; + double y; + + if (!matrix) + return PANGO_GRAVITY_SOUTH; + + x = matrix->xy; + y = matrix->yy; if (abs (x) > abs (y)) - gravity = x < 0 ? PANGO_GRAVITY_WEST : PANGO_GRAVITY_EAST; + gravity = x > 0 ? PANGO_GRAVITY_WEST : PANGO_GRAVITY_EAST; else gravity = y < 0 ? PANGO_GRAVITY_NORTH : PANGO_GRAVITY_SOUTH; diff --git a/pango/pango-types.h b/pango/pango-types.h index 9d4caba6..2e8b5a83 100644 --- a/pango/pango-types.h +++ b/pango/pango-types.h @@ -154,11 +154,16 @@ gboolean pango_get_mirror_char (gunichar ch, * @PANGO_GRAVITY_EAST: Glyphs are rotated 90 degrees clockwise * @PANGO_GRAVITY_NORTH: Glyphs are upside-down * @PANGO_GRAVITY_WEST: Glyphs are rotated 90 degrees counter-clockwise + * @PANGO_GRAVITY_AUTO: Gravity is resolved from the context matrix * * The #PangoGravity type represents the orientation of glyphs in a segment * of text. This is useful when rendering vertical text layouts. In * those situations, the layout is rotated using a non-identity PangoMatrix, * and then glyph orientation is controlled using #PangoGravity. + * Not every value in this enumeration makes sense for every usage of + * #PangoGravity; for example, %PANGO_GRAVITY_AUTO only can be passed to + * pango_context_set_base_gravity() and can only be returned by + * pango_context_get_base_gravity(). * * Since: 1.16 **/ @@ -166,7 +171,8 @@ typedef enum { PANGO_GRAVITY_SOUTH, PANGO_GRAVITY_EAST, PANGO_GRAVITY_NORTH, - PANGO_GRAVITY_WEST + PANGO_GRAVITY_WEST, + PANGO_GRAVITY_AUTO } PangoGravity; double pango_gravity_to_rotation (PangoGravity gravity); diff --git a/pango/pango.def b/pango/pango.def index 32576db6..fed46d8b 100644 --- a/pango/pango.def +++ b/pango/pango.def @@ -54,6 +54,7 @@ EXPORTS pango_context_get_base_gravity pango_context_get_font_description pango_context_get_font_map + pango_context_get_gravity pango_context_get_language pango_context_get_matrix pango_context_get_metrics diff --git a/pango/pangocairo-fcfont.c b/pango/pangocairo-fcfont.c index a0dec5c6..f6ce1087 100644 --- a/pango/pangocairo-fcfont.c +++ b/pango/pangocairo-fcfont.c @@ -239,6 +239,7 @@ pango_cairo_fc_font_get_metrics (PangoFont *font, switch (cffont->gravity) { default: + case PANGO_GRAVITY_AUTO: case PANGO_GRAVITY_SOUTH: break; case PANGO_GRAVITY_NORTH: @@ -299,6 +300,7 @@ pango_cairo_fc_font_glyph_extents_cache_init (PangoCairoFcFont *cffont) switch (cffont->gravity) { default: + case PANGO_GRAVITY_AUTO: case PANGO_GRAVITY_SOUTH: cffont->font_extents.y = - PANGO_UNITS (font_extents.ascent); break; @@ -506,7 +508,7 @@ _pango_cairo_fc_font_new (PangoCairoFcFontMap *cffontmap, NULL); /* FIXME: support per-item gravity */ - cffont->gravity = pango_context_get_base_gravity (context); + cffont->gravity = pango_context_get_gravity (context); if (FcPatternGetMatrix (pattern, FC_MATRIX, 0, &fc_matrix) == FcResultMatch) diff --git a/pango/pangofc-fontmap.c b/pango/pangofc-fontmap.c index 356b321a..756774ad 100644 --- a/pango/pangofc-fontmap.c +++ b/pango/pangofc-fontmap.c @@ -812,6 +812,7 @@ pango_fc_make_pattern (const PangoFontDescription *description, width = pango_fc_convert_width_to_fc (pango_font_description_get_stretch (description)); #endif + /* FIXME: get gravity from description */ switch (gravity) { case PANGO_GRAVITY_SOUTH: @@ -1233,7 +1234,7 @@ pango_fc_font_map_load_fontset (PangoFontMap *fontmap, { /* FIXME: support per-item gravity */ PangoFcPatternSet *patterns = pango_fc_font_map_get_patterns (fontmap, context, desc, language, - pango_context_get_base_gravity (context)); + pango_context_get_gravity (context)); PangoFontset *result; int i; |