*glyphs = (PangoOTGlyph *) hb_buffer_get_glyph_infos (buffer->buffer);
if (n_glyphs)
- *n_glyphs = hb_buffer_get_len (buffer->buffer);
-}
-
-static void
-apply_gpos_ltr (PangoGlyphString *glyphs,
- hb_glyph_position_t *positions,
- gboolean scale,
- double xscale,
- double yscale,
- gboolean is_hinted)
-{
- int i;
-
- for (i = 0; i < glyphs->num_glyphs; i++)
- {
- FT_Pos x_pos = positions[i].x_pos;
- FT_Pos y_pos = positions[i].y_pos;
- int back = i;
- int j;
- int adjustment;
-
-
- adjustment = PANGO_UNITS_26_6(positions[i].x_advance);
-
- if (is_hinted)
- adjustment = PANGO_UNITS_ROUND (adjustment);
- if (G_UNLIKELY (scale))
- adjustment *= xscale;
-
- if (positions[i].new_advance)
- glyphs->glyphs[i].geometry.width = adjustment;
- else
- glyphs->glyphs[i].geometry.width += adjustment;
-
-
- while (positions[back].back != 0)
- {
- back -= positions[back].back;
- x_pos += positions[back].x_pos;
- y_pos += positions[back].y_pos;
- }
-
- for (j = back; j < i; j++)
- glyphs->glyphs[i].geometry.x_offset -= glyphs->glyphs[j].geometry.width;
-
- if (G_UNLIKELY (scale))
- {
- glyphs->glyphs[i].geometry.x_offset += xscale * PANGO_UNITS_26_6(x_pos);
- glyphs->glyphs[i].geometry.y_offset -= yscale * PANGO_UNITS_26_6(y_pos);
- }
- else
- {
- glyphs->glyphs[i].geometry.x_offset += PANGO_UNITS_26_6(x_pos);
- glyphs->glyphs[i].geometry.y_offset -= PANGO_UNITS_26_6(y_pos);
- }
- }
-}
-
-static void
-apply_gpos_rtl (PangoGlyphString *glyphs,
- hb_glyph_position_t *positions,
- gboolean scale,
- double xscale,
- double yscale,
- gboolean is_hinted)
-{
- int i;
-
- for (i = 0; i < glyphs->num_glyphs; i++)
- {
- int i_rev = glyphs->num_glyphs - i - 1;
- int back_rev = i_rev;
- int back;
- FT_Pos x_pos = positions[i_rev].x_pos;
- FT_Pos y_pos = positions[i_rev].y_pos;
- int j;
- int adjustment;
-
-
- adjustment = PANGO_UNITS_26_6(positions[i_rev].x_advance);
-
- if (is_hinted)
- adjustment = PANGO_UNITS_ROUND (adjustment);
- if (G_UNLIKELY (scale))
- adjustment *= xscale;
-
- if (positions[i_rev].new_advance)
- glyphs->glyphs[i].geometry.width = adjustment;
- else
- glyphs->glyphs[i].geometry.width += adjustment;
-
-
- while (positions[back_rev].back != 0)
- {
- back_rev -= positions[back_rev].back;
- x_pos += positions[back_rev].x_pos;
- y_pos += positions[back_rev].y_pos;
- }
-
- back = glyphs->num_glyphs - back_rev - 1;
-
- for (j = i; j < back; j++)
- glyphs->glyphs[i].geometry.x_offset += glyphs->glyphs[j].geometry.width;
-
- if (G_UNLIKELY (scale))
- {
- glyphs->glyphs[i].geometry.x_offset += xscale * PANGO_UNITS_26_6(x_pos);
- glyphs->glyphs[i].geometry.y_offset -= yscale * PANGO_UNITS_26_6(y_pos);
- }
- else
- {
- glyphs->glyphs[i].geometry.x_offset += PANGO_UNITS_26_6(x_pos);
- glyphs->glyphs[i].geometry.y_offset -= PANGO_UNITS_26_6(y_pos);
- }
- }
+ *n_glyphs = hb_buffer_get_length (buffer->buffer);
}
- static void
- swap_range (PangoGlyphString *glyphs, int start, int end)
- {
- int i, j;
-
- for (i = start, j = end - 1; i < j; i++, j--)
- {
- PangoGlyphInfo glyph_info;
- gint log_cluster;
-
- glyph_info = glyphs->glyphs[i];
- glyphs->glyphs[i] = glyphs->glyphs[j];
- glyphs->glyphs[j] = glyph_info;
-
- log_cluster = glyphs->log_clusters[i];
- glyphs->log_clusters[i] = glyphs->log_clusters[j];
- glyphs->log_clusters[j] = log_cluster;
- }
- }
-
/**
* pango_ot_buffer_output
* @buffer: a #PangoOTBuffer
}
if (buffer->rtl)
- swap_range (glyphs, 0, glyphs->num_glyphs);
- {
- /* Swap all glyphs */
- pango_glyph_string_reverse_range (glyphs, 0, glyphs->num_glyphs);
- }
-
- positions = hb_buffer_get_glyph_positions (buffer->buffer);
- if (buffer->applied_gpos)
- {
- gboolean scale = FALSE;
- double xscale = 1, yscale = 1;
- PangoFcFontKey *key = _pango_fc_font_get_font_key (buffer->font);
-
- /* This is a kludge, and dupped in pango_fc_font_kern_glyphs().
- * Should move the scale factor to PangoFcFont layer. */
- if (key) {
- const PangoMatrix *matrix = pango_fc_font_key_get_matrix (key);
- PangoMatrix identity = PANGO_MATRIX_INIT;
- if (G_UNLIKELY (matrix && 0 != memcmp (&identity, matrix, 4 * sizeof (double))))
- {
- scale = TRUE;
- pango_matrix_get_font_scale_factors (matrix, &xscale, &yscale);
- if (xscale) xscale = 1 / xscale;
- if (yscale) yscale = 1 / yscale;
- }
- }
-
- if (buffer->rtl)
- apply_gpos_rtl (glyphs, positions, scale, xscale, yscale, buffer->font->is_hinted);
- else
- apply_gpos_ltr (glyphs, positions, scale, xscale, yscale, buffer->font->is_hinted);
- }
- else
- {
- /* FIXME we should only do this if the 'kern' feature was requested */
- pango_fc_font_kern_glyphs (buffer->font, glyphs);
- }
-
- pango_fc_font_unlock_face (buffer->font);
++ pango_glyph_string_reverse_range (glyphs, 0, glyphs->num_glyphs);
+ if (!buffer->applied_gpos)
+ pango_fc_font_kern_glyphs (buffer->font, glyphs);
}