[ot/hangul] Don't decompose Hangul even when combining marks present
As discussed on https://github.com/behdad/harfbuzz/pull/10#issuecomment-31442030
This commit is contained in:
parent
64426ec73a
commit
8fc1f7fe74
|
@ -218,7 +218,7 @@ const hb_ot_complex_shaper_t _hb_ot_complex_shaper_hangul =
|
||||||
NULL, /* data_create */
|
NULL, /* data_create */
|
||||||
NULL, /* data_destroy */
|
NULL, /* data_destroy */
|
||||||
preprocess_text_hangul,
|
preprocess_text_hangul,
|
||||||
HB_OT_SHAPE_NORMALIZATION_MODE_DEFAULT,
|
HB_OT_SHAPE_NORMALIZATION_MODE_NONE,
|
||||||
NULL, /* decompose */
|
NULL, /* decompose */
|
||||||
NULL, /* compose */
|
NULL, /* compose */
|
||||||
NULL, /* setup_masks */
|
NULL, /* setup_masks */
|
||||||
|
|
|
@ -36,6 +36,7 @@
|
||||||
struct hb_ot_shape_plan_t;
|
struct hb_ot_shape_plan_t;
|
||||||
|
|
||||||
enum hb_ot_shape_normalization_mode_t {
|
enum hb_ot_shape_normalization_mode_t {
|
||||||
|
HB_OT_SHAPE_NORMALIZATION_MODE_NONE,
|
||||||
HB_OT_SHAPE_NORMALIZATION_MODE_DECOMPOSED,
|
HB_OT_SHAPE_NORMALIZATION_MODE_DECOMPOSED,
|
||||||
HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS, /* never composes base-to-base */
|
HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS, /* never composes base-to-base */
|
||||||
HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT, /* always fully decomposes and then recompose back */
|
HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT, /* always fully decomposes and then recompose back */
|
||||||
|
|
|
@ -213,8 +213,9 @@ decompose_current_character (const hb_ot_shape_normalize_context_t *c, bool shor
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
handle_variation_selector_cluster (const hb_ot_shape_normalize_context_t *c, unsigned int end)
|
handle_variation_selector_cluster (const hb_ot_shape_normalize_context_t *c, unsigned int end, bool short_circuit)
|
||||||
{
|
{
|
||||||
|
/* TODO Currently if there's a variation-selector we give-up, it's just too hard. */
|
||||||
hb_buffer_t * const buffer = c->buffer;
|
hb_buffer_t * const buffer = c->buffer;
|
||||||
hb_font_t * const font = c->font;
|
hb_font_t * const font = c->font;
|
||||||
for (; buffer->idx < end - 1;) {
|
for (; buffer->idx < end - 1;) {
|
||||||
|
@ -250,27 +251,26 @@ handle_variation_selector_cluster (const hb_ot_shape_normalize_context_t *c, uns
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
decompose_multi_char_cluster (const hb_ot_shape_normalize_context_t *c, unsigned int end)
|
decompose_multi_char_cluster (const hb_ot_shape_normalize_context_t *c, unsigned int end, bool short_circuit)
|
||||||
{
|
{
|
||||||
hb_buffer_t * const buffer = c->buffer;
|
hb_buffer_t * const buffer = c->buffer;
|
||||||
/* TODO Currently if there's a variation-selector we give-up, it's just too hard. */
|
|
||||||
for (unsigned int i = buffer->idx; i < end; i++)
|
for (unsigned int i = buffer->idx; i < end; i++)
|
||||||
if (unlikely (buffer->unicode->is_variation_selector (buffer->info[i].codepoint))) {
|
if (unlikely (buffer->unicode->is_variation_selector (buffer->info[i].codepoint))) {
|
||||||
handle_variation_selector_cluster (c, end);
|
handle_variation_selector_cluster (c, end, short_circuit);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (buffer->idx < end)
|
while (buffer->idx < end)
|
||||||
decompose_current_character (c, false);
|
decompose_current_character (c, short_circuit);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
decompose_cluster (const hb_ot_shape_normalize_context_t *c, bool short_circuit, unsigned int end)
|
decompose_cluster (const hb_ot_shape_normalize_context_t *c, unsigned int end, bool might_short_circuit, bool always_short_circuit)
|
||||||
{
|
{
|
||||||
if (likely (c->buffer->idx + 1 == end))
|
if (likely (c->buffer->idx + 1 == end))
|
||||||
decompose_current_character (c, short_circuit);
|
decompose_current_character (c, might_short_circuit);
|
||||||
else
|
else
|
||||||
decompose_multi_char_cluster (c, end);
|
decompose_multi_char_cluster (c, end, always_short_circuit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -299,8 +299,10 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan,
|
||||||
plan->shaper->compose ? plan->shaper->compose : compose_unicode
|
plan->shaper->compose ? plan->shaper->compose : compose_unicode
|
||||||
};
|
};
|
||||||
|
|
||||||
bool short_circuit = mode != HB_OT_SHAPE_NORMALIZATION_MODE_DECOMPOSED &&
|
bool always_short_circuit = mode == HB_OT_SHAPE_NORMALIZATION_MODE_NONE;
|
||||||
mode != HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT;
|
bool might_short_circuit = always_short_circuit ||
|
||||||
|
(mode != HB_OT_SHAPE_NORMALIZATION_MODE_DECOMPOSED &&
|
||||||
|
mode != HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT);
|
||||||
unsigned int count;
|
unsigned int count;
|
||||||
|
|
||||||
/* We do a fairly straightforward yet custom normalization process in three
|
/* We do a fairly straightforward yet custom normalization process in three
|
||||||
|
@ -321,7 +323,7 @@ _hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan,
|
||||||
if (buffer->cur().cluster != buffer->info[end].cluster)
|
if (buffer->cur().cluster != buffer->info[end].cluster)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
decompose_cluster (&c, short_circuit, end);
|
decompose_cluster (&c, end, might_short_circuit, always_short_circuit);
|
||||||
}
|
}
|
||||||
buffer->swap_buffers ();
|
buffer->swap_buffers ();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue