Skip to content

Commit

Permalink
bug 758236 - force non-spacing marks to have zero width (merged forwa…
Browse files Browse the repository at this point in the history
…rd from bug 727736). r=jdaggett
  • Loading branch information
jfkthame committed Apr 21, 2012
1 parent 1b4e759 commit fcabd5f
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 5 deletions.
30 changes: 28 additions & 2 deletions gfx/harfbuzz/src/hb-ot-layout.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -506,8 +507,33 @@ 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;
const hb_glyph_info_t *info = buffer->info;
hb_glyph_position_t *positions = buffer->pos;
/*
* Forcibly zero widths of chars with GC=Mn; we don't use the GDEF 'Mark' class
* because some fonts (e.g. C-DAC Yogesh) classify spacing Indic matras as 'Mark'
* but we don't want to force their width to zero.
*/
if (buffer->props.direction == HB_DIRECTION_RTL) {
for (unsigned int i = 1; i < count; i++) {
if (_hb_glyph_info_get_general_category (&info[i]) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK) {
positions[i].x_advance = 0;
}
}
} else {
for (unsigned int i = 1; i < count; i++) {
if (_hb_glyph_info_get_general_category (&info[i]) == HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK) {
hb_glyph_position_t& pos = positions[i];
pos.x_offset -= pos.x_advance;
pos.x_advance = 0;
}
}
}

GPOS::position_finish (buffer);
}

Expand Down
2 changes: 1 addition & 1 deletion gfx/harfbuzz/src/hb-ot-layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,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
Expand Down
27 changes: 25 additions & 2 deletions gfx/harfbuzz/src/hb-ot-shape.cc
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,38 @@ 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;
const hb_glyph_info_t *info = c->buffer->info;
hb_glyph_position_t *positions = c->buffer->pos;
if (c->buffer->props.direction == HB_DIRECTION_RTL) {
for (unsigned int i = 1; i < count; i++) {
if (FLAG (_hb_glyph_info_get_general_category (&info[i])) &
(FLAG (HB_UNICODE_GENERAL_CATEGORY_FORMAT) |
FLAG (HB_UNICODE_GENERAL_CATEGORY_ENCLOSING_MARK) |
FLAG (HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK)))
positions[i].x_advance = 0;
}
} else {
for (unsigned int i = 1; i < count; i++) {
if (FLAG (_hb_glyph_info_get_general_category (&info[i])) &
(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 = positions[i];
pos.x_offset = -pos.x_advance;
pos.x_advance = 0;
}
}
}
}

static void
Expand Down

0 comments on commit fcabd5f

Please sign in to comment.