提交 afbcc24b 编写于 作者: B Behdad Esfahbod

[GSUB] Wire the font, not just the face, down to substitute()

We need the font for glyph lookup during GSUB pauses in Indic shaper.
Could perhaps be avoided, but at this point, we don't mean to support
separate substitute()/position() entry points (anymore), so there is
no point in not providing the font to GSUB.
上级 b0e6a26a
......@@ -1287,8 +1287,8 @@ struct GSUB : GSUBGPOS
inline bool substitute_lookup (hb_apply_context_t *c, unsigned int lookup_index) const
{ return get_lookup (lookup_index).apply_string (c); }
static inline void substitute_start (hb_face_t *face, hb_buffer_t *buffer);
static inline void substitute_finish (hb_face_t *face, hb_buffer_t *buffer);
static inline void substitute_start (hb_font_t *font, hb_buffer_t *buffer);
static inline void substitute_finish (hb_font_t *font, hb_buffer_t *buffer);
inline void closure_lookup (hb_closure_context_t *c,
unsigned int lookup_index) const
......@@ -1306,16 +1306,13 @@ struct GSUB : GSUBGPOS
void
GSUB::substitute_start (hb_face_t *face, hb_buffer_t *buffer)
GSUB::substitute_start (hb_font_t *font, hb_buffer_t *buffer)
{
HB_BUFFER_ALLOCATE_VAR (buffer, glyph_props);
HB_BUFFER_ALLOCATE_VAR (buffer, lig_props);
HB_BUFFER_ALLOCATE_VAR (buffer, syllable);
/* TODO This pattern is duplicated from gsubgpos-private.h. Do something about it. */
const GDEF &gdef = hb_ot_layout_from_face (face) &&
!HB_SHAPER_DATA_IS_INVALID (hb_ot_layout_from_face (face)) ?
*hb_ot_layout_from_face (face)->gdef : Null(GDEF);
const GDEF &gdef = *hb_ot_layout_from_face (font->face)->gdef;
unsigned int count = buffer->len;
for (unsigned int i = 0; i < count; i++) {
buffer->info[i].lig_props() = buffer->info[i].syllable() = 0;
......@@ -1324,7 +1321,7 @@ GSUB::substitute_start (hb_face_t *face, hb_buffer_t *buffer)
}
void
GSUB::substitute_finish (hb_face_t *face HB_UNUSED, hb_buffer_t *buffer HB_UNUSED)
GSUB::substitute_finish (hb_font_t *font HB_UNUSED, hb_buffer_t *buffer HB_UNUSED)
{
}
......
......@@ -118,18 +118,15 @@ struct hb_apply_context_t
hb_apply_context_t (hb_font_t *font_,
hb_face_t *face_,
hb_buffer_t *buffer_,
hb_mask_t lookup_mask_,
const hb_set_digest_t *digest_) :
font (font_), face (face_), buffer (buffer_),
font (font_), face (font->face), buffer (buffer_),
direction (buffer_->props.direction),
lookup_mask (lookup_mask_),
nesting_level_left (MAX_NESTING_LEVEL),
lookup_props (0), property (0), debug_depth (0),
gdef (hb_ot_layout_from_face (face_) &&
!HB_SHAPER_DATA_IS_INVALID (hb_ot_layout_from_face (face_)) ?
*hb_ot_layout_from_face (face_)->gdef : Null(GDEF)),
gdef (*hb_ot_layout_from_face (face)->gdef),
has_glyph_classes (gdef.has_glyph_classes ()),
digest (*digest_) {}
......
......@@ -146,18 +146,18 @@ hb_ot_layout_would_substitute_lookup_fast (hb_face_t *face,
/* Should be called before all the substitute_lookup's are done. */
HB_INTERNAL void
hb_ot_layout_substitute_start (hb_face_t *face,
hb_ot_layout_substitute_start (hb_font_t *font,
hb_buffer_t *buffer);
HB_INTERNAL hb_bool_t
hb_ot_layout_substitute_lookup (hb_face_t *face,
hb_ot_layout_substitute_lookup (hb_font_t *font,
hb_buffer_t *buffer,
unsigned int lookup_index,
hb_mask_t mask);
/* Should be called after all the substitute_lookup's are done */
HB_INTERNAL void
hb_ot_layout_substitute_finish (hb_face_t *face,
hb_ot_layout_substitute_finish (hb_font_t *font,
hb_buffer_t *buffer);
......
......@@ -422,26 +422,26 @@ hb_ot_layout_would_substitute_lookup_fast (hb_face_t *face,
}
void
hb_ot_layout_substitute_start (hb_face_t *face, hb_buffer_t *buffer)
hb_ot_layout_substitute_start (hb_font_t *font, hb_buffer_t *buffer)
{
GSUB::substitute_start (face, buffer);
GSUB::substitute_start (font, buffer);
}
hb_bool_t
hb_ot_layout_substitute_lookup (hb_face_t *face,
hb_ot_layout_substitute_lookup (hb_font_t *font,
hb_buffer_t *buffer,
unsigned int lookup_index,
hb_mask_t mask)
{
if (unlikely (lookup_index >= hb_ot_layout_from_face (face)->gsub_lookup_count)) return false;
hb_apply_context_t c (NULL, face, buffer, mask, &hb_ot_layout_from_face (face)->gsub_digests[lookup_index]);
return hb_ot_layout_from_face (face)->gsub->substitute_lookup (&c, lookup_index);
if (unlikely (lookup_index >= hb_ot_layout_from_face (font->face)->gsub_lookup_count)) return false;
hb_apply_context_t c (font, buffer, mask, &hb_ot_layout_from_face (font->face)->gsub_digests[lookup_index]);
return hb_ot_layout_from_face (font->face)->gsub->substitute_lookup (&c, lookup_index);
}
void
hb_ot_layout_substitute_finish (hb_face_t *face, hb_buffer_t *buffer)
hb_ot_layout_substitute_finish (hb_font_t *font, hb_buffer_t *buffer)
{
GSUB::substitute_finish (face, buffer);
GSUB::substitute_finish (font, buffer);
}
void
......@@ -476,7 +476,7 @@ hb_ot_layout_position_lookup (hb_font_t *font,
hb_mask_t mask)
{
if (unlikely (lookup_index >= hb_ot_layout_from_face (font->face)->gpos_lookup_count)) return false;
hb_apply_context_t c (font, font->face, buffer, mask, &hb_ot_layout_from_face (font->face)->gpos_digests[lookup_index]);
hb_apply_context_t c (font, buffer, mask, &hb_ot_layout_from_face (font->face)->gpos_digests[lookup_index]);
return hb_ot_layout_from_face (font->face)->gpos->position_lookup (&c, lookup_index);
}
......
......@@ -62,7 +62,7 @@ struct hb_ot_map_t
{ return a->index < b->index ? -1 : a->index > b->index ? 1 : 0; }
};
typedef void (*pause_func_t) (const hb_ot_map_t *map, void *face_or_font, hb_buffer_t *buffer, void *user_data);
typedef void (*pause_func_t) (const hb_ot_map_t *map, hb_font_t *font, hb_buffer_t *buffer, void *user_data);
typedef struct {
pause_func_t func;
void *user_data;
......@@ -76,9 +76,6 @@ struct hb_ot_map_t
hb_ot_map_t (void) { memset (this, 0, sizeof (*this)); }
typedef void (*gsub_pause_func_t) (const hb_ot_map_t *map, hb_face_t *face, hb_buffer_t *buffer, void *user_data);
typedef void (*gpos_pause_func_t) (const hb_ot_map_t *map, hb_font_t *font, hb_buffer_t *buffer, void *user_data);
inline hb_mask_t get_global_mask (void) const { return global_mask; }
inline hb_mask_t get_mask (hb_tag_t feature_tag, unsigned int *shift = NULL) const {
......@@ -120,7 +117,7 @@ struct hb_ot_map_t
{ return chosen_script[table_index]; }
HB_INTERNAL void substitute_closure (hb_face_t *face, hb_set_t *glyphs) const;
HB_INTERNAL void substitute (hb_face_t *face, hb_buffer_t *buffer) const;
HB_INTERNAL void substitute (hb_font_t *font, hb_buffer_t *buffer) const;
HB_INTERNAL void position (hb_font_t *font, hb_buffer_t *buffer) const;
inline void finish (void) {
......@@ -159,10 +156,10 @@ struct hb_ot_map_builder_t
inline void add_bool_feature (hb_tag_t tag, bool global = true)
{ add_feature (tag, 1, global); }
inline void add_gsub_pause (hb_ot_map_t::gsub_pause_func_t pause_func, void *user_data)
{ add_pause (0, (hb_ot_map_t::pause_func_t) pause_func, user_data); }
inline void add_gpos_pause (hb_ot_map_t::gpos_pause_func_t pause_func, void *user_data)
{ add_pause (1, (hb_ot_map_t::pause_func_t) pause_func, user_data); }
inline void add_gsub_pause (hb_ot_map_t::pause_func_t pause_func, void *user_data)
{ add_pause (0, pause_func, user_data); }
inline void add_gpos_pause (hb_ot_map_t::pause_func_t pause_func, void *user_data)
{ add_pause (1, pause_func, user_data); }
HB_INTERNAL void compile (hb_face_t *face,
const hb_segment_properties_t *props,
......
......@@ -77,7 +77,7 @@ void hb_ot_map_builder_t::add_feature (hb_tag_t tag, unsigned int value, bool gl
/* Keep the next two functions in sync. */
void hb_ot_map_t::substitute (hb_face_t *face, hb_buffer_t *buffer) const
void hb_ot_map_t::substitute (hb_font_t *font, hb_buffer_t *buffer) const
{
const unsigned int table_index = 0;
unsigned int i = 0;
......@@ -85,16 +85,16 @@ void hb_ot_map_t::substitute (hb_face_t *face, hb_buffer_t *buffer) const
for (unsigned int pause_index = 0; pause_index < pauses[table_index].len; pause_index++) {
const pause_map_t *pause = &pauses[table_index][pause_index];
for (; i < pause->num_lookups; i++)
hb_ot_layout_substitute_lookup (face, buffer, lookups[table_index][i].index, lookups[table_index][i].mask);
hb_ot_layout_substitute_lookup (font, buffer, lookups[table_index][i].index, lookups[table_index][i].mask);
buffer->clear_output ();
if (pause->callback.func)
pause->callback.func (this, face, buffer, pause->callback.user_data);
pause->callback.func (this, font, buffer, pause->callback.user_data);
}
for (; i < lookups[table_index].len; i++)
hb_ot_layout_substitute_lookup (face, buffer, lookups[table_index][i].index, lookups[table_index][i].mask);
hb_ot_layout_substitute_lookup (font, buffer, lookups[table_index][i].index, lookups[table_index][i].mask);
}
void hb_ot_map_t::position (hb_font_t *font, hb_buffer_t *buffer) const
......
......@@ -193,12 +193,12 @@ indic_other_features[] =
static void
initial_reordering (const hb_ot_map_t *map,
hb_face_t *face,
hb_font_t *font,
hb_buffer_t *buffer,
void *user_data HB_UNUSED);
static void
final_reordering (const hb_ot_map_t *map,
hb_face_t *face,
hb_font_t *font,
hb_buffer_t *buffer,
void *user_data HB_UNUSED);
......@@ -696,7 +696,7 @@ initial_reordering_non_indic (const hb_ot_map_t *map HB_UNUSED,
static void
initial_reordering (const hb_ot_map_t *map,
hb_face_t *face HB_UNUSED,
hb_font_t *font HB_UNUSED,
hb_buffer_t *buffer,
void *user_data HB_UNUSED)
{
......@@ -1059,7 +1059,7 @@ final_reordering_syllable (hb_buffer_t *buffer,
static void
final_reordering (const hb_ot_map_t *map,
hb_face_t *face HB_UNUSED,
hb_font_t *font HB_UNUSED,
hb_buffer_t *buffer,
void *user_data HB_UNUSED)
{
......
......@@ -367,15 +367,15 @@ hb_synthesize_glyph_classes (hb_ot_shape_context_t *c)
static void
hb_ot_substitute_complex (hb_ot_shape_context_t *c)
{
hb_ot_layout_substitute_start (c->face, c->buffer);
hb_ot_layout_substitute_start (c->font, c->buffer);
if (!hb_ot_layout_has_glyph_classes (c->face))
hb_synthesize_glyph_classes (c);
if (hb_ot_layout_has_substitution (c->face))
c->plan->map.substitute (c->face, c->buffer);
c->plan->map.substitute (c->font, c->buffer);
hb_ot_layout_substitute_finish (c->face, c->buffer);
hb_ot_layout_substitute_finish (c->font, c->buffer);
return;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册