[HarfBuzz] harfbuzz: Branch 'master' - 3 commits

Behdad Esfahbod behdad at kemper.freedesktop.org
Wed Feb 8 22:36:39 UTC 2017


 src/hb-graphite2.cc |   45 ++++++++++++++++++---------------------------
 src/hb-graphite2.h  |    4 ++++
 2 files changed, 22 insertions(+), 27 deletions(-)

New commits:
commit c8dfed8e1ee4ab64b6936f5c8561db0666e37647
Merge: 7c47474 b435c7c
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Feb 8 14:36:18 2017 -0800

    Merge pull request #357 from khaledhosny/graphite-scale
    
    [graphite] Fix shaping with varying font sizes

commit b435c7c46a46350771e837e87fee448fd9dc06d3
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Fri Nov 11 02:16:39 2016 +0200

    [graphite] Stop creating unused gr_face
    
    It is unused after previous commit, hb_graphite2_font_get_gr_font()
    makes no sense now so deprecating it.

diff --git a/src/hb-graphite2.cc b/src/hb-graphite2.cc
index dc87795..f253a5f 100644
--- a/src/hb-graphite2.cc
+++ b/src/hb-graphite2.cc
@@ -27,7 +27,6 @@
  */
 
 #define HB_SHAPER graphite2
-#define hb_graphite2_shaper_font_data_t gr_font
 #include "hb-shaper-impl-private.hh"
 
 #include "hb-graphite2.h"
@@ -153,27 +152,17 @@ hb_graphite2_face_get_gr_face (hb_face_t *face)
  * shaper font data
  */
 
-static float hb_graphite2_get_advance (const void *hb_font, unsigned short gid)
-{
-  return ((hb_font_t *) hb_font)->get_glyph_h_advance (gid);
-}
+struct hb_graphite2_shaper_font_data_t {};
 
 hb_graphite2_shaper_font_data_t *
-_hb_graphite2_shaper_font_data_create (hb_font_t *font)
+_hb_graphite2_shaper_font_data_create (hb_font_t *font HB_UNUSED)
 {
-  if (unlikely (!hb_graphite2_shaper_face_data_ensure (font->face))) return NULL;
-
-  hb_face_t *face = font->face;
-  unsigned int upem = hb_face_get_upem (face);
-  hb_graphite2_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face);
-
-  return gr_make_font_with_advance_fn (upem, font, &hb_graphite2_get_advance, face_data->grface);
+  return (hb_graphite2_shaper_font_data_t *) HB_SHAPER_DATA_SUCCEEDED;
 }
 
 void
