{ return a->index < b->index ? -1 : a->index > b->index ? 1 : 0; }
};
- typedef void (*pause_func_t) (const hb_ot_map_t *map, hb_font_t *font, hb_buffer_t *buffer);
+ typedef void (*pause_func_t) (const struct hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer);
struct pause_map_t {
unsigned int num_lookups; /* Cumulative */
inline hb_tag_t get_chosen_script (unsigned int table_index) const
{ return chosen_script[table_index]; }
- HB_INTERNAL void substitute_closure (hb_face_t *face, hb_set_t *glyphs) 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;
+ HB_INTERNAL void substitute_closure (const struct hb_ot_shape_plan_t *plan, hb_face_t *face, hb_set_t *glyphs) const;
+ HB_INTERNAL void substitute (const struct hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const;
+ HB_INTERNAL void position (const struct hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const;
inline void finish (void) {
features.finish ();
/* Keep the next two functions in sync. */
-void hb_ot_map_t::substitute (hb_font_t *font, hb_buffer_t *buffer) const
+void hb_ot_map_t::substitute (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const
{
const unsigned int table_index = 0;
unsigned int i = 0;
buffer->clear_output ();
if (pause->callback)
- pause->callback (this, font, buffer);
+ pause->callback (plan, font, buffer);
}
for (; i < lookups[table_index].len; i++)
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
+void hb_ot_map_t::position (const hb_ot_shape_plan_t *plan, hb_font_t *font, hb_buffer_t *buffer) const
{
const unsigned int table_index = 1;
unsigned int i = 0;
hb_ot_layout_position_lookup (font, buffer, lookups[table_index][i].index, lookups[table_index][i].mask);
if (pause->callback)
- pause->callback (this, font, buffer);
+ pause->callback (plan, font, buffer);
}
for (; i < lookups[table_index].len; i++)
hb_ot_layout_position_lookup (font, buffer, lookups[table_index][i].index, lookups[table_index][i].mask);
}
-void hb_ot_map_t::substitute_closure (hb_face_t *face,
- hb_set_t *glyphs) const
+void hb_ot_map_t::substitute_closure (const hb_ot_shape_plan_t *plan, hb_face_t *face, hb_set_t *glyphs) const
{
unsigned int table_index = 0;
unsigned int i = 0;
if (0) fprintf (stderr, "syllable %d..%d %s\n", last, p+1, #func); \
for (unsigned int i = last; i < p+1; i++) \
info[i].syllable() = syllable_serial; \
- PASTE (initial_reordering_, func) (map, buffer, mask_array, last, p+1); \
+ PASTE (initial_reordering_, func) (plan, buffer, mask_array, last, p+1); \
last = p+1; \
syllable_serial++; \
if (unlikely (!syllable_serial)) syllable_serial++; \
} HB_STMT_END
static void
-find_syllables (const hb_ot_map_t *map, hb_buffer_t *buffer, hb_mask_t *mask_array)
+find_syllables (const hb_ot_shape_plan_t *plan, hb_buffer_t *buffer, hb_mask_t *mask_array)
{
unsigned int p, pe, eof, ts, te, act;
int cs;
unsigned int count;
};
- indic_shape_plan_t (const hb_ot_map_t *map_) :
- map (map_),
- pref (map_, HB_TAG('p','r','e','f')),
- blwf (map_, HB_TAG('b','l','w','f')),
- pstf (map_, HB_TAG('p','s','t','f')),
- is_old_spec (IS_OLD_INDIC_TAG (map->get_chosen_script (0))) {}
-
- const hb_ot_map_t *map;
+ indic_shape_plan_t (const hb_ot_shape_plan_t *plan) :
+ pref (&plan->map, HB_TAG('p','r','e','f')),
+ blwf (&plan->map, HB_TAG('b','l','w','f')),
+ pstf (&plan->map, HB_TAG('p','s','t','f')),
+ is_old_spec (IS_OLD_INDIC_TAG (plan->map.get_chosen_script (0))) {}
+
would_apply_feature_t pref;
would_apply_feature_t blwf;
would_apply_feature_t pstf;
static void
-initial_reordering (const hb_ot_map_t *map,
+initial_reordering (const hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer);
static void
-final_reordering (const hb_ot_map_t *map,
+final_reordering (const hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer);
static void
-update_consonant_positions (const hb_ot_map_t *map,
+update_consonant_positions (const hb_ot_shape_plan_t *plan,
hb_buffer_t *buffer,
hb_font_t *font)
{
default: virama = 0; break;
}
- indic_shape_plan_t indic_plan (map);
+ indic_shape_plan_t indic_plan (plan);
unsigned int consonant_pos = indic_plan.is_old_spec ? 0 : 1;
hb_codepoint_t glyphs[2];
* https://www.microsoft.com/typography/otfntdev/devanot/shaping.aspx */
static void
-initial_reordering_consonant_syllable (const hb_ot_map_t *map, hb_buffer_t *buffer, hb_mask_t *basic_mask_array,
+initial_reordering_consonant_syllable (const hb_ot_shape_plan_t *plan, hb_buffer_t *buffer, hb_mask_t *basic_mask_array,
unsigned int start, unsigned int end)
{
hb_glyph_info_t *info = buffer->info;
/* For old-style Indic script tags, move the first post-base Halant after
* last consonant. */
- if (IS_OLD_INDIC_TAG (map->get_chosen_script (0))) {
+ if (IS_OLD_INDIC_TAG (plan->map.get_chosen_script (0))) {
for (unsigned int i = base + 1; i < end; i++)
if (info[i].indic_category() == OT_H) {
unsigned int j;
static void
-initial_reordering_vowel_syllable (const hb_ot_map_t *map,
+initial_reordering_vowel_syllable (const hb_ot_shape_plan_t *plan,
hb_buffer_t *buffer,
hb_mask_t *basic_mask_array,
unsigned int start, unsigned int end)
{
/* We made the vowels look like consonants. So let's call the consonant logic! */
- initial_reordering_consonant_syllable (map, buffer, basic_mask_array, start, end);
+ initial_reordering_consonant_syllable (plan, buffer, basic_mask_array, start, end);
}
static void
-initial_reordering_standalone_cluster (const hb_ot_map_t *map,
+initial_reordering_standalone_cluster (const hb_ot_shape_plan_t *plan,
hb_buffer_t *buffer,
hb_mask_t *basic_mask_array,
unsigned int start, unsigned int end)
return;
}
- initial_reordering_consonant_syllable (map, buffer, basic_mask_array, start, end);
+ initial_reordering_consonant_syllable (plan, buffer, basic_mask_array, start, end);
}
static void
-initial_reordering_non_indic (const hb_ot_map_t *map HB_UNUSED,
+initial_reordering_non_indic (const hb_ot_shape_plan_t *plan HB_UNUSED,
hb_buffer_t *buffer HB_UNUSED,
hb_mask_t *basic_mask_array HB_UNUSED,
unsigned int start HB_UNUSED, unsigned int end HB_UNUSED)
#include "hb-ot-shape-complex-indic-machine.hh"
static void
-initial_reordering (const hb_ot_map_t *map,
+initial_reordering (const hb_ot_shape_plan_t *plan,
hb_font_t *font,
hb_buffer_t *buffer)
{
- update_consonant_positions (map, buffer, font);
+ update_consonant_positions (plan, buffer, font);
hb_mask_t basic_mask_array[ARRAY_LENGTH (indic_basic_features)] = {0};
unsigned int num_masks = ARRAY_LENGTH (indic_basic_features);
for (unsigned int i = 0; i < num_masks; i++)
- basic_mask_array[i] = map->get_1_mask (indic_basic_features[i].tag);
+ basic_mask_array[i] = plan->map.get_1_mask (indic_basic_features[i].tag);
- find_syllables (map, buffer, basic_mask_array);
+ find_syllables (plan, buffer, basic_mask_array);
}
static void
static void
-final_reordering (const hb_ot_map_t *map,
+final_reordering (const hb_ot_shape_plan_t *plan,
hb_font_t *font HB_UNUSED,
hb_buffer_t *buffer)
{
unsigned int count = buffer->len;
if (!count) return;
- hb_mask_t init_mask = map->get_1_mask (HB_TAG('i','n','i','t'));
- hb_mask_t pref_mask = map->get_1_mask (HB_TAG('p','r','e','f'));
+ hb_mask_t init_mask = plan->map.get_1_mask (HB_TAG('i','n','i','t'));
+ hb_mask_t pref_mask = plan->map.get_1_mask (HB_TAG('p','r','e','f'));
hb_glyph_info_t *info = buffer->info;
unsigned int last = 0;
hb_segment_properties_t props;
const struct hb_ot_complex_shaper_t *shaper;
hb_ot_map_t map;
+
+ inline void substitute_closure (hb_face_t *face, hb_set_t *glyphs) const { map.substitute_closure (this, face, glyphs); }
+ inline void substitute (hb_font_t *font, hb_buffer_t *buffer) const { map.substitute (this, font, buffer); }
+ inline void position (hb_font_t *font, hb_buffer_t *buffer) const { map.position (this, font, buffer); }
+
+ void finish (void) { map.finish (); }
};
struct hb_ot_shape_planner_t
const hb_feature_t *user_features,
unsigned int num_user_features)
{
+ hb_ot_map_builder_t *map = &planner->map;
+
switch (props->direction) {
case HB_DIRECTION_LTR:
- planner->map.add_bool_feature (HB_TAG ('l','t','r','a'));
- planner->map.add_bool_feature (HB_TAG ('l','t','r','m'));
+ map->add_bool_feature (HB_TAG ('l','t','r','a'));
+ map->add_bool_feature (HB_TAG ('l','t','r','m'));
break;
case HB_DIRECTION_RTL:
- planner->map.add_bool_feature (HB_TAG ('r','t','l','a'));
- planner->map.add_bool_feature (HB_TAG ('r','t','l','m'), false);
+ map->add_bool_feature (HB_TAG ('r','t','l','a'));
+ map->add_bool_feature (HB_TAG ('r','t','l','m'), false);
break;
case HB_DIRECTION_TTB:
case HB_DIRECTION_BTT:
#define ADD_FEATURES(array) \
HB_STMT_START { \
for (unsigned int i = 0; i < ARRAY_LENGTH (array); i++) \
- planner->map.add_bool_feature (array[i]); \
+ map->add_bool_feature (array[i]); \
} HB_STMT_END
if (planner->shaper->collect_features)
for (unsigned int i = 0; i < num_user_features; i++) {
const hb_feature_t *feature = &user_features[i];
- planner->map.add_feature (feature->tag, feature->value, (feature->start == 0 && feature->end == (unsigned int) -1));
+ map->add_feature (feature->tag, feature->value, (feature->start == 0 && feature->end == (unsigned int) -1));
}
}
void
_hb_ot_shaper_shape_plan_data_destroy (hb_ot_shaper_shape_plan_data_t *data)
{
- data->map.finish ();
+ data->finish ();
free (data);
}
static void
hb_ot_shape_setup_masks (hb_ot_shape_context_t *c)
{
- hb_mask_t global_mask = c->plan->map.get_global_mask ();
+ hb_ot_map_t *map = &c->plan->map;
+
+ hb_mask_t global_mask = map->get_global_mask ();
c->buffer->reset_masks (global_mask);
if (c->plan->shaper->setup_masks)
const hb_feature_t *feature = &c->user_features[i];
if (!(feature->start == 0 && feature->end == (unsigned int)-1)) {
unsigned int shift;
- hb_mask_t mask = c->plan->map.get_mask (feature->tag, &shift);
+ hb_mask_t mask = map->get_mask (feature->tag, &shift);
c->buffer->set_masks (feature->value << shift, mask, feature->start, feature->end);
}
}
hb_synthesize_glyph_classes (c);
if (hb_ot_layout_has_substitution (c->face))
- c->plan->map.substitute (c->font, c->buffer);
+ c->plan->substitute (c->font, c->buffer);
hb_ot_layout_substitute_finish (c->font, c->buffer);
&c->buffer->pos[i].y_offset);
}
- c->plan->map.position (c->font, c->buffer);
+ c->plan->position (c->font, c->buffer);
for (unsigned int i = 0; i < count; i++) {
c->font->subtract_glyph_origin_for_direction (c->buffer->info[i].codepoint,
do {
copy.set (glyphs);
- HB_SHAPER_DATA_GET (shape_plan)->map.substitute_closure (font->face, glyphs);
+ HB_SHAPER_DATA_GET (shape_plan)->substitute_closure (font->face, glyphs);
} while (!copy.equal (glyphs));
hb_shape_plan_destroy (shape_plan);