{ return a->index < b->index ? -1 : a->index > b->index ? 1 : 0; }
};
-
- void
- add_lookups (hb_ot_shape_context_t *c,
- unsigned int table_index,
- unsigned int feature_index,
- hb_mask_t mask)
- {
- unsigned int i = MAX_LOOKUPS - lookup_count[table_index];
- lookup_map_t *lookups = lookup_maps[table_index] + lookup_count[table_index];
-
- unsigned int *lookup_indices = (unsigned int *) lookups;
-
- hb_ot_layout_feature_get_lookup_indexes (c->face,
- table_tags[table_index],
- feature_index,
- 0, &i,
- lookup_indices);
-
- lookup_count[table_index] += i;
-
- while (i--) {
- lookups[i].mask = mask;
- lookups[i].index = lookup_indices[i];
- }
- }
-
+ HB_INTERNAL void add_lookups (hb_ot_shape_plan_context_t *c,
+ unsigned int table_index,
+ unsigned int feature_index,
+ hb_mask_t mask);
public:
inline void add_bool_feature (hb_tag_t tag, bool global = true)
{ add_feature (tag, 1, global); }
- HB_INTERNAL void compile (hb_ot_shape_context_t *c);
+ HB_INTERNAL void compile (hb_ot_shape_plan_context_t *c);
hb_mask_t get_global_mask (void) const { return global_mask; }
void
-hb_ot_map_t::compile (hb_ot_shape_context_t *c)
+hb_ot_map_t::add_lookups (hb_ot_shape_plan_context_t *c,
+ unsigned int table_index,
+ unsigned int feature_index,
+ hb_mask_t mask)
+{
+ unsigned int i = MAX_LOOKUPS - lookup_count[table_index];
+ lookup_map_t *lookups = lookup_maps[table_index] + lookup_count[table_index];
+
+ unsigned int *lookup_indices = (unsigned int *) lookups;
+
+ hb_ot_layout_feature_get_lookup_indexes (c->face,
+ table_tags[table_index],
+ feature_index,
+ 0, &i,
+ lookup_indices);
+
+ lookup_count[table_index] += i;
+
+ while (i--) {
+ lookups[i].mask = mask;
+ lookups[i].index = lookup_indices[i];
+ }
+}
+
+
+void
+hb_ot_map_t::compile (hb_ot_shape_plan_context_t *c)
{
global_mask = 0;
lookup_count[0] = lookup_count[1] = 0;
const hb_tag_t *script_tags;
hb_tag_t language_tag;
- script_tags = hb_ot_tags_from_script (c->buffer->props.script);
- language_tag = hb_ot_tag_from_language (c->buffer->props.language);
+ script_tags = hb_ot_tags_from_script (c->props->script);
+ language_tag = hb_ot_tag_from_language (c->props->language);
unsigned int script_index[2], language_index[2];
for (unsigned int table_index = 0; table_index < 2; table_index++) {
struct hb_ot_map_t;
+struct hb_ot_shape_plan_context_t
+{
+ struct hb_ot_map_t *map;
+
+ hb_face_t *face;
+ hb_segment_properties_t *props;
+
+ const hb_feature_t *user_features;
+ unsigned int num_user_features;
+};
+
+
struct hb_ot_shape_context_t
{
/* Input to hb_ot_shape() */
hb_font_t *font;
hb_face_t *face;
hb_buffer_t *buffer;
- hb_feature_t *features;
- unsigned int num_features;
+ const hb_feature_t *user_features;
+ unsigned int num_user_features;
/* Transient stuff */
hb_direction_t original_direction;
};
static void
-hb_ot_shape_collect_features (hb_ot_shape_context_t *c)
+hb_ot_shape_collect_features (hb_ot_shape_plan_context_t *c)
{
- switch (c->original_direction) {
+ switch (c->props->direction) {
case HB_DIRECTION_LTR:
c->map->add_bool_feature (HB_TAG ('l','t','r','a'));
c->map->add_bool_feature (HB_TAG ('l','t','r','m'));
/* complex */
- for (unsigned int i = 0; i < c->num_features; i++) {
- const hb_feature_t *feature = &c->features[i];
+ for (unsigned int i = 0; i < c->num_user_features; i++) {
+ const hb_feature_t *feature = &c->user_features[i];
c->map->add_feature (feature->tag, feature->value, (feature->start == 0 && feature->end == (unsigned int) -1));
}
}
if (global_mask)
c->buffer->set_masks (global_mask, global_mask, 0, (unsigned int) -1);
- for (unsigned int i = 0; i < c->num_features; i++)
+ for (unsigned int i = 0; i < c->num_user_features; i++)
{
- hb_feature_t *feature = &c->features[i];
+ 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->map->get_mask (feature->tag, &shift);
static void
hb_ot_shape_internal (hb_ot_shape_context_t *c)
{
+ /* Save the original direction, we use it later. */
+ c->original_direction = c->buffer->props.direction;
+
hb_ot_shape_setup_masks (c);
hb_form_clusters (c);
}
void
+hb_ot_shape_plan_internal (hb_ot_map_t *map,
+ hb_face_t *face,
+ hb_segment_properties_t *props,
+ const hb_feature_t *user_features,
+ unsigned int num_user_features)
+{
+ hb_ot_shape_plan_context_t c = {map, face, props, user_features, num_user_features};
+
+ hb_ot_shape_collect_features (&c);
+
+ map->compile (&c);
+}
+
+void
hb_ot_shape (hb_font_t *font,
hb_face_t *face,
hb_buffer_t *buffer,
- hb_feature_t *features,
- unsigned int num_features)
+ const hb_feature_t *user_features,
+ unsigned int num_user_features)
{
- hb_ot_shape_context_t c = {font, face, buffer, features, num_features};
hb_ot_map_t map;
- /* Setup transient context members */
- c.original_direction = buffer->props.direction;
- c.map = ↦
-
- hb_ot_shape_collect_features (&c);
- c.map->compile (&c);
+ hb_ot_shape_plan_internal (&map, face, &buffer->props, user_features, num_user_features);
+ hb_ot_shape_context_t c = {font, face, buffer, user_features, num_user_features};
+ c.map = ↦
hb_ot_shape_internal (&c);
}
void
-hb_ot_shape (hb_font_t *font,
- hb_face_t *face,
- hb_buffer_t *buffer,
- hb_feature_t *features,
- unsigned int num_features);
+hb_ot_shape (hb_font_t *font,
+ hb_face_t *face,
+ hb_buffer_t *buffer,
+ const hb_feature_t *user_features,
+ unsigned int num_user_features);
HB_END_DECLS