diff options
author | Behdad Esfahbod <behdad@gnome.org> | 2006-08-21 03:05:46 +0000 |
---|---|---|
committer | Behdad Esfahbod <behdad@src.gnome.org> | 2006-08-21 03:05:46 +0000 |
commit | 3ae5159b3f64aa0b5a8119177ab1d765810bd3d8 (patch) | |
tree | 2d5db55240def5407997eecbb563273dd78062a5 /pango/pango-context.c | |
parent | eb1c701a10dc70680326c1bf47d6ae5aea472c46 (diff) | |
download | pango-3ae5159b3f64aa0b5a8119177ab1d765810bd3d8.tar.gz |
Support per-item gravity.
2006-08-20 Behdad Esfahbod <behdad@gnome.org>
Support per-item gravity.
* pango/pango-context.c (update_attr_iterator),
(itemize_state_init), (itemize_state_update_for_new_run),
(itemize_state_process_run): Make per-item gravity work, by setting
gravity into font description before loading fonts. Also, allow
the context font description to override the gravity (but not
centered_baseline.)
* pango/pangocairo-fcfont.c (_pango_cairo_fc_font_new): Get gravity
from font description, not context.
* pango/pangofc-fontmap.c (fontset_hash_key_equal),
(fontset_hash_key_hash), (fontset_hash_key_copy),
(pango_fc_make_pattern), (pango_fc_font_map_get_patterns),
(pango_fc_font_map_load_fontset),
(pango_fc_font_description_from_pattern): Get gravity from font
description, not context. Moreover, put it into pattern, and
reconstruct it out of font patterns.
* pango/pangofc-private.h: Define PANGO_FC_GRAVITY, which is the key
we put PangoGravity into an FcPattern under.
Diffstat (limited to 'pango/pango-context.c')
-rw-r--r-- | pango/pango-context.c | 51 |
1 files changed, 40 insertions, 11 deletions
diff --git a/pango/pango-context.c b/pango/pango-context.c index b3dec728..6044dafc 100644 --- a/pango/pango-context.c +++ b/pango/pango-context.c @@ -615,7 +615,9 @@ struct _ItemizeState int embedding_end_offset; const char *embedding_end; guint8 embedding; + PangoGravity gravity; + PangoGravity font_desc_gravity; gboolean centered_baseline; PangoAttrIterator *attr_iter; @@ -690,6 +692,11 @@ update_attr_iterator (ItemizeState *state) state->font_desc = pango_font_description_copy_static (state->context->font_desc); pango_attr_iterator_get_font (state->attr_iter, state->font_desc, &state->lang, &state->extra_attrs); + if (pango_font_description_get_set_fields (state->font_desc) & PANGO_FONT_MASK_GRAVITY) + state->font_desc_gravity = pango_font_description_get_gravity (state->font_desc); + else + state->font_desc_gravity = PANGO_GRAVITY_AUTO; + state->copy_extra_attrs = FALSE; if (!state->lang) @@ -743,14 +750,6 @@ itemize_state_init (ItemizeState *state, state->embedding_end = text + start_index; update_embedding_end (state); - /* FIXME: Set gravity to base gravity for now, until we do - * proper gravity assignment. - */ - state->gravity = context->resolved_gravity; - - state->centered_baseline = context->resolved_gravity == PANGO_GRAVITY_EAST - || context->resolved_gravity == PANGO_GRAVITY_WEST; - /* Initialize the attribute iterator */ if (cached_iter) @@ -796,6 +795,15 @@ itemize_state_init (ItemizeState *state, update_end (state); + state->centered_baseline = state->context->resolved_gravity == PANGO_GRAVITY_EAST + || state->context->resolved_gravity == PANGO_GRAVITY_WEST; + + if (pango_font_description_get_set_fields (state->font_desc) & PANGO_FONT_MASK_GRAVITY) + state->font_desc_gravity = pango_font_description_get_gravity (state->font_desc); + else + state->font_desc_gravity = PANGO_GRAVITY_AUTO; + + state->gravity = PANGO_GRAVITY_AUTO; state->derived_lang = NULL; state->lang_engine = NULL; state->current_fonts = NULL; @@ -1158,6 +1166,30 @@ get_lang_map (PangoLanguage *lang) static void itemize_state_update_for_new_run (ItemizeState *state) { + if (state->changed & (FONT_CHANGED | SCRIPT_CHANGED)) + { + PangoGravity old_gravity = state->gravity; + + if (state->font_desc_gravity != PANGO_GRAVITY_AUTO) + state->gravity = state->font_desc_gravity; + else + { + PangoGravity gravity = state->context->resolved_gravity; + + /* FIXME + * gravity = pango_script_get_resolved_gravity (script, gravity, hint); + */ + + state->gravity = gravity; + } + + if (old_gravity != state->gravity) + { + pango_font_description_set_gravity (state->font_desc, state->gravity); + state->changed |= FONT_CHANGED; + } + } + if (state->changed & (SCRIPT_CHANGED | LANG_CHANGED)) { PangoLanguage *old_derived_lang = state->derived_lang; @@ -1242,9 +1274,6 @@ itemize_state_process_run (ItemizeState *state) } else { - /* FIXME: We need a way to respect item gravity when loading - * fonts, but we currently don't have a way to do that. - */ get_shaper_and_font (state, wc, &shape_engine, &font); } |