[Indic] Ra is a consonant too
[framework/uifw/harfbuzz.git] / src / hb-font-private.hh
index bd3000a..dd71b67 100644 (file)
@@ -41,6 +41,18 @@ HB_BEGIN_DECLS
  * hb_font_funcs_t
  */
 
+#define HB_FONT_FUNCS_IMPLEMENT_CALLBACKS \
+  HB_FONT_FUNC_IMPLEMENT (glyph) \
+  HB_FONT_FUNC_IMPLEMENT (glyph_h_advance) \
+  HB_FONT_FUNC_IMPLEMENT (glyph_v_advance) \
+  HB_FONT_FUNC_IMPLEMENT (glyph_h_origin) \
+  HB_FONT_FUNC_IMPLEMENT (glyph_v_origin) \
+  HB_FONT_FUNC_IMPLEMENT (glyph_h_kerning) \
+  HB_FONT_FUNC_IMPLEMENT (glyph_v_kerning) \
+  HB_FONT_FUNC_IMPLEMENT (glyph_extents) \
+  HB_FONT_FUNC_IMPLEMENT (glyph_contour_point) \
+  /* ^--- Add new callbacks here */
+
 struct _hb_font_funcs_t {
   hb_object_header_t header;
 
@@ -49,27 +61,21 @@ struct _hb_font_funcs_t {
   /* Don't access these directly.  Call hb_font_get_*() instead. */
 
   struct {
-    hb_font_get_contour_point_func_t   contour_point;
-    hb_font_get_glyph_advance_func_t   glyph_advance;
-    hb_font_get_glyph_extents_func_t   glyph_extents;
-    hb_font_get_glyph_func_t           glyph;
-    hb_font_get_kerning_func_t         kerning;
+#define HB_FONT_FUNC_IMPLEMENT(name) hb_font_get_##name##_func_t name;
+    HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
+#undef HB_FONT_FUNC_IMPLEMENT
   } get;
 
   struct {
-    void                               *contour_point;
-    void                               *glyph_advance;
-    void                               *glyph_extents;
-    void                               *glyph;
-    void                               *kerning;
+#define HB_FONT_FUNC_IMPLEMENT(name) void *name;
+    HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
+#undef HB_FONT_FUNC_IMPLEMENT
   } user_data;
 
   struct {
-    hb_destroy_func_t                  contour_point;
-    hb_destroy_func_t                  glyph_advance;
-    hb_destroy_func_t                  glyph_extents;
-    hb_destroy_func_t                  glyph;
-    hb_destroy_func_t                  kerning;
+#define HB_FONT_FUNC_IMPLEMENT(name) hb_destroy_func_t name;
+    HB_FONT_FUNCS_IMPLEMENT_CALLBACKS
+#undef HB_FONT_FUNC_IMPLEMENT
   } destroy;
 };
 
@@ -81,6 +87,8 @@ struct _hb_font_funcs_t {
 struct _hb_face_t {
   hb_object_header_t header;
 
+  hb_bool_t immutable;
+
   hb_get_table_func_t  get_table;
   void                *user_data;
   hb_destroy_func_t    destroy;
@@ -115,11 +123,39 @@ struct _hb_font_t {
 
 
   /* Convert from font-space to user-space */
-  inline hb_position_t scale_x (int16_t v) { return scale (v, this->x_scale); }
-  inline hb_position_t scale_y (int16_t v) { return scale (v, this->y_scale); }
+  inline hb_position_t em_scale_x (int16_t v) { return em_scale (v, this->x_scale); }
+  inline hb_position_t em_scale_y (int16_t v) { return em_scale (v, this->y_scale); }
+
+  /* Convert from parent-font user-space to our user-space */
+  inline hb_position_t parent_scale_x_distance (hb_position_t v) {
+    if (unlikely (parent && parent->x_scale != x_scale))
+      return v * (int64_t) this->x_scale / this->parent->x_scale;
+    return v;
+  }
+  inline hb_position_t parent_scale_y_distance (hb_position_t v) {
+    if (unlikely (parent && parent->y_scale != y_scale))
+      return v * (int64_t) this->y_scale / this->parent->y_scale;
+    return v;
+  }
+  inline hb_position_t parent_scale_x_position (hb_position_t v) {
+    return parent_scale_x_distance (v);
+  }
+  inline hb_position_t parent_scale_y_position (hb_position_t v) {
+    return parent_scale_y_distance (v);
+  }
+
+  inline void parent_scale_distance (hb_position_t *x, hb_position_t *y) {
+    *x = parent_scale_x_distance (*x);
+    *y = parent_scale_y_distance (*y);
+  }
+  inline void parent_scale_position (hb_position_t *x, hb_position_t *y) {
+    *x = parent_scale_x_position (*x);
+    *y = parent_scale_y_position (*y);
+  }
+
 
   private:
-  inline hb_position_t scale (int16_t v, int scale) { return v * (int64_t) scale / this->face->upem; }
+  inline hb_position_t em_scale (int16_t v, int scale) { return v * (int64_t) scale / this->face->upem; }
 };