< prev index next >

src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-map.hh

Print this page

        

@@ -24,16 +24,19 @@
  *
  * Red Hat Author(s): Behdad Esfahbod
  * Google Author(s): Behdad Esfahbod
  */
 
-#ifndef HB_OT_MAP_PRIVATE_HH
-#define HB_OT_MAP_PRIVATE_HH
+#ifndef HB_OT_MAP_HH
+#define HB_OT_MAP_HH
 
-#include "hb-buffer-private.hh"
+#include "hb-buffer.hh"
 
 
+#define HB_OT_MAP_MAX_BITS 8u
+#define HB_OT_MAP_MAX_VALUE ((1u << HB_OT_MAP_MAX_BITS) - 1u)
+
 struct hb_ot_shape_plan_t;
 
 static const hb_tag_t table_tags[2] = {HB_OT_TAG_GSUB, HB_OT_TAG_GPOS};
 
 struct hb_ot_map_t

@@ -50,19 +53,21 @@
     hb_mask_t mask;
     hb_mask_t _1_mask; /* mask for value=1, for quick access */
     unsigned int needs_fallback : 1;
     unsigned int auto_zwnj : 1;
     unsigned int auto_zwj : 1;
+    unsigned int random : 1;
 
-    inline int cmp (const hb_tag_t *tag_) const
-    { return *tag_ < tag ? -1 : *tag_ > tag ? 1 : 0; }
+    int cmp (const hb_tag_t tag_) const
+    { return tag_ < tag ? -1 : tag_ > tag ? 1 : 0; }
   };
 
   struct lookup_map_t {
     unsigned short index;
     unsigned short auto_zwnj : 1;
     unsigned short auto_zwj : 1;
+    unsigned short random : 1;
     hb_mask_t mask;
 
     static int cmp (const void *pa, const void *pb)
     {
       const lookup_map_t *a = (const lookup_map_t *) pa;

@@ -76,69 +81,75 @@
   struct stage_map_t {
     unsigned int last_lookup; /* Cumulative */
     pause_func_t pause_func;
   };
 
-  inline void init (void)
+  void init ()
   {
     memset (this, 0, sizeof (*this));
 
     features.init ();
     for (unsigned int table_index = 0; table_index < 2; table_index++)
     {
       lookups[table_index].init ();
       stages[table_index].init ();
     }
   }
-  inline void fini (void)
+  void fini ()
   {
     features.fini ();
     for (unsigned int table_index = 0; table_index < 2; table_index++)
     {
       lookups[table_index].fini ();
       stages[table_index].fini ();
     }
   }
 
-  inline hb_mask_t get_global_mask (void) const { return global_mask; }
+  hb_mask_t get_global_mask () const { return global_mask; }
 
-  inline hb_mask_t get_mask (hb_tag_t feature_tag, unsigned int *shift = nullptr) const {
+  hb_mask_t get_mask (hb_tag_t feature_tag, unsigned int *shift = nullptr) const
+  {
     const feature_map_t *map = features.bsearch (feature_tag);
     if (shift) *shift = map ? map->shift : 0;
     return map ? map->mask : 0;
   }
 
-  inline bool needs_fallback (hb_tag_t feature_tag) const {
+  bool needs_fallback (hb_tag_t feature_tag) const
+  {
     const feature_map_t *map = features.bsearch (feature_tag);
     return map ? map->needs_fallback : false;
   }
 
-  inline hb_mask_t get_1_mask (hb_tag_t feature_tag) const {
+  hb_mask_t get_1_mask (hb_tag_t feature_tag) const
+  {
     const feature_map_t *map = features.bsearch (feature_tag);
     return map ? map->_1_mask : 0;
   }
 
-  inline unsigned int get_feature_index (unsigned int table_index, hb_tag_t feature_tag) const {
+  unsigned int get_feature_index (unsigned int table_index, hb_tag_t feature_tag) const
+  {
     const feature_map_t *map = features.bsearch (feature_tag);
     return map ? map->index[table_index] : HB_OT_LAYOUT_NO_FEATURE_INDEX;
   }
 
-  inline unsigned int get_feature_stage (unsigned int table_index, hb_tag_t feature_tag) const {
+  unsigned int get_feature_stage (unsigned int table_index, hb_tag_t feature_tag) const
+  {
     const feature_map_t *map = features.bsearch (feature_tag);
     return map ? map->stage[table_index] : (unsigned int) -1;
   }
 
-  inline void get_stage_lookups (unsigned int table_index, unsigned int stage,
-                                 const struct lookup_map_t **plookups, unsigned int *lookup_count) const {
+  void get_stage_lookups (unsigned int table_index, unsigned int stage,
+                          const struct lookup_map_t **plookups, unsigned int *lookup_count) const
+  {
     if (unlikely (stage == (unsigned int) -1)) {
       *plookups = nullptr;
       *lookup_count = 0;
       return;
     }
-    assert (stage <= stages[table_index].len);
+    assert (stage <= stages[table_index].length);
     unsigned int start = stage ? stages[table_index][stage - 1].last_lookup : 0;
-    unsigned int end   = stage < stages[table_index].len ? stages[table_index][stage].last_lookup : lookups[table_index].len;
+    unsigned int end   = stage < stages[table_index].length ? stages[table_index][stage].last_lookup : lookups[table_index].length;
     *plookups = end == start ? nullptr : &lookups[table_index][start];
     *lookup_count = end - start;
   }
 
   HB_INTERNAL void collect_lookups (unsigned int table_index, hb_set_t *lookups) const;

@@ -154,61 +165,81 @@
 
   private:
 
   hb_mask_t global_mask;
 
-  hb_vector_t<feature_map_t, 8> features;
-  hb_vector_t<lookup_map_t, 32> lookups[2]; /* GSUB/GPOS */
-  hb_vector_t<stage_map_t, 4> stages[2]; /* GSUB/GPOS */
+  hb_vector_t<feature_map_t> features;
+  hb_vector_t<lookup_map_t> lookups[2]; /* GSUB/GPOS */
+  hb_vector_t<stage_map_t> stages[2]; /* GSUB/GPOS */
 };
 
-enum hb_ot_map_feature_flags_t {
+enum hb_ot_map_feature_flags_t
+{
   F_NONE                = 0x0000u,
   F_GLOBAL              = 0x0001u, /* Feature applies to all characters; results in no mask allocated for it. */
   F_HAS_FALLBACK        = 0x0002u, /* Has fallback implementation, so include mask bit even if feature not found. */
   F_MANUAL_ZWNJ         = 0x0004u, /* Don't skip over ZWNJ when matching **context**. */
   F_MANUAL_ZWJ          = 0x0008u, /* Don't skip over ZWJ when matching **input**. */
-  F_GLOBAL_SEARCH       = 0x0010u  /* If feature not found in LangSys, look for it in global feature list and pick one. */
+  F_MANUAL_JOINERS      = F_MANUAL_ZWNJ | F_MANUAL_ZWJ,
+  F_GLOBAL_MANUAL_JOINERS= F_GLOBAL | F_MANUAL_JOINERS,
+  F_GLOBAL_HAS_FALLBACK = F_GLOBAL | F_HAS_FALLBACK,
+  F_GLOBAL_SEARCH       = 0x0010u, /* If feature not found in LangSys, look for it in global feature list and pick one. */
+  F_RANDOM              = 0x0020u  /* Randomly select a glyph from an AlternateSubstFormat1 subtable. */
 };
 HB_MARK_AS_FLAG_T (hb_ot_map_feature_flags_t);
-/* Macro version for where const is desired. */
-#define F_COMBINE(l,r) (hb_ot_map_feature_flags_t ((unsigned int) (l) | (unsigned int) (r)))
 
 
+struct hb_ot_map_feature_t
+{
+  hb_tag_t tag;
+  hb_ot_map_feature_flags_t flags;
+};
+
+struct hb_ot_shape_plan_key_t;
+
 struct hb_ot_map_builder_t
 {
   public:
 
   HB_INTERNAL hb_ot_map_builder_t (hb_face_t *face_,
                                    const hb_segment_properties_t *props_);
 
-  HB_INTERNAL ~hb_ot_map_builder_t (void);
+  HB_INTERNAL ~hb_ot_map_builder_t ();
+
+  HB_INTERNAL void add_feature (hb_tag_t tag,
+                                hb_ot_map_feature_flags_t flags=F_NONE,
+                                unsigned int value=1);
+
+  void add_feature (const hb_ot_map_feature_t &feat)
+  { add_feature (feat.tag, feat.flags); }
 
-  HB_INTERNAL void add_feature (hb_tag_t tag, unsigned int value,
-                                hb_ot_map_feature_flags_t flags);
+  void enable_feature (hb_tag_t tag,
+                              hb_ot_map_feature_flags_t flags=F_NONE,
+                              unsigned int value=1)
+  { add_feature (tag, F_GLOBAL | flags, value); }
 
-  inline void add_global_bool_feature (hb_tag_t tag)
-  { add_feature (tag, 1, F_GLOBAL); }
+  void disable_feature (hb_tag_t tag)
+  { add_feature (tag, F_GLOBAL, 0); }
 
-  inline void add_gsub_pause (hb_ot_map_t::pause_func_t pause_func)
+  void add_gsub_pause (hb_ot_map_t::pause_func_t pause_func)
   { add_pause (0, pause_func); }
-  inline void add_gpos_pause (hb_ot_map_t::pause_func_t pause_func)
+  void add_gpos_pause (hb_ot_map_t::pause_func_t pause_func)
   { add_pause (1, pause_func); }
 
   HB_INTERNAL void compile (hb_ot_map_t  &m,
-                            const int    *coords,
-                            unsigned int  num_coords);
+                            const hb_ot_shape_plan_key_t &key);
 
   private:
 
   HB_INTERNAL void add_lookups (hb_ot_map_t  &m,
                                 unsigned int  table_index,
                                 unsigned int  feature_index,
                                 unsigned int  variations_index,
                                 hb_mask_t     mask,
                                 bool          auto_zwnj = true,
-                                bool          auto_zwj = true);
+                                bool          auto_zwj = true,
+                                bool          random = false);
 
   struct feature_info_t {
     hb_tag_t tag;
     unsigned int seq; /* sequence#, used for stable sorting only */
     unsigned int max_value;

@@ -242,12 +273,12 @@
   unsigned int script_index[2], language_index[2];
 
   private:
 
   unsigned int current_stage[2]; /* GSUB/GPOS */
-  hb_vector_t<feature_info_t, 32> feature_infos;
-  hb_vector_t<stage_info_t, 8> stages[2]; /* GSUB/GPOS */
+  hb_vector_t<feature_info_t> feature_infos;
+  hb_vector_t<stage_info_t> stages[2]; /* GSUB/GPOS */
 };
 
 
 
-#endif /* HB_OT_MAP_PRIVATE_HH */
+#endif /* HB_OT_MAP_HH */
< prev index next >