[GX] Towards anisotropic interpolation
authorBehdad Esfahbod <behdad@behdad.org>
Tue, 1 Mar 2016 10:29:36 +0000 (19:29 +0900)
committerBehdad Esfahbod <behdad@behdad.org>
Sat, 17 Dec 2016 01:06:26 +0000 (19:06 -0600)
Also hookup to ValueRecord and Anchors.

src/hb-font-private.hh
src/hb-font.cc
src/hb-ot-layout-common-private.hh
src/hb-ot-layout-gpos-table.hh

index 3a1e31f..48dc725 100644 (file)
@@ -109,8 +109,9 @@ struct hb_font_t {
   unsigned int y_ppem;
 
   /* Font variation coordinates. */
-  int *coords;
-  unsigned int coord_count;
+  unsigned int num_coords;
+  int *x_coords;
+  int *y_coords;
 
   hb_font_funcs_t   *klass;
   void              *user_data;
index b4b4d0a..75c8515 100644 (file)
@@ -1165,6 +1165,8 @@ hb_font_create_sub_font (hb_font_t *parent)
   font->x_ppem = parent->x_ppem;
   font->y_ppem = parent->y_ppem;
 
+  /* TODO: copy variation coordinates. */
+
   return font;
 }
 
@@ -1194,8 +1196,9 @@ hb_font_get_empty (void)
     0, /* x_ppem */
     0, /* y_ppem */
 
-    NULL, /* coords */
-    0, /* coord_count */
+    0, /* num_coords */
+    NULL, /* x_coords */
+    NULL, /* y_coords */
 
     const_cast<hb_font_funcs_t *> (&_hb_font_funcs_nil), /* klass */
     NULL, /* user_data */
@@ -1251,6 +1254,8 @@ hb_font_destroy (hb_font_t *font)
   hb_face_destroy (font->face);
   hb_font_funcs_destroy (font->klass);
 
+  /* TODO: destroy variation coordinates. */
+
   free (font);
 }
 
index a18ce74..cd26db3 100644 (file)
@@ -1315,10 +1315,10 @@ struct VariationDevice
 {
 
   inline hb_position_t get_x_delta (hb_font_t *font) const
-  { return font->em_scalef_x (get_delta (font->coords, font->coord_count)); }
+  { return font->em_scalef_x (get_delta (font->x_coords, font->num_coords)); }
 
   inline hb_position_t get_y_delta (hb_font_t *font) const
-  { return font->em_scalef_y (get_delta (font->coords, font->coord_count)); }
+  { return font->em_scalef_y (get_delta (font->y_coords, font->num_coords)); }
 
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
index bbe390c..424a34e 100644 (file)
@@ -109,7 +109,6 @@ struct ValueFormat : USHORT
                    const Value          *values,
                    hb_glyph_position_t  &glyph_pos) const
   {
-    unsigned int x_ppem, y_ppem;
     unsigned int format = *this;
     hb_bool_t horizontal = HB_DIRECTION_IS_HORIZONTAL (direction);
 
@@ -129,27 +128,28 @@ struct ValueFormat : USHORT
 
     if (!has_device ()) return;
 
-    x_ppem = font->x_ppem;
-    y_ppem = font->y_ppem;
+    bool use_x_device = font->x_ppem || font->num_coords;
+    bool use_y_device = font->y_ppem || font->num_coords;
 
-    if (!x_ppem && !y_ppem) return;
+
+    if (!use_x_device && !use_y_device) return;
 
     /* pixel -> fractional pixel */
     if (format & xPlaDevice) {
-      if (x_ppem) glyph_pos.x_offset  += (base + get_device (values)).get_x_delta (font);
+      if (use_x_device) glyph_pos.x_offset  += (base + get_device (values)).get_x_delta (font);
       values++;
     }
     if (format & yPlaDevice) {
-      if (y_ppem) glyph_pos.y_offset  += (base + get_device (values)).get_y_delta (font);
+      if (use_y_device) glyph_pos.y_offset  += (base + get_device (values)).get_y_delta (font);
       values++;
     }
     if (format & xAdvDevice) {
-      if (horizontal && x_ppem) glyph_pos.x_advance += (base + get_device (values)).get_x_delta (font);
+      if (horizontal && use_x_device) glyph_pos.x_advance += (base + get_device (values)).get_x_delta (font);
       values++;
     }
     if (format & yAdvDevice) {
       /* y_advance values grow downward but font-space grows upward, hence negation */
-      if (!horizontal && y_ppem) glyph_pos.y_advance -= (base + get_device (values)).get_y_delta (font);
+      if (!horizontal && use_y_device) glyph_pos.y_advance -= (base + get_device (values)).get_y_delta (font);
       values++;
     }
   }
@@ -291,9 +291,9 @@ struct AnchorFormat3
       *x = font->em_scale_x (xCoordinate);
       *y = font->em_scale_y (yCoordinate);
 
-      if (font->x_ppem)
+      if (font->x_ppem || font->num_coords)
        *x += (this+xDeviceTable).get_x_delta (font);
-      if (font->y_ppem)
+      if (font->y_ppem || font->num_coords)
        *y += (this+yDeviceTable).get_x_delta (font);
   }