In Arabic fallback shaping, check that the font has glyph for new char

This commit is contained in:
Behdad Esfahbod 2012-04-10 18:02:20 -04:00
parent 7752aa73e7
commit acd88e659f
5 changed files with 16 additions and 13 deletions

View File

@ -205,20 +205,22 @@ _hb_ot_shape_complex_normalization_preference_arabic (void)
static void
arabic_fallback_shape (hb_buffer_t *buffer)
arabic_fallback_shape (hb_font_t *font, hb_buffer_t *buffer)
{
unsigned int count = buffer->len;
hb_codepoint_t glyph;
/* Shape to presentation forms */
for (unsigned int i = 0; i < count; i++)
buffer->info[i].codepoint = get_arabic_shape (buffer->info[i].codepoint, buffer->info[i].arabic_shaping_action());
if (hb_font_get_glyph (font, buffer->info[i].codepoint, 0, &glyph))
buffer->info[i].codepoint = get_arabic_shape (buffer->info[i].codepoint, buffer->info[i].arabic_shaping_action());
/* Mandatory ligatures */
buffer->clear_output ();
for (buffer->idx = 0; buffer->idx + 1 < count;) {
uint16_t ligature = get_ligature (buffer->info[buffer->idx].codepoint,
buffer->info[buffer->idx + 1].codepoint);
if (likely (!ligature)) {
if (likely (!ligature) || !(hb_font_get_glyph (font, ligature, 0, &glyph))) {
buffer->next_glyph ();
continue;
}
@ -234,7 +236,7 @@ arabic_fallback_shape (hb_buffer_t *buffer)
}
void
_hb_ot_shape_complex_setup_masks_arabic (hb_ot_map_t *map, hb_buffer_t *buffer)
_hb_ot_shape_complex_setup_masks_arabic (hb_ot_map_t *map, hb_buffer_t *buffer, hb_font_t *font)
{
unsigned int count = buffer->len;
unsigned int prev = 0, state = 0;
@ -281,7 +283,7 @@ _hb_ot_shape_complex_setup_masks_arabic (hb_ot_map_t *map, hb_buffer_t *buffer)
* Most probably it's safe to assume that init/medi/fina/isol
* still mean Arabic shaping, although they do not have to.
*/
arabic_fallback_shape (buffer);
arabic_fallback_shape (font, buffer);
}
HB_BUFFER_DEALLOCATE_VAR (buffer, arabic_shaping_action);

View File

@ -378,7 +378,7 @@ _hb_ot_shape_complex_normalization_preference_indic (void)
void
_hb_ot_shape_complex_setup_masks_indic (hb_ot_map_t *map, hb_buffer_t *buffer)
_hb_ot_shape_complex_setup_masks_indic (hb_ot_map_t *map, hb_buffer_t *buffer, hb_font_t *font)
{
HB_BUFFER_ALLOCATE_VAR (buffer, indic_category);
HB_BUFFER_ALLOCATE_VAR (buffer, indic_position);

View File

@ -48,7 +48,7 @@ _hb_ot_shape_complex_normalization_preference_default (void)
}
void
_hb_ot_shape_complex_setup_masks_default (hb_ot_map_t *map, hb_buffer_t *buffer)
_hb_ot_shape_complex_setup_masks_default (hb_ot_map_t *map, hb_buffer_t *buffer, hb_font_t *font)
{
}
@ -68,7 +68,7 @@ _hb_ot_shape_complex_normalization_preference_hangul (void)
}
void
_hb_ot_shape_complex_setup_masks_hangul (hb_ot_map_t *map, hb_buffer_t *buffer)
_hb_ot_shape_complex_setup_masks_hangul (hb_ot_map_t *map, hb_buffer_t *buffer, hb_font_t *font)
{
}
@ -88,7 +88,7 @@ _hb_ot_shape_complex_normalization_preference_thai (void)
}
void
_hb_ot_shape_complex_setup_masks_thai (hb_ot_map_t *map, hb_buffer_t *buffer)
_hb_ot_shape_complex_setup_masks_thai (hb_ot_map_t *map, hb_buffer_t *buffer, hb_font_t *font)
{
/* The following is NOT specified in the MS OT Thai spec, however, it seems
* to be what Uniscribe and other engines implement. According to Eric Muller:

View File

@ -280,7 +280,7 @@ hb_ot_shape_complex_normalization_preference (hb_ot_complex_shaper_t shaper)
* Shapers should use map to get feature masks and set on buffer.
*/
typedef void hb_ot_shape_complex_setup_masks_func_t (hb_ot_map_t *map, hb_buffer_t *buffer);
typedef void hb_ot_shape_complex_setup_masks_func_t (hb_ot_map_t *map, hb_buffer_t *buffer, hb_font_t *font);
#define HB_COMPLEX_SHAPER_IMPLEMENT(name) \
HB_INTERNAL hb_ot_shape_complex_setup_masks_func_t _hb_ot_shape_complex_setup_masks_##name;
HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS
@ -289,12 +289,13 @@ typedef void hb_ot_shape_complex_setup_masks_func_t (hb_ot_map_t *map, hb_buffer
static inline void
hb_ot_shape_complex_setup_masks (hb_ot_complex_shaper_t shaper,
hb_ot_map_t *map,
hb_buffer_t *buffer)
hb_buffer_t *buffer,
hb_font_t *font)
{
switch (shaper) {
default:
#define HB_COMPLEX_SHAPER_IMPLEMENT(name) \
case hb_ot_complex_shaper_##name: _hb_ot_shape_complex_setup_masks_##name (map, buffer); return;
case hb_ot_complex_shaper_##name: _hb_ot_shape_complex_setup_masks_##name (map, buffer, font); return;
HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS
#undef HB_COMPLEX_SHAPER_IMPLEMENT
}

View File

@ -114,7 +114,7 @@ hb_ot_shape_setup_masks (hb_ot_shape_context_t *c)
hb_mask_t global_mask = c->plan->map.get_global_mask ();
c->buffer->reset_masks (global_mask);
hb_ot_shape_complex_setup_masks (c->plan->shaper, &c->plan->map, c->buffer);
hb_ot_shape_complex_setup_masks (c->plan->shaper, &c->plan->map, c->buffer, c->font);
for (unsigned int i = 0; i < c->num_user_features; i++)
{