-_hb_graphite2_shaper_font_data_destroy (hb_graphite2_shaper_font_data_t *data)
+_hb_graphite2_shaper_font_data_destroy (hb_graphite2_shaper_font_data_t *data HB_UNUSED)
 {
-  gr_font_destroy (data);
 }
 
 /*
@@ -182,8 +171,7 @@ _hb_graphite2_shaper_font_data_destroy (hb_graphite2_shaper_font_data_t *data)
 gr_font *
 hb_graphite2_font_get_gr_font (hb_font_t *font)
 {
-  if (unlikely (!hb_graphite2_shaper_font_data_ensure (font))) return NULL;
-  return HB_SHAPER_DATA_GET (font);
+  return NULL;
 }
 
 
diff --git a/src/hb-graphite2.h b/src/hb-graphite2.h
index 122c3e4..82b1e64 100644
--- a/src/hb-graphite2.h
+++ b/src/hb-graphite2.h
@@ -39,9 +39,13 @@ HB_BEGIN_DECLS
 HB_EXTERN gr_face *
 hb_graphite2_face_get_gr_face (hb_face_t *face);
 
+#ifndef HB_DISABLE_DEPRECATED
+
 HB_EXTERN gr_font *
 hb_graphite2_font_get_gr_font (hb_font_t *font);
 
+#endif
+
 
 HB_END_DECLS
 
commit 1b00a3b0488a5d1c6ede141ae0545e2eb9af0ed8
Author: Khaled Hosny <khaledhosny at eglug.org>
Date:   Sun Oct 30 20:16:41 2016 +0200

    [graphite] Fix shaping with varying font sizes
    
    Shape using design units and scale the output.
    
    See https://bugs.documentfoundation.org/show_bug.cgi?id=103403#c7

diff --git a/src/hb-graphite2.cc b/src/hb-graphite2.cc
index a2d90db..dc87795 100644
--- a/src/hb-graphite2.cc
+++ b/src/hb-graphite2.cc
@@ -164,9 +164,10 @@ _hb_graphite2_shaper_font_data_create (hb_font_t *font)
   if (unlikely (!hb_graphite2_shaper_face_data_ensure (font->face))) return NULL;
 
   hb_face_t *face = font->face;
+  unsigned int upem = hb_face_get_upem (face);
   hb_graphite2_shaper_face_data_t *face_data = HB_SHAPER_DATA_GET (face);
 
-  return gr_make_font_with_advance_fn (font->x_scale, font, &hb_graphite2_get_advance, face_data->grface);
+  return gr_make_font_with_advance_fn (upem, font, &hb_graphite2_get_advance, face_data->grface);
 }
 
 void
@@ -230,7 +231,6 @@ _hb_graphite2_shape (hb_shape_plan_t    *shape_plan,
 {
   hb_face_t *face = font->face;
   gr_face *grface = HB_SHAPER_DATA_GET (face)->grface;
-  gr_font *grfont = HB_SHAPER_DATA_GET (font);
 
   const char *lang = hb_language_to_string (hb_buffer_get_language (buffer));
   const char *lang_end = lang ? strchr (lang, '-') : NULL;
@@ -262,7 +262,7 @@ _hb_graphite2_shape (hb_shape_plan_t    *shape_plan,
   hb_tag_t script_tag[2];
   hb_ot_tags_from_script (hb_buffer_get_script (buffer), &script_tag[0], &script_tag[1]);
 
-  seg = gr_make_seg (grfont, grface,
+  seg = gr_make_seg (NULL, grface,
 		     script_tag[1] == HB_TAG_NONE ? script_tag[0] : script_tag[1],
 		     feats,
 		     gr_utf32, chars, buffer->len,
@@ -373,7 +373,10 @@ _hb_graphite2_shape (hb_shape_plan_t    *shape_plan,
   }
   buffer->len = glyph_count;
 
-  float yscale = font->y_scale / font->x_scale;
+  unsigned int upem = hb_face_get_upem (face);
+  float xscale = (float) font->x_scale / upem;
+  float yscale = (float) font->y_scale / upem;
+  yscale *= yscale / xscale;
   /* Positioning. */
   if (!HB_DIRECTION_IS_BACKWARD(buffer->props.direction))
   {
@@ -383,16 +386,16 @@ _hb_graphite2_shape (hb_shape_plan_t    *shape_plan,
     curradvx = 0;
     for (is = gr_seg_first_slot (seg); is; pPos++, ++info, is = gr_slot_next_in_segment (is))
     {
-      pPos->x_offset = gr_slot_origin_X (is) - curradvx;
+      pPos->x_offset = gr_slot_origin_X (is) * xscale - curradvx;
       pPos->y_offset = gr_slot_origin_Y (is) * yscale - curradvy;
       if (info->cluster != currclus) {
-        pPos->x_advance = info->var1.i32;
+        pPos->x_advance = info->var1.i32 * xscale;
         curradvx += pPos->x_advance;
         currclus = info->cluster;
       } else
         pPos->x_advance = 0.;
 
-      pPos->y_advance = gr_slot_advance_Y (is, grface, grfont) * yscale;
+      pPos->y_advance = gr_slot_advance_Y (is, grface, NULL) * yscale;
       curradvy += pPos->y_advance;
     }
   }
@@ -401,20 +404,20 @@ _hb_graphite2_shape (hb_shape_plan_t    *shape_plan,
     int currclus = -1;
     const hb_glyph_info_t *info = buffer->info;
     hb_glyph_position_t *pPos = hb_buffer_get_glyph_positions (buffer, NULL);
-    curradvx = gr_seg_advance_X(seg);
+    curradvx = gr_seg_advance_X(seg) * xscale;
     for (is = gr_seg_first_slot (seg); is; pPos++, info++, is = gr_slot_next_in_segment (is))
     {
       if (info->cluster != currclus)
       {
-        pPos->x_advance = info->var1.i32;
-        if (currclus != -1) curradvx -= info[-1].var1.i32;
+        pPos->x_advance = info->var1.i32 * xscale;
+        if (currclus != -1) curradvx -= info[-1].var1.i32 * xscale;
         currclus = info->cluster;
       } else
       pPos->x_advance = 0.;
 
-      pPos->y_advance = gr_slot_advance_Y (is, grface, grfont) * yscale;
+      pPos->y_advance = gr_slot_advance_Y (is, grface, NULL) * yscale;
       curradvy -= pPos->y_advance;
-      pPos->x_offset = gr_slot_origin_X (is) - curradvx + pPos->x_advance;
+      pPos->x_offset = gr_slot_origin_X (is) * xscale - curradvx + pPos->x_advance;
       pPos->y_offset = gr_slot_origin_Y (is) * yscale - curradvy;
     }
     hb_buffer_reverse_clusters (buffer);


More information about the HarfBuzz mailing list