Plumbing to get shape plan and font into complex decompose function
So we can handle Sinhala split matras smartly... Coming soon.
This commit is contained in:
parent
3f82f8ff07
commit
eba312c8d1
|
@ -83,8 +83,8 @@ normalization_preference_default (const hb_segment_properties_t *props)
|
||||||
return HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS;
|
return HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS;
|
||||||
}
|
}
|
||||||
|
|
||||||
static hb_bool_t
|
static bool
|
||||||
compose_default (hb_unicode_funcs_t *unicode,
|
compose_default (const hb_ot_shape_normalize_context_t *c,
|
||||||
hb_codepoint_t a,
|
hb_codepoint_t a,
|
||||||
hb_codepoint_t b,
|
hb_codepoint_t b,
|
||||||
hb_codepoint_t *ab)
|
hb_codepoint_t *ab)
|
||||||
|
@ -123,7 +123,7 @@ compose_default (hb_unicode_funcs_t *unicode,
|
||||||
0xFB4A // TAV
|
0xFB4A // TAV
|
||||||
};
|
};
|
||||||
|
|
||||||
hb_bool_t found = unicode->compose (a, b, ab);
|
bool found = c->unicode->compose (a, b, ab);
|
||||||
|
|
||||||
if (!found && (b & ~0x7F) == 0x0580) {
|
if (!found && (b & ~0x7F) == 0x0580) {
|
||||||
// special-case Hebrew presentation forms that are excluded from
|
// special-case Hebrew presentation forms that are excluded from
|
||||||
|
|
|
@ -1278,8 +1278,8 @@ normalization_preference_indic (const hb_segment_properties_t *props)
|
||||||
return HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT;
|
return HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS_NO_SHORT_CIRCUIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
static hb_bool_t
|
static bool
|
||||||
decompose_indic (hb_unicode_funcs_t *unicode,
|
decompose_indic (const hb_ot_shape_normalize_context_t *c,
|
||||||
hb_codepoint_t ab,
|
hb_codepoint_t ab,
|
||||||
hb_codepoint_t *a,
|
hb_codepoint_t *a,
|
||||||
hb_codepoint_t *b)
|
hb_codepoint_t *b)
|
||||||
|
@ -1328,23 +1328,23 @@ decompose_indic (hb_unicode_funcs_t *unicode,
|
||||||
case 0x0DDE : *a = 0x0DD9; *b= 0x0DDE; return true;
|
case 0x0DDE : *a = 0x0DD9; *b= 0x0DDE; return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return unicode->decompose (ab, a, b);
|
return c->unicode->decompose (ab, a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
static hb_bool_t
|
static bool
|
||||||
compose_indic (hb_unicode_funcs_t *unicode,
|
compose_indic (const hb_ot_shape_normalize_context_t *c,
|
||||||
hb_codepoint_t a,
|
hb_codepoint_t a,
|
||||||
hb_codepoint_t b,
|
hb_codepoint_t b,
|
||||||
hb_codepoint_t *ab)
|
hb_codepoint_t *ab)
|
||||||
{
|
{
|
||||||
/* Avoid recomposing split matras. */
|
/* Avoid recomposing split matras. */
|
||||||
if (HB_UNICODE_GENERAL_CATEGORY_IS_MARK (unicode->general_category (a)))
|
if (HB_UNICODE_GENERAL_CATEGORY_IS_MARK (c->unicode->general_category (a)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Composition-exclusion exceptions that we want to recompose. */
|
/* Composition-exclusion exceptions that we want to recompose. */
|
||||||
if (a == 0x09AF && b == 0x09BC) { *ab = 0x09DF; return true; }
|
if (a == 0x09AF && b == 0x09BC) { *ab = 0x09DF; return true; }
|
||||||
|
|
||||||
return unicode->compose (a, b, ab);
|
return c->unicode->compose (a, b, ab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ struct hb_ot_complex_shaper_t
|
||||||
* Called during shape()'s normalization.
|
* Called during shape()'s normalization.
|
||||||
* May be NULL.
|
* May be NULL.
|
||||||
*/
|
*/
|
||||||
hb_bool_t (*decompose) (hb_unicode_funcs_t *unicode,
|
bool (*decompose) (const hb_ot_shape_normalize_context_t *c,
|
||||||
hb_codepoint_t ab,
|
hb_codepoint_t ab,
|
||||||
hb_codepoint_t *a,
|
hb_codepoint_t *a,
|
||||||
hb_codepoint_t *b);
|
hb_codepoint_t *b);
|
||||||
|
@ -115,7 +115,7 @@ struct hb_ot_complex_shaper_t
|
||||||
* Called during shape()'s normalization.
|
* Called during shape()'s normalization.
|
||||||
* May be NULL.
|
* May be NULL.
|
||||||
*/
|
*/
|
||||||
hb_bool_t (*compose) (hb_unicode_funcs_t *unicode,
|
bool (*compose) (const hb_ot_shape_normalize_context_t *c,
|
||||||
hb_codepoint_t a,
|
hb_codepoint_t a,
|
||||||
hb_codepoint_t b,
|
hb_codepoint_t b,
|
||||||
hb_codepoint_t *ab);
|
hb_codepoint_t *ab);
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
/* buffer var allocations, used during the normalization process */
|
/* buffer var allocations, used during the normalization process */
|
||||||
#define glyph_index() var1.u32
|
#define glyph_index() var1.u32
|
||||||
|
|
||||||
struct hb_ot_complex_shaper_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_DECOMPOSED,
|
HB_OT_SHAPE_NORMALIZATION_MODE_DECOMPOSED,
|
||||||
|
@ -46,8 +46,26 @@ enum hb_ot_shape_normalization_mode_t {
|
||||||
HB_OT_SHAPE_NORMALIZATION_MODE_DEFAULT = HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS
|
HB_OT_SHAPE_NORMALIZATION_MODE_DEFAULT = HB_OT_SHAPE_NORMALIZATION_MODE_COMPOSED_DIACRITICS
|
||||||
};
|
};
|
||||||
|
|
||||||
HB_INTERNAL void _hb_ot_shape_normalize (const hb_ot_complex_shaper_t *shaper,
|
HB_INTERNAL void _hb_ot_shape_normalize (const hb_ot_shape_plan_t *shaper,
|
||||||
hb_buffer_t *buffer,
|
hb_buffer_t *buffer,
|
||||||
hb_font_t *font);
|
hb_font_t *font);
|
||||||
|
|
||||||
|
|
||||||
|
struct hb_ot_shape_normalize_context_t
|
||||||
|
{
|
||||||
|
const hb_ot_shape_plan_t *plan;
|
||||||
|
hb_buffer_t *buffer;
|
||||||
|
hb_font_t *font;
|
||||||
|
hb_unicode_funcs_t *unicode;
|
||||||
|
bool (*decompose) (const hb_ot_shape_normalize_context_t *c,
|
||||||
|
hb_codepoint_t ab,
|
||||||
|
hb_codepoint_t *a,
|
||||||
|
hb_codepoint_t *b);
|
||||||
|
bool (*compose) (const hb_ot_shape_normalize_context_t *c,
|
||||||
|
hb_codepoint_t a,
|
||||||
|
hb_codepoint_t b,
|
||||||
|
hb_codepoint_t *ab);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* HB_OT_SHAPE_NORMALIZE_PRIVATE_HH */
|
#endif /* HB_OT_SHAPE_NORMALIZE_PRIVATE_HH */
|
||||||
|
|
|
@ -82,22 +82,22 @@
|
||||||
* egrep "`echo -n ';('; grep ';<' UnicodeData.txt | cut -d';' -f1 | tr '\n' '|'; echo ') '`" UnicodeData.txt
|
* egrep "`echo -n ';('; grep ';<' UnicodeData.txt | cut -d';' -f1 | tr '\n' '|'; echo ') '`" UnicodeData.txt
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static hb_bool_t
|
static bool
|
||||||
decompose_unicode (hb_unicode_funcs_t *unicode,
|
decompose_unicode (const hb_ot_shape_normalize_context_t *c,
|
||||||
hb_codepoint_t ab,
|
hb_codepoint_t ab,
|
||||||
hb_codepoint_t *a,
|
hb_codepoint_t *a,
|
||||||
hb_codepoint_t *b)
|
hb_codepoint_t *b)
|
||||||
{
|
{
|
||||||
return unicode->decompose (ab, a, b);
|
return c->unicode->decompose (ab, a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
static hb_bool_t
|
static bool
|
||||||
compose_unicode (hb_unicode_funcs_t *unicode,
|
compose_unicode (const hb_ot_shape_normalize_context_t *c,
|
||||||
hb_codepoint_t a,
|
hb_codepoint_t a,
|
||||||
hb_codepoint_t b,
|
hb_codepoint_t b,
|
||||||
hb_codepoint_t *ab)
|
hb_codepoint_t *ab)
|
||||||
{
|
{
|
||||||
return unicode->compose (a, b, ab);
|
return c->unicode->compose (a, b, ab);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
@ -127,27 +127,13 @@ skip_char (hb_buffer_t *buffer)
|
||||||
buffer->skip_glyph ();
|
buffer->skip_glyph ();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct normalize_context_t
|
|
||||||
{
|
|
||||||
hb_buffer_t *buffer;
|
|
||||||
hb_font_t *font;
|
|
||||||
hb_bool_t (*decompose) (hb_unicode_funcs_t *unicode,
|
|
||||||
hb_codepoint_t ab,
|
|
||||||
hb_codepoint_t *a,
|
|
||||||
hb_codepoint_t *b);
|
|
||||||
hb_bool_t (*compose) (hb_unicode_funcs_t *unicode,
|
|
||||||
hb_codepoint_t a,
|
|
||||||
hb_codepoint_t b,
|
|
||||||
hb_codepoint_t *ab);
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Returns 0 if didn't decompose, number of resulting characters otherwise. */
|
/* Returns 0 if didn't decompose, number of resulting characters otherwise. */
|
||||||
static inline unsigned int
|
static inline unsigned int
|
||||||
decompose (const normalize_context_t *c, bool shortest, hb_codepoint_t ab)
|
decompose (const hb_ot_shape_normalize_context_t *c, bool shortest, hb_codepoint_t ab)
|
||||||
{
|
{
|
||||||
hb_codepoint_t a, b, a_glyph, b_glyph;
|
hb_codepoint_t a, b, a_glyph, b_glyph;
|
||||||
|
|
||||||
if (!c->decompose (c->buffer->unicode, ab, &a, &b) ||
|
if (!c->decompose (c, ab, &a, &b) ||
|
||||||
(b && !c->font->get_glyph (b, 0, &b_glyph)))
|
(b && !c->font->get_glyph (b, 0, &b_glyph)))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -185,7 +171,7 @@ decompose (const normalize_context_t *c, bool shortest, hb_codepoint_t ab)
|
||||||
|
|
||||||
/* Returns 0 if didn't decompose, number of resulting characters otherwise. */
|
/* Returns 0 if didn't decompose, number of resulting characters otherwise. */
|
||||||
static inline bool
|
static inline bool
|
||||||
decompose_compatibility (const normalize_context_t *c, hb_codepoint_t u)
|
decompose_compatibility (const hb_ot_shape_normalize_context_t *c, hb_codepoint_t u)
|
||||||
{
|
{
|
||||||
unsigned int len, i;
|
unsigned int len, i;
|
||||||
hb_codepoint_t decomposed[HB_UNICODE_MAX_DECOMPOSITION_LEN];
|
hb_codepoint_t decomposed[HB_UNICODE_MAX_DECOMPOSITION_LEN];
|
||||||
|
@ -207,7 +193,7 @@ decompose_compatibility (const normalize_context_t *c, hb_codepoint_t u)
|
||||||
|
|
||||||
/* Returns true if recomposition may be benefitial. */
|
/* Returns true if recomposition may be benefitial. */
|
||||||
static inline bool
|
static inline bool
|
||||||
decompose_current_character (const normalize_context_t *c, bool shortest)
|
decompose_current_character (const hb_ot_shape_normalize_context_t *c, bool shortest)
|
||||||
{
|
{
|
||||||
hb_buffer_t * const buffer = c->buffer;
|
hb_buffer_t * const buffer = c->buffer;
|
||||||
hb_codepoint_t glyph;
|
hb_codepoint_t glyph;
|
||||||
|
@ -233,7 +219,7 @@ decompose_current_character (const normalize_context_t *c, bool shortest)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
handle_variation_selector_cluster (const normalize_context_t *c, unsigned int end)
|
handle_variation_selector_cluster (const hb_ot_shape_normalize_context_t *c, unsigned int end)
|
||||||
{
|
{
|
||||||
hb_buffer_t * const buffer = c->buffer;
|
hb_buffer_t * const buffer = c->buffer;
|
||||||
for (; buffer->idx < end - 1;) {
|
for (; buffer->idx < end - 1;) {
|
||||||
|
@ -254,7 +240,7 @@ handle_variation_selector_cluster (const normalize_context_t *c, unsigned int en
|
||||||
|
|
||||||
/* Returns true if recomposition may be benefitial. */
|
/* Returns true if recomposition may be benefitial. */
|
||||||
static inline bool
|
static inline bool
|
||||||
decompose_multi_char_cluster (const normalize_context_t *c, unsigned int end)
|
decompose_multi_char_cluster (const hb_ot_shape_normalize_context_t *c, unsigned int end)
|
||||||
{
|
{
|
||||||
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. */
|
/* TODO Currently if there's a variation-selector we give-up, it's just too hard. */
|
||||||
|
@ -272,7 +258,7 @@ decompose_multi_char_cluster (const normalize_context_t *c, unsigned int end)
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline bool
|
static inline bool
|
||||||
decompose_cluster (const normalize_context_t *c, bool short_circuit, unsigned int end)
|
decompose_cluster (const hb_ot_shape_normalize_context_t *c, bool short_circuit, unsigned int end)
|
||||||
{
|
{
|
||||||
if (likely (c->buffer->idx + 1 == end))
|
if (likely (c->buffer->idx + 1 == end))
|
||||||
return decompose_current_character (c, short_circuit);
|
return decompose_current_character (c, short_circuit);
|
||||||
|
@ -292,18 +278,20 @@ compare_combining_class (const hb_glyph_info_t *pa, const hb_glyph_info_t *pb)
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
_hb_ot_shape_normalize (const hb_ot_complex_shaper_t *shaper,
|
_hb_ot_shape_normalize (const hb_ot_shape_plan_t *plan,
|
||||||
hb_buffer_t *buffer,
|
hb_buffer_t *buffer,
|
||||||
hb_font_t *font)
|
hb_font_t *font)
|
||||||
{
|
{
|
||||||
hb_ot_shape_normalization_mode_t mode = shaper->normalization_preference ?
|
hb_ot_shape_normalization_mode_t mode = plan->shaper->normalization_preference ?
|
||||||
shaper->normalization_preference (&buffer->props) :
|
plan->shaper->normalization_preference (&buffer->props) :
|
||||||
HB_OT_SHAPE_NORMALIZATION_MODE_DEFAULT;
|
HB_OT_SHAPE_NORMALIZATION_MODE_DEFAULT;
|
||||||
const normalize_context_t c = {
|
const hb_ot_shape_normalize_context_t c = {
|
||||||
|
plan,
|
||||||
buffer,
|
buffer,
|
||||||
font,
|
font,
|
||||||
shaper->decompose ? shaper->decompose : decompose_unicode,
|
buffer->unicode,
|
||||||
shaper->compose ? shaper->compose : compose_unicode
|
plan->shaper->decompose ? plan->shaper->decompose : decompose_unicode,
|
||||||
|
plan->shaper->compose ? plan->shaper->compose : compose_unicode
|
||||||
};
|
};
|
||||||
|
|
||||||
bool short_circuit = mode != HB_OT_SHAPE_NORMALIZATION_MODE_DECOMPOSED &&
|
bool short_circuit = mode != HB_OT_SHAPE_NORMALIZATION_MODE_DECOMPOSED &&
|
||||||
|
@ -389,7 +377,7 @@ _hb_ot_shape_normalize (const hb_ot_complex_shaper_t *shaper,
|
||||||
(starter == buffer->out_len - 1 ||
|
(starter == buffer->out_len - 1 ||
|
||||||
_hb_glyph_info_get_modified_combining_class (&buffer->prev()) < _hb_glyph_info_get_modified_combining_class (&buffer->cur())) &&
|
_hb_glyph_info_get_modified_combining_class (&buffer->prev()) < _hb_glyph_info_get_modified_combining_class (&buffer->cur())) &&
|
||||||
/* And compose. */
|
/* And compose. */
|
||||||
c.compose (buffer->unicode,
|
c.compose (&c,
|
||||||
buffer->out_info[starter].codepoint,
|
buffer->out_info[starter].codepoint,
|
||||||
buffer->cur().codepoint,
|
buffer->cur().codepoint,
|
||||||
&composed) &&
|
&composed) &&
|
||||||
|
|
|
@ -362,7 +362,7 @@ hb_ot_substitute_default (hb_ot_shape_context_t *c)
|
||||||
|
|
||||||
HB_BUFFER_ALLOCATE_VAR (c->buffer, glyph_index);
|
HB_BUFFER_ALLOCATE_VAR (c->buffer, glyph_index);
|
||||||
|
|
||||||
_hb_ot_shape_normalize (c->plan->shaper, c->buffer, c->font);
|
_hb_ot_shape_normalize (c->plan, c->buffer, c->font);
|
||||||
|
|
||||||
hb_ot_shape_setup_masks (c);
|
hb_ot_shape_setup_masks (c);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue