bug 745780 - re-apply patch from bug 727736 after harfbuzz update. r=jdaggett a=mfinkle

This commit is contained in:
Jonathan Kew 2012-04-21 22:25:03 +01:00
parent 47286126f0
commit 8a87c0d01d
3 changed files with 64 additions and 4 deletions

View File

@ -32,6 +32,7 @@
#include "hb-ot-layout-gsub-table.hh"
#include "hb-ot-layout-gpos-table.hh"
#include "hb-ot-maxp-table.hh"
#include "hb-ot-shape-private.hh"
#include <stdlib.h>
@ -496,8 +497,46 @@ hb_ot_layout_position_lookup (hb_font_t *font,
}
void
hb_ot_layout_position_finish (hb_buffer_t *buffer)
hb_ot_layout_position_finish (hb_face_t *face, hb_buffer_t *buffer)
{
/* force diacritics to have zero width */
unsigned int count = buffer->len;
if (hb_ot_layout_has_glyph_classes (face)) {
const GDEF& gdef = _get_gdef (face);
if (buffer->props.direction == HB_DIRECTION_RTL) {
for (unsigned int i = 1; i < count; i++) {
if (gdef.get_glyph_class (buffer->info[i].codepoint) == GDEF::MarkGlyph) {
buffer->pos[i].x_advance = 0;
}
}
} else {
for (unsigned int i = 1; i < count; i++) {
if (gdef.get_glyph_class (buffer->info[i].codepoint) == GDEF::MarkGlyph) {
hb_glyph_position_t& pos = buffer->pos[i];
pos.x_offset -= pos.x_advance;
pos.x_advance = 0;
}
}
}
} else {
/* no GDEF classes available, so use General Category as a fallback */
if (buffer->props.direction == HB_DIRECTION_RTL) {
for (unsigned int i = 1; i < count; i++) {
if (buffer->info[i].general_category() == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK) {
buffer->pos[i].x_advance = 0;
}
}
} else {
for (unsigned int i = 1; i < count; i++) {
if (buffer->info[i].general_category() == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK) {
hb_glyph_position_t& pos = buffer->pos[i];
pos.x_offset -= pos.x_advance;
pos.x_advance = 0;
}
}
}
}
GPOS::position_finish (buffer);
}

View File

@ -201,7 +201,7 @@ hb_ot_layout_position_lookup (hb_font_t *font,
/* Should be called after all the position_lookup's are done */
void
hb_ot_layout_position_finish (hb_buffer_t *buffer);
hb_ot_layout_position_finish (hb_face_t *face, hb_buffer_t *buffer);
HB_END_DECLS

View File

@ -336,15 +336,36 @@ hb_ot_position_complex (hb_ot_shape_context_t *c)
c->applied_position_complex = TRUE;
}
hb_ot_layout_position_finish (c->buffer);
hb_ot_layout_position_finish (c->face, c->buffer);
return;
}
static void
hb_position_complex_fallback (hb_ot_shape_context_t *c HB_UNUSED)
hb_position_complex_fallback (hb_ot_shape_context_t *c)
{
/* TODO Mark pos */
unsigned int count = c->buffer->len;
if (c->buffer->props.direction == HB_DIRECTION_RTL) {
for (unsigned int i = 1; i < count; i++) {
if (FLAG (c->buffer->info[i].general_category()) &
(FLAG (HB_UNICODE_GENERAL_CATEGORY_FORMAT) |
FLAG (HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK) |
FLAG (HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)))
c->buffer->pos[i].x_advance = 0;
}
} else {
for (unsigned int i = 1; i < count; i++) {
if (FLAG (c->buffer->info[i].general_category()) &
(FLAG (HB_UNICODE_GENERAL_CATEGORY_FORMAT) |
FLAG (HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK) |
FLAG (HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK))) {
hb_glyph_position_t& pos = c->buffer->pos[i];
pos.x_offset = -pos.x_advance;
pos.x_advance = 0;
}
}
}
}
static void