Imported Upstream version 8.2.2
[platform/upstream/harfbuzz.git] / src / hb-ot-shaper.hh
similarity index 84%
rename from src/hb-ot-shape-complex.hh
rename to src/hb-ot-shaper.hh
index 8012a9a..0207b2b 100644 (file)
@@ -24,8 +24,8 @@
  * Google Author(s): Behdad Esfahbod
  */
 
-#ifndef HB_OT_SHAPE_COMPLEX_HH
-#define HB_OT_SHAPE_COMPLEX_HH
+#ifndef HB_OT_SHAPER_HH
+#define HB_OT_SHAPER_HH
 
 #include "hb.hh"
 
 #include "hb-ot-shape-normalize.hh"
 
 
-/* buffer var allocations, used by complex shapers */
-#define complex_var_u8_category()      var2.u8[2]
-#define complex_var_u8_auxiliary()     var2.u8[3]
+/* buffer var allocations, used by all OT shapers */
+#define ot_shaper_var_u8_category()    var2.u8[2]
+#define ot_shaper_var_u8_auxiliary()   var2.u8[3]
 
 
-#define HB_OT_SHAPE_COMPLEX_MAX_COMBINING_MARKS 32
+#define HB_OT_SHAPE_MAX_COMBINING_MARKS 32
 
 enum hb_ot_shape_zero_width_marks_type_t {
   HB_OT_SHAPE_ZERO_WIDTH_MARKS_NONE,
@@ -49,22 +49,22 @@ enum hb_ot_shape_zero_width_marks_type_t {
 
 
 /* Master OT shaper list */
-#define HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS \
-  HB_COMPLEX_SHAPER_IMPLEMENT (arabic) \
-  HB_COMPLEX_SHAPER_IMPLEMENT (default) \
-  HB_COMPLEX_SHAPER_IMPLEMENT (dumber) \
-  HB_COMPLEX_SHAPER_IMPLEMENT (hangul) \
-  HB_COMPLEX_SHAPER_IMPLEMENT (hebrew) \
-  HB_COMPLEX_SHAPER_IMPLEMENT (indic) \
-  HB_COMPLEX_SHAPER_IMPLEMENT (khmer) \
-  HB_COMPLEX_SHAPER_IMPLEMENT (myanmar) \
-  HB_COMPLEX_SHAPER_IMPLEMENT (myanmar_zawgyi) \
-  HB_COMPLEX_SHAPER_IMPLEMENT (thai) \
-  HB_COMPLEX_SHAPER_IMPLEMENT (use) \
+#define HB_OT_SHAPERS_IMPLEMENT_SHAPERS \
+  HB_OT_SHAPER_IMPLEMENT (arabic) \
+  HB_OT_SHAPER_IMPLEMENT (default) \
+  HB_OT_SHAPER_IMPLEMENT (dumber) \
+  HB_OT_SHAPER_IMPLEMENT (hangul) \
+  HB_OT_SHAPER_IMPLEMENT (hebrew) \
+  HB_OT_SHAPER_IMPLEMENT (indic) \
+  HB_OT_SHAPER_IMPLEMENT (khmer) \
+  HB_OT_SHAPER_IMPLEMENT (myanmar) \
+  HB_OT_SHAPER_IMPLEMENT (myanmar_zawgyi) \
+  HB_OT_SHAPER_IMPLEMENT (thai) \
+  HB_OT_SHAPER_IMPLEMENT (use) \
   /* ^--- Add new shapers here; keep sorted. */
 
 
-struct hb_ot_complex_shaper_t
+struct hb_ot_shaper_t
 {
   /* collect_features()
    * Called during shape_plan().
@@ -117,8 +117,6 @@ struct hb_ot_complex_shaper_t
                              hb_font_t                *font);
 
 
-  hb_ot_shape_normalization_mode_t normalization_preference;
-
   /* decompose()
    * Called during shape()'s normalization.
    * May be NULL.
@@ -147,12 +145,6 @@ struct hb_ot_complex_shaper_t
                       hb_buffer_t              *buffer,
                       hb_font_t                *font);
 
-  /* gpos_tag()
-   * If not HB_TAG_NONE, then must match found GPOS script tag for
-   * GPOS to be applied.  Otherwise, fallback positioning will be used.
-   */
-  hb_tag_t gpos_tag;
-
   /* reorder_marks()
    * Called during shape().
    * Shapers can use to modify ordering of combining marks.
@@ -163,23 +155,31 @@ struct hb_ot_complex_shaper_t
                         unsigned int              start,
                         unsigned int              end);
 
+  /* gpos_tag()
+   * If not HB_TAG_NONE, then must match found GPOS script tag for
+   * GPOS to be applied.  Otherwise, fallback positioning will be used.
+   */
+  hb_tag_t gpos_tag;
+
+  hb_ot_shape_normalization_mode_t normalization_preference;
+
   hb_ot_shape_zero_width_marks_type_t zero_width_marks;
 
   bool fallback_position;
 };
 
-#define HB_COMPLEX_SHAPER_IMPLEMENT(name) extern HB_INTERNAL const hb_ot_complex_shaper_t _hb_ot_complex_shaper_##name;
-HB_COMPLEX_SHAPERS_IMPLEMENT_SHAPERS
-#undef HB_COMPLEX_SHAPER_IMPLEMENT
+#define HB_OT_SHAPER_IMPLEMENT(name) extern HB_INTERNAL const hb_ot_shaper_t _hb_ot_shaper_##name;
+HB_OT_SHAPERS_IMPLEMENT_SHAPERS
+#undef HB_OT_SHAPER_IMPLEMENT
 
 
-static inline const hb_ot_complex_shaper_t *
-hb_ot_shape_complex_categorize (const hb_ot_shape_planner_t *planner)
+static inline const hb_ot_shaper_t *
+hb_ot_shaper_categorize (const hb_ot_shape_planner_t *planner)
 {
   switch ((hb_tag_t) planner->props.script)
   {
     default:
-      return &_hb_ot_complex_shaper_default;
+      return &_hb_ot_shaper_default;
 
 
     /* Unicode-1.1 additions */
@@ -195,28 +195,28 @@ hb_ot_shape_complex_categorize (const hb_ot_shape_planner_t *planner)
       if ((planner->map.chosen_script[0] != HB_OT_TAG_DEFAULT_SCRIPT ||
           planner->props.script == HB_SCRIPT_ARABIC) &&
          HB_DIRECTION_IS_HORIZONTAL(planner->props.direction))
-       return &_hb_ot_complex_shaper_arabic;
+       return &_hb_ot_shaper_arabic;
       else
-       return &_hb_ot_complex_shaper_default;
+       return &_hb_ot_shaper_default;
 
 
     /* Unicode-1.1 additions */
     case HB_SCRIPT_THAI:
     case HB_SCRIPT_LAO:
 
-      return &_hb_ot_complex_shaper_thai;
+      return &_hb_ot_shaper_thai;
 
 
     /* Unicode-1.1 additions */
     case HB_SCRIPT_HANGUL:
 
-      return &_hb_ot_complex_shaper_hangul;
+      return &_hb_ot_shaper_hangul;
 
 
     /* Unicode-1.1 additions */
     case HB_SCRIPT_HEBREW:
 
-      return &_hb_ot_complex_shaper_hebrew;
+      return &_hb_ot_shaper_hebrew;
 
 
     /* Unicode-1.1 additions */
@@ -230,9 +230,6 @@ hb_ot_shape_complex_categorize (const hb_ot_shape_planner_t *planner)
     case HB_SCRIPT_TAMIL:
     case HB_SCRIPT_TELUGU:
 
-    /* Unicode-3.0 additions */
-    case HB_SCRIPT_SINHALA:
-
       /* If the designer designed the font for the 'DFLT' script,
        * (or we ended up arbitrarily pick 'latn'), use the default shaper.
        * Otherwise, use the specific shaper.
@@ -240,14 +237,14 @@ hb_ot_shape_complex_categorize (const hb_ot_shape_planner_t *planner)
        * If it's indy3 tag, send to USE. */
       if (planner->map.chosen_script[0] == HB_TAG ('D','F','L','T') ||
          planner->map.chosen_script[0] == HB_TAG ('l','a','t','n'))
-       return &_hb_ot_complex_shaper_default;
+       return &_hb_ot_shaper_default;
       else if ((planner->map.chosen_script[0] & 0x000000FF) == '3')
-       return &_hb_ot_complex_shaper_use;
+       return &_hb_ot_shaper_use;
       else
-       return &_hb_ot_complex_shaper_indic;
+       return &_hb_ot_shaper_indic;
 
     case HB_SCRIPT_KHMER:
-       return &_hb_ot_complex_shaper_khmer;
+       return &_hb_ot_shaper_khmer;
 
     case HB_SCRIPT_MYANMAR:
       /* If the designer designed the font for the 'DFLT' script,
@@ -260,16 +257,18 @@ hb_ot_shape_complex_categorize (const hb_ot_shape_planner_t *planner)
       if (planner->map.chosen_script[0] == HB_TAG ('D','F','L','T') ||
          planner->map.chosen_script[0] == HB_TAG ('l','a','t','n') ||
          planner->map.chosen_script[0] == HB_TAG ('m','y','m','r'))
-       return &_hb_ot_complex_shaper_default;
+       return &_hb_ot_shaper_default;
       else
-       return &_hb_ot_complex_shaper_myanmar;
+       return &_hb_ot_shaper_myanmar;
 
 
+#ifndef HB_NO_OT_SHAPER_MYANMAR_ZAWGYI
 #define HB_SCRIPT_MYANMAR_ZAWGYI       ((hb_script_t) HB_TAG ('Q','a','a','g'))
     case HB_SCRIPT_MYANMAR_ZAWGYI:
     /* https://github.com/harfbuzz/harfbuzz/issues/1162 */
 
-      return &_hb_ot_complex_shaper_myanmar_zawgyi;
+      return &_hb_ot_shaper_myanmar_zawgyi;
+#endif
 
 
     /* Unicode-2.0 additions */
@@ -277,7 +276,7 @@ hb_ot_shape_complex_categorize (const hb_ot_shape_planner_t *planner)
 
     /* Unicode-3.0 additions */
     case HB_SCRIPT_MONGOLIAN:
-    //case HB_SCRIPT_SINHALA:
+    case HB_SCRIPT_SINHALA:
 
     /* Unicode-3.2 additions */
     case HB_SCRIPT_BUHID:
@@ -383,6 +382,10 @@ hb_ot_shape_complex_categorize (const hb_ot_shape_planner_t *planner)
     case HB_SCRIPT_TOTO:
     case HB_SCRIPT_VITHKUQI:
 
+    /* Unicode-15.0 additions */
+    case HB_SCRIPT_KAWI:
+    case HB_SCRIPT_NAG_MUNDARI:
+
       /* If the designer designed the font for the 'DFLT' script,
        * (or we ended up arbitrarily pick 'latn'), use the default shaper.
        * Otherwise, use the specific shaper.
@@ -390,11 +393,11 @@ hb_ot_shape_complex_categorize (const hb_ot_shape_planner_t *planner)
        * GSUB/GPOS needed, so there may be no scripts found! */
       if (planner->map.chosen_script[0] == HB_TAG ('D','F','L','T') ||
          planner->map.chosen_script[0] == HB_TAG ('l','a','t','n'))
-       return &_hb_ot_complex_shaper_default;
+       return &_hb_ot_shaper_default;
       else
-       return &_hb_ot_complex_shaper_use;
+       return &_hb_ot_shaper_use;
   }
 }
 
 
-#endif /* HB_OT_SHAPE_COMPLEX_HH */
+#endif /* HB_OT_SHAPER_HH */