のねのBlog

パソコンの問題や、ソフトウェアの開発で起きた問題など書いていきます。よろしくお願いします^^。

hb_ot_shape_collect_features

     44 static hb_tag_t common_features[] = {
     45   HB_TAG('c','c','m','p'),
     46   HB_TAG('l','i','g','a'),
     47   HB_TAG('l','o','c','l'),
     48   HB_TAG('m','a','r','k'),
     49   HB_TAG('m','k','m','k'),
     50   HB_TAG('r','l','i','g'),
     51 };
     54 static hb_tag_t horizontal_features[] = {
     55   HB_TAG('c','a','l','t'),
     56   HB_TAG('c','l','i','g'),
     57   HB_TAG('c','u','r','s'),
     58   HB_TAG('k','e','r','n'),
     59   HB_TAG('r','c','l','t'),
     60 };
     62 static hb_tag_t vertical_features[] = {
     63   HB_TAG('v','e','r','t'),
     64 };
     68 static void
     69 hb_ot_shape_collect_features (hb_ot_shape_planner_t          *planner,
     70 			      const hb_segment_properties_t  *props,
     71 			      const hb_feature_t             *user_features,
     72 			      unsigned int                    num_user_features)
     73 {
     74   hb_ot_map_builder_t *map = &planner->map;
     75 
     76   switch (props->direction) {
     77     case HB_DIRECTION_LTR:
     78       map->add_global_bool_feature (HB_TAG ('l','t','r','a'));
     79       map->add_global_bool_feature (HB_TAG ('l','t','r','m'));
     80       break;
     81     case HB_DIRECTION_RTL:
     82       map->add_global_bool_feature (HB_TAG ('r','t','l','a'));
     83       map->add_feature (HB_TAG ('r','t','l','m'), 1, F_NONE);
     84       break;
     85     case HB_DIRECTION_TTB:
     86     case HB_DIRECTION_BTT:
     87     case HB_DIRECTION_INVALID:
     88     default:
     89       break;
     90   }
     91 
     92   map->add_feature (HB_TAG ('f','r','a','c'), 1, F_NONE);
     93   map->add_feature (HB_TAG ('n','u','m','r'), 1, F_NONE);
     94   map->add_feature (HB_TAG ('d','n','o','m'), 1, F_NONE);
     95 
     96   if (planner->shaper->collect_features)
     97     planner->shaper->collect_features (planner);
     98 
     99   for (unsigned int i = 0; i < ARRAY_LENGTH (common_features); i++)
    100     map->add_global_bool_feature (common_features[i]);
    101 
    102   if (HB_DIRECTION_IS_HORIZONTAL (props->direction))

    103     for (unsigned int i = 0; i < ARRAY_LENGTH (horizontal_features); i++)
    104       map->add_feature (horizontal_features[i], 1, F_GLOBAL |
    105 			(horizontal_features[i] == HB_TAG('k','e','r','n') ?
    106 			 F_HAS_FALLBACK : F_NONE));
    107   else

    108     for (unsigned int i = 0; i < ARRAY_LENGTH (vertical_features); i++)
    109       map->add_feature (vertical_features[i], 1, F_GLOBAL |
    110 			(vertical_features[i] == HB_TAG('v','k','r','n') ?
    111 			 F_HAS_FALLBACK : F_NONE));
    112 
    113   if (planner->shaper->override_features)
    114     planner->shaper->override_features (planner);
    115 
    116   for (unsigned int i = 0; i < num_user_features; i++) {
    117     const hb_feature_t *feature = &user_features[i];
    118     map->add_feature (feature->tag, feature->value,
    119 		      (feature->start == 0 && feature->end == (unsigned int) -1) ?
    120 		       F_GLOBAL : F_NONE);
    121   }
    122 }
    190   inline void add_global_bool_feature (hb_tag_t tag)
    191   { add_feature (tag, 1, F_GLOBAL); }
     97 void hb_ot_map_builder_t::add_feature (hb_tag_t                  tag,
                                               unsigned int              value,
     98 				       hb_ot_map_feature_flags_t flags)
     99 {
    100   feature_info_t *info = feature_infos.push();
    101   if (unlikely (!info)) return;
    102   if (unlikely (!tag)) return;
    103   info->tag = tag;
    104   info->seq = feature_infos.len;
    105   info->max_value = value;
    106   info->flags = flags;
    107   info->default_value = (flags & F_GLOBAL) ? value : 0;
    108   info->stage[0] = current_stage[0];
    109   info->stage[1] = current_stage[1];
    110 }
    111 
 #if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
     61 #define _HB_BOOLEAN_EXPR(expr) ((expr) ? 1 : 0)
     62 #define likely(  expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 1))
     63 #define unlikely(expr) (__builtin_expect (_HB_BOOLEAN_EXPR(expr), 0))