summaryrefslogtreecommitdiff
path: root/pango/pango-ot-info.c
diff options
context:
space:
mode:
authorBehdad Esfahbod <behdad@behdad.org>2009-11-06 16:30:46 -0500
committerBehdad Esfahbod <behdad@behdad.org>2009-11-06 16:47:22 -0500
commit7455ff248507bfe3b26b5739de7a3ee54c50698d (patch)
tree5363349a496e29d21d2cde123c428e4decc9f359 /pango/pango-ot-info.c
parenta7b753f0084913f64c67c7b7764da56dc6d67d8a (diff)
downloadpango-7455ff248507bfe3b26b5739de7a3ee54c50698d.tar.gz
Use hb_ot_layout_position_finish()
Diffstat (limited to 'pango/pango-ot-info.c')
-rw-r--r--pango/pango-ot-info.c55
1 files changed, 30 insertions, 25 deletions
diff --git a/pango/pango-ot-info.c b/pango/pango-ot-info.c
index 39129dfb..eeb39443 100644
--- a/pango/pango-ot-info.c
+++ b/pango/pango-ot-info.c
@@ -528,11 +528,11 @@ _pango_ot_info_position (const PangoOTInfo *info,
const PangoOTRuleset *ruleset,
PangoOTBuffer *buffer)
{
- unsigned int i;
+ unsigned int i, num_glyphs;
gboolean is_hinted;
hb_font_t *hb_font;
-
- hb_buffer_clear_positions (buffer->buffer);
+ hb_glyph_info_t *hb_glyph;
+ hb_glyph_position_t *hb_position;
/* XXX reuse hb_font */
hb_font = hb_font_create ();
@@ -544,6 +544,31 @@ _pango_ot_info_position (const PangoOTInfo *info,
is_hinted ? info->face->size->metrics.x_ppem : 0,
is_hinted ? info->face->size->metrics.y_ppem : 0);
+
+ /* Apply default positioning */
+ num_glyphs = hb_buffer_get_length (buffer->buffer);
+ hb_glyph = hb_buffer_get_glyph_infos (buffer->buffer);
+ hb_position = hb_buffer_get_glyph_positions (buffer->buffer);
+
+ hb_buffer_clear_positions (buffer->buffer);
+ for (i = 0; i < num_glyphs; i++)
+ {
+ if (hb_glyph->codepoint &&
+ (!buffer->zero_width_marks ||
+ hb_ot_layout_get_glyph_class (info->hb_face, hb_glyph->codepoint) != HB_OT_LAYOUT_GLYPH_CLASS_MARK))
+ {
+ PangoRectangle logical_rect;
+ pango_font_get_glyph_extents ((PangoFont *) buffer->font, hb_glyph->codepoint, NULL, &logical_rect);
+ hb_position->x_advance = PANGO_UNITS_TO_26_6 (logical_rect.width);
+ }
+ else
+ hb_position->x_advance = 0;
+
+ hb_glyph++;
+ hb_position++;
+ }
+
+
for (i = 0; i < ruleset->rules->len; i++)
{
PangoOTRule *rule = &g_array_index (ruleset->rules, PangoOTRule, i);
@@ -572,28 +597,8 @@ _pango_ot_info_position (const PangoOTInfo *info,
buffer->applied_gpos = TRUE;
}
- if (buffer->applied_gpos)
- {
- unsigned int i, j;
- unsigned int len = hb_buffer_get_len (buffer->buffer);
- hb_glyph_position_t *positions = hb_buffer_get_glyph_positions (buffer->buffer);
-
- /* First handle all left-to-right connections */
- for (j = 0; j < len; j++)
- {
- if (positions[j].cursive_chain > 0)
- positions[j].y_offset += positions[j - positions[j].cursive_chain].y_offset;
- }
-
- /* Then handle all right-to-left connections */
- for (i = len; i > 0; i--)
- {
- j = i - 1;
-
- if (positions[j].cursive_chain < 0)
- positions[j].y_offset += positions[j - positions[j].cursive_chain].y_offset;
- }
- }
+ if (buffer->applied_gpos)
+ hb_ot_layout_position_finish (info->hb_face, hb_font, buffer->buffer);
hb_font_destroy (hb_font);
}