Refactor, in a different direction
This commit is contained in:
parent
d2ba016ca1
commit
895fb5d364
|
@ -29,7 +29,7 @@
|
|||
#ifndef HB_OT_MAP_PRIVATE_HH
|
||||
#define HB_OT_MAP_PRIVATE_HH
|
||||
|
||||
#include "hb-ot-shape-private.hh"
|
||||
#include "hb-buffer-private.hh"
|
||||
|
||||
#include "hb-ot-layout.h"
|
||||
|
||||
|
@ -73,7 +73,7 @@ struct hb_ot_map_t {
|
|||
{ return a->index < b->index ? -1 : a->index > b->index ? 1 : 0; }
|
||||
};
|
||||
|
||||
HB_INTERNAL void add_lookups (hb_ot_shape_plan_context_t *c,
|
||||
HB_INTERNAL void add_lookups (hb_face_t *face,
|
||||
unsigned int table_index,
|
||||
unsigned int feature_index,
|
||||
hb_mask_t mask);
|
||||
|
@ -95,7 +95,8 @@ struct hb_ot_map_t {
|
|||
inline void add_bool_feature (hb_tag_t tag, bool global = true)
|
||||
{ add_feature (tag, 1, global); }
|
||||
|
||||
HB_INTERNAL void compile (hb_ot_shape_plan_context_t *c);
|
||||
HB_INTERNAL void compile (hb_face_t *face,
|
||||
hb_segment_properties_t *props);
|
||||
|
||||
hb_mask_t get_global_mask (void) const { return global_mask; }
|
||||
|
||||
|
@ -105,14 +106,14 @@ struct hb_ot_map_t {
|
|||
return map ? map->mask : 0;
|
||||
}
|
||||
|
||||
inline void substitute (hb_ot_shape_context_t *c) const {
|
||||
inline void substitute (hb_face_t *face, hb_buffer_t *buffer) const {
|
||||
for (unsigned int i = 0; i < lookup_count[0]; i++)
|
||||
hb_ot_layout_substitute_lookup (c->face, c->buffer, lookup_maps[0][i].index, lookup_maps[0][i].mask);
|
||||
hb_ot_layout_substitute_lookup (face, buffer, lookup_maps[0][i].index, lookup_maps[0][i].mask);
|
||||
}
|
||||
|
||||
inline void position (hb_ot_shape_context_t *c) const {
|
||||
inline void position (hb_font_t *font, hb_face_t *face, hb_buffer_t *buffer) const {
|
||||
for (unsigned int i = 0; i < lookup_count[1]; i++)
|
||||
hb_ot_layout_position_lookup (c->font, c->face, c->buffer, lookup_maps[1][i].index, lookup_maps[1][i].mask);
|
||||
hb_ot_layout_position_lookup (font, face, buffer, lookup_maps[1][i].index, lookup_maps[1][i].mask);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -34,7 +34,7 @@ HB_BEGIN_DECLS
|
|||
|
||||
|
||||
void
|
||||
hb_ot_map_t::add_lookups (hb_ot_shape_plan_context_t *c,
|
||||
hb_ot_map_t::add_lookups (hb_face_t *face,
|
||||
unsigned int table_index,
|
||||
unsigned int feature_index,
|
||||
hb_mask_t mask)
|
||||
|
@ -44,7 +44,7 @@ hb_ot_map_t::add_lookups (hb_ot_shape_plan_context_t *c,
|
|||
|
||||
unsigned int *lookup_indices = (unsigned int *) lookups;
|
||||
|
||||
hb_ot_layout_feature_get_lookup_indexes (c->face,
|
||||
hb_ot_layout_feature_get_lookup_indexes (face,
|
||||
table_tags[table_index],
|
||||
feature_index,
|
||||
0, &i,
|
||||
|
@ -60,7 +60,8 @@ hb_ot_map_t::add_lookups (hb_ot_shape_plan_context_t *c,
|
|||
|
||||
|
||||
void
|
||||
hb_ot_map_t::compile (hb_ot_shape_plan_context_t *c)
|
||||
hb_ot_map_t::compile (hb_face_t *face,
|
||||
hb_segment_properties_t *props)
|
||||
{
|
||||
global_mask = 0;
|
||||
lookup_count[0] = lookup_count[1] = 0;
|
||||
|
@ -75,14 +76,14 @@ hb_ot_map_t::compile (hb_ot_shape_plan_context_t *c)
|
|||
const hb_tag_t *script_tags;
|
||||
hb_tag_t language_tag;
|
||||
|
||||
script_tags = hb_ot_tags_from_script (c->props->script);
|
||||
language_tag = hb_ot_tag_from_language (c->props->language);
|
||||
script_tags = hb_ot_tags_from_script (props->script);
|
||||
language_tag = hb_ot_tag_from_language (props->language);
|
||||
|
||||
unsigned int script_index[2], language_index[2];
|
||||
for (unsigned int table_index = 0; table_index < 2; table_index++) {
|
||||
hb_tag_t table_tag = table_tags[table_index];
|
||||
hb_ot_layout_table_choose_script (c->face, table_tag, script_tags, &script_index[table_index]);
|
||||
hb_ot_layout_script_find_language (c->face, table_tag, script_index[table_index], language_tag, &language_index[table_index]);
|
||||
hb_ot_layout_table_choose_script (face, table_tag, script_tags, &script_index[table_index]);
|
||||
hb_ot_layout_script_find_language (face, table_tag, script_index[table_index], language_tag, &language_index[table_index]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -124,7 +125,7 @@ hb_ot_map_t::compile (hb_ot_shape_plan_context_t *c)
|
|||
bool found = false;
|
||||
unsigned int feature_index[2];
|
||||
for (unsigned int table_index = 0; table_index < 2; table_index++)
|
||||
found |= hb_ot_layout_language_find_feature (c->face,
|
||||
found |= hb_ot_layout_language_find_feature (face,
|
||||
table_tags[table_index],
|
||||
script_index[table_index],
|
||||
language_index[table_index],
|
||||
|
@ -161,15 +162,15 @@ hb_ot_map_t::compile (hb_ot_shape_plan_context_t *c)
|
|||
/* Collect lookup indices for features */
|
||||
|
||||
unsigned int required_feature_index;
|
||||
if (hb_ot_layout_language_get_required_feature_index (c->face,
|
||||
if (hb_ot_layout_language_get_required_feature_index (face,
|
||||
table_tag,
|
||||
script_index[table_index],
|
||||
language_index[table_index],
|
||||
&required_feature_index))
|
||||
add_lookups (c, table_index, required_feature_index, 1);
|
||||
add_lookups (face, table_index, required_feature_index, 1);
|
||||
|
||||
for (unsigned i = 0; i < feature_count; i++)
|
||||
add_lookups (c, table_index, feature_maps[i].index[table_index], feature_maps[i].mask);
|
||||
add_lookups (face, table_index, feature_maps[i].index[table_index], feature_maps[i].mask);
|
||||
|
||||
/* Sort lookups and merge duplicates */
|
||||
qsort (lookup_maps[table_index], lookup_count[table_index], sizeof (lookup_maps[table_index][0]), (hb_compare_func_t) lookup_map_t::cmp);
|
||||
|
|
|
@ -31,23 +31,12 @@
|
|||
|
||||
#include "hb-ot-shape.h"
|
||||
|
||||
#include "hb-buffer-private.hh"
|
||||
#include "hb-ot-map-private.hh"
|
||||
|
||||
HB_BEGIN_DECLS
|
||||
|
||||
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
|
||||
{
|
||||
|
|
|
@ -49,16 +49,19 @@ hb_tag_t default_features[] = {
|
|||
};
|
||||
|
||||
static void
|
||||
hb_ot_shape_collect_features (hb_ot_shape_plan_context_t *c)
|
||||
hb_ot_shape_collect_features (hb_ot_map_t *map,
|
||||
hb_segment_properties_t *props,
|
||||
const hb_feature_t *user_features,
|
||||
unsigned int num_user_features)
|
||||
{
|
||||
switch (c->props->direction) {
|
||||
switch (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'));
|
||||
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:
|
||||
c->map->add_bool_feature (HB_TAG ('r','t','l','a'));
|
||||
c->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:
|
||||
|
@ -67,13 +70,13 @@ hb_ot_shape_collect_features (hb_ot_shape_plan_context_t *c)
|
|||
}
|
||||
|
||||
for (unsigned int i = 0; i < ARRAY_LENGTH (default_features); i++)
|
||||
c->map->add_bool_feature (default_features[i]);
|
||||
map->add_bool_feature (default_features[i]);
|
||||
|
||||
/* complex */
|
||||
|
||||
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));
|
||||
for (unsigned int i = 0; i < num_user_features; i++) {
|
||||
const hb_feature_t *feature = &user_features[i];
|
||||
map->add_feature (feature->tag, feature->value, (feature->start == 0 && feature->end == (unsigned int) -1));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,7 +108,7 @@ hb_ot_substitute_complex (hb_ot_shape_context_t *c)
|
|||
if (!hb_ot_layout_has_substitution (c->face))
|
||||
return;
|
||||
|
||||
c->map->substitute (c);
|
||||
c->map->substitute (c->face, c->buffer);
|
||||
|
||||
c->applied_substitute_complex = TRUE;
|
||||
return;
|
||||
|
@ -118,7 +121,7 @@ hb_ot_position_complex (hb_ot_shape_context_t *c)
|
|||
if (!hb_ot_layout_has_positioning (c->face))
|
||||
return;
|
||||
|
||||
c->map->position (c);
|
||||
c->map->position (c->font, c->face, c->buffer);
|
||||
|
||||
hb_ot_layout_position_finish (c->font, c->face, c->buffer);
|
||||
|
||||
|
@ -324,11 +327,9 @@ hb_ot_shape_plan_internal (hb_ot_map_t *map,
|
|||
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 (map, props, user_features, num_user_features);
|
||||
|
||||
hb_ot_shape_collect_features (&c);
|
||||
|
||||
map->compile (&c);
|
||||
map->compile (face, props);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
Loading…
Reference in New Issue