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

Behdad Esfahbod behdad at kemper.freedesktop.org
Fri Nov 30 05:02:22 PST 2012


 src/Makefile.am                                                                    |   10 -
 src/hb-buffer.cc                                                                   |    4 
 src/hb-ot-layout-gpos-table.hh                                                     |    4 
 src/hb-ot-layout-gsub-table.hh                                                     |    4 
 src/hb-ot-layout-gsubgpos-private.hh                                               |   11 -
 src/hb-ot-layout.cc                                                                |   23 --
 src/hb-ot-layout.h                                                                 |    7 
 src/test-size-params.cc                                                            |   98 ++++++++++
 test/shaping/texts/in-tree/shaper-arabic/script-arabic/MANIFEST                    |    1 
 test/shaping/texts/in-tree/shaper-arabic/script-arabic/language-persian/MANIFEST   |    1 
 test/shaping/texts/in-tree/shaper-arabic/script-arabic/language-persian/mehran.txt |    8 
 11 files changed, 137 insertions(+), 34 deletions(-)

New commits:
commit 4ab99fb8c363cfc6a4f5952e69a19757f0cab344
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Nov 30 15:02:04 2012 +0200

    Minor

diff --git a/src/hb-ot-layout.h b/src/hb-ot-layout.h
index 8999eaf..f8fab24 100644
--- a/src/hb-ot-layout.h
+++ b/src/hb-ot-layout.h
@@ -278,7 +278,7 @@ Xhb_ot_layout_lookup_position (hb_font_t            *font,
 #endif
 
 /* Optical 'size' feature info.  Returns true if found.
- * XXX Add URL. */
+ * http://www.microsoft.com/typography/otspec/features_pt.htm#size */
 hb_bool_t
 hb_ot_layout_get_size_params (hb_face_t *face,
 			      uint16_t  *data /* OUT, 5 items */);
commit 6748b96d27477b35dd69129e55d861259d66bf9f
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Nov 30 12:02:21 2012 +0200

    Minor

diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index df5c836..441b3ea 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -33,7 +33,6 @@
 #include "hb-ot-layout-gdef-table.hh"
 #include "hb-ot-layout-gsub-table.hh"
 #include "hb-ot-layout-gpos-table.hh"
-#include "hb-ot-maxp-table.hh"
 
 #include <stdlib.h>
 #include <string.h>
commit 624933f67642997ee0a46d5acea285362e837142
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Nov 30 11:46:35 2012 +0200

    Add Persian test cases from Mehran Mehr

diff --git a/test/shaping/texts/in-tree/shaper-arabic/script-arabic/MANIFEST b/test/shaping/texts/in-tree/shaper-arabic/script-arabic/MANIFEST
index 28f10bc..62e050d 100644
--- a/test/shaping/texts/in-tree/shaper-arabic/script-arabic/MANIFEST
+++ b/test/shaping/texts/in-tree/shaper-arabic/script-arabic/MANIFEST
@@ -1,2 +1,3 @@
+language-persian
 language-urdu
 misc
diff --git a/test/shaping/texts/in-tree/shaper-arabic/script-arabic/language-persian/MANIFEST b/test/shaping/texts/in-tree/shaper-arabic/script-arabic/language-persian/MANIFEST
new file mode 100644
index 0000000..a6ac235
--- /dev/null
+++ b/test/shaping/texts/in-tree/shaper-arabic/script-arabic/language-persian/MANIFEST
@@ -0,0 +1 @@
+mehran.txt
diff --git a/test/shaping/texts/in-tree/shaper-arabic/script-arabic/language-persian/mehran.txt b/test/shaping/texts/in-tree/shaper-arabic/script-arabic/language-persian/mehran.txt
new file mode 100755
index 0000000..4be0786
--- /dev/null
+++ b/test/shaping/texts/in-tree/shaper-arabic/script-arabic/language-persian/mehran.txt
@@ -0,0 +1,8 @@
+‫دَر فارسی گَچْ‌پَژْ هست. این «ی» فارسی است.‬
+‫حرف «ع» را به چٰهار شکلِ «ع‍» و «‍ع‍» و «‍ع» و «‌ع‌» می‌توان نشان داد.‬
+‫تشخیصِ اِعْ‌ًٌَُراب ناهمخوان از وظایف حروفْ‌چین است.‬
+‫دو اِعراب همخوان مانند « َ» و « ّ» به شکل « َّ» باهم ترکیب می‌شوند.‬
+‫لازم است حروف‌چین رفتار درستی با کشیدهٔ یونی‌کدی داشته باشد.‬
+‫مثلاً بتواند کلـمهٔ «پیِٓـــــــچ» یا حروف «ــٖٓـ» را به درستی نمایش دهد.‬
+‫حرف «لام» و «الف» باید به شکل لیگاتوری نمایش داده شوند.‬
+‫کلمهٔ «بَلَاٰ» از آزمون‌های سطح پائین حروف‌چین است.‬
\ No newline at end of file
commit 0f3f5299047e3cfc4d1202fee83d484b871279ad
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Nov 30 09:06:59 2012 +0200

    Add test-size-params
    
    Eventually this will become part of a yet-to-be-written hb-ot cmdline
    tool.

diff --git a/src/Makefile.am b/src/Makefile.am
index bb7601e..b7896bf 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -247,17 +247,25 @@ $(srcdir)/hb-ot-shape-complex-indic-machine.hh: hb-ot-shape-complex-indic-machin
 	$(AM_V_GEN)$(top_srcdir)/missing --run ragel -e -F1 -o "$@.tmp" "$<" && \
 	mv "$@.tmp" "$@" || ( $(RM) "$@.tmp" && false )
 
-noinst_PROGRAMS = main test-would-substitute
+noinst_PROGRAMS = main test test-would-substitute test-size-params
 bin_PROGRAMS =
 
 main_SOURCES = main.cc
 main_CPPFLAGS = $(HBCFLAGS)
 main_LDADD = libharfbuzz.la $(HBLIBS)
 
+test_SOURCES = test.cc
+test_CPPFLAGS = $(HBCFLAGS) $(FREETYPE_CFLAGS)
+test_LDADD = libharfbuzz.la $(HBLIBS) $(FREETYPE_LIBS)
+
 test_would_substitute_SOURCES = test-would-substitute.cc
 test_would_substitute_CPPFLAGS = $(HBCFLAGS) $(FREETYPE_CFLAGS)
 test_would_substitute_LDADD = libharfbuzz.la $(HBLIBS) $(FREETYPE_LIBS)
 
+test_size_params_SOURCES = test-size-params.cc
+test_size_params_CPPFLAGS = $(HBCFLAGS)
+test_size_params_LDADD = libharfbuzz.la $(HBLIBS)
+
 dist_check_SCRIPTS = \
 	check-c-linkage-decls.sh \
 	check-header-guards.sh \
diff --git a/src/test-size-params.cc b/src/test-size-params.cc
new file mode 100644
index 0000000..a60aa10
--- /dev/null
+++ b/src/test-size-params.cc
@@ -0,0 +1,98 @@
+/*
+ * Copyright © 2010,2011  Google, Inc.
+ *
+ *  This is part of HarfBuzz, a text shaping library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Google Author(s): Behdad Esfahbod
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "hb.h"
+#include "hb-ot.h"
+
+#ifdef HAVE_GLIB
+#include <glib.h>
+#endif
+#include <stdlib.h>
+#include <stdio.h>
+
+int
+main (int argc, char **argv)
+{
+  hb_blob_t *blob = NULL;
+
+  if (argc != 2) {
+    fprintf (stderr, "usage: %s font-file\n", argv[0]);
+    exit (1);
+  }
+
+  /* Create the blob */
+  {
+    const char *font_data;
+    unsigned int len;
+    hb_destroy_func_t destroy;
+    void *user_data;
+    hb_memory_mode_t mm;
+
+#ifdef HAVE_GLIB
+    GMappedFile *mf = g_mapped_file_new (argv[1], false, NULL);
+    font_data = g_mapped_file_get_contents (mf);
+    len = g_mapped_file_get_length (mf);
+    destroy = (hb_destroy_func_t) g_mapped_file_unref;
+    user_data = (void *) mf;
+    mm = HB_MEMORY_MODE_READONLY_MAY_MAKE_WRITABLE;
+#else
+    FILE *f = fopen (argv[1], "rb");
+    fseek (f, 0, SEEK_END);
+    len = ftell (f);
+    fseek (f, 0, SEEK_SET);
+    font_data = (const char *) malloc (len);
+    if (!font_data) len = 0;
+    len = fread ((char *) font_data, 1, len, f);
+    destroy = free;
+    user_data = (void *) font_data;
+    fclose (f);
+    mm = HB_MEMORY_MODE_WRITABLE;
+#endif
+
+    blob = hb_blob_create (font_data, len, mm, user_data, destroy);
+  }
+
+  /* Create the face */
+  hb_face_t *face = hb_face_create (blob, 0 /* first face */);
+  hb_blob_destroy (blob);
+  blob = NULL;
+
+  uint16_t params[5];
+  if (!hb_ot_layout_get_size_params (face, params))
+    return 1;
+
+  for (unsigned int i = 0; i < 5; i++) {
+    if (i) printf (" ");
+    printf ("%u", params[i]);
+  }
+  printf ("\n");
+
+  return 0;
+}
commit 8465a05a89742295d4b009a9b4442eb0a899fd80
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Nov 30 08:46:43 2012 +0200

    Fix hb_buffer_guess_segment_properties() for empty buffer
    
    Was causing assertion failure in shape_plan().

diff --git a/src/hb-buffer.cc b/src/hb-buffer.cc
index 0f5a97f..0a5600b 100644
--- a/src/hb-buffer.cc
+++ b/src/hb-buffer.cc
@@ -493,8 +493,8 @@ hb_buffer_t::merge_out_clusters (unsigned int start,
 void
 hb_buffer_t::guess_segment_properties (void)
 {
-  if (unlikely (!len)) return;
-  assert (content_type == HB_BUFFER_CONTENT_TYPE_UNICODE);
+  assert (content_type == HB_BUFFER_CONTENT_TYPE_UNICODE ||
+	  (!len && content_type == HB_BUFFER_CONTENT_TYPE_INVALID));
 
   /* If script is set to INVALID, guess from buffer contents */
   if (props.script == HB_SCRIPT_INVALID) {
commit e75943de803f571b7ad2cf2f777119753a209656
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Nov 30 08:38:24 2012 +0200

    [OTLayout] Fix collect_glyphs() recursion in ContextFormat3

diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index fe4dcbc..7bf3e71 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -1269,7 +1269,7 @@ struct ContextFormat3
     const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverage, coverage[0].static_size * glyphCount);
     struct ContextCollectGlyphsLookupContext lookup_context = {
       {collect_coverage},
-      NULL
+      this
     };
 
     context_collect_glyphs_lookup (c,
commit 3038ae6adbb61e55d6c665dea0c5271e0c9f0ed8
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Nov 30 08:24:13 2012 +0200

    [OTLayout] Minor

diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh
index 8f0d38f..5ec7e07 100644
--- a/src/hb-ot-layout-gpos-table.hh
+++ b/src/hb-ot-layout-gpos-table.hh
@@ -1521,10 +1521,6 @@ struct GPOS : GSUBGPOS
   inline const PosLookup& get_lookup (unsigned int i) const
   { return CastR<PosLookup> (GSUBGPOS::get_lookup (i)); }
 
-  template <typename set_t>
-  inline void add_coverage (set_t *glyphs, unsigned int lookup_index) const
-  { get_lookup (lookup_index).add_coverage (glyphs); }
-
   static inline void position_start (hb_font_t *font, hb_buffer_t *buffer);
   static inline void position_finish (hb_font_t *font, hb_buffer_t *buffer, hb_bool_t zero_width_attahced_marks);
 
diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh
index 373cf69..69572ef 100644
--- a/src/hb-ot-layout-gsub-table.hh
+++ b/src/hb-ot-layout-gsub-table.hh
@@ -1341,10 +1341,6 @@ struct GSUB : GSUBGPOS
   inline const SubstLookup& get_lookup (unsigned int i) const
   { return CastR<SubstLookup> (GSUBGPOS::get_lookup (i)); }
 
-  template <typename set_t>
-  inline void add_coverage (set_t *glyphs, unsigned int lookup_index) const
-  { get_lookup (lookup_index).add_coverage (glyphs); }
-
   static inline void substitute_start (hb_font_t *font, hb_buffer_t *buffer);
   static inline void substitute_finish (hb_font_t *font, hb_buffer_t *buffer);
 
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 5accbcf..df5c836 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -71,9 +71,9 @@ _hb_ot_layout_create (hb_face_t *face)
   }
 
   for (unsigned int i = 0; i < layout->gsub_lookup_count; i++)
-    layout->gsub->add_coverage (&layout->gsub_digests[i], i);
+    layout->gsub->get_lookup (i).add_coverage (&layout->gsub_digests[i]);
   for (unsigned int i = 0; i < layout->gpos_lookup_count; i++)
-    layout->gpos->add_coverage (&layout->gpos_digests[i], i);
+    layout->gpos->get_lookup (i).add_coverage (&layout->gpos_digests[i]);
 
   return layout;
 }
commit 0dff11f6bfbda444a153ca75ff2b947f94e9b3c5
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Nov 30 08:14:20 2012 +0200

    [OTLayout] Look for any 'size' feature, not only in DFLT script
    
    The old code doesn't work with all fonts, as Khaled has reported.

diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 879266d..5accbcf 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -645,17 +645,13 @@ hb_ot_layout_get_size_params (hb_face_t *face,
 			      uint16_t  *data /* OUT, 5 items */)
 {
   const OT::GPOS &gpos = _get_gpos (face);
-  unsigned int script_index;
-  gpos.find_script_index (HB_OT_TAG_DEFAULT_SCRIPT, &script_index);
-  const OT::LangSys &l = gpos.get_script (script_index).get_lang_sys (HB_OT_TAG_DEFAULT_LANGUAGE);
 
-  unsigned int num_features = l.get_feature_count ();
-  for (unsigned int i = 0; i < num_features; i++) {
-    unsigned int f_index = l.get_feature_index (i);
-
-    if (HB_TAG ('s','i','z','e') == gpos.get_feature_tag (f_index))
+  unsigned int num_features = gpos.get_feature_count ();
+  for (unsigned int i = 0; i < num_features; i++)
+  {
+    if (HB_TAG ('s','i','z','e') == gpos.get_feature_tag (i))
     {
-      const OT::Feature &f = gpos.get_feature (f_index);
+      const OT::Feature &f = gpos.get_feature (i);
       const OT::FeatureParams &params = f.get_feature_params ();
 
       for (unsigned int i = 0; i < 5; i++)
commit e9ad71dee845407da74ccacfbb53ad7ededf07fd
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Nov 30 08:10:26 2012 +0200

    [OTLayout] Rename hb_ot_layout_position_get_size() to hb_ot_layout_get_size_params()

diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 2572c00..879266d 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -641,8 +641,8 @@ hb_ot_layout_position_finish (hb_font_t *font, hb_buffer_t *buffer, hb_bool_t ze
 }
 
 hb_bool_t
-hb_ot_layout_position_get_size (hb_face_t *face,
-				uint16_t  *data /* OUT, 5 items */)
+hb_ot_layout_get_size_params (hb_face_t *face,
+			      uint16_t  *data /* OUT, 5 items */)
 {
   const OT::GPOS &gpos = _get_gpos (face);
   unsigned int script_index;
diff --git a/src/hb-ot-layout.h b/src/hb-ot-layout.h
index adb483c..8999eaf 100644
--- a/src/hb-ot-layout.h
+++ b/src/hb-ot-layout.h
@@ -277,10 +277,11 @@ Xhb_ot_layout_lookup_position (hb_font_t            *font,
 			      hb_glyph_position_t  *positions /* IN / OUT */);
 #endif
 
-/* Optical 'size' feature info.  Returns true if found. */
+/* Optical 'size' feature info.  Returns true if found.
+ * XXX Add URL. */
 hb_bool_t
-hb_ot_layout_position_get_size (hb_face_t *face,
-				uint16_t  *data /* OUT, 5 items */);
+hb_ot_layout_get_size_params (hb_face_t *face,
+			      uint16_t  *data /* OUT, 5 items */);
 
 
 HB_END_DECLS
commit f18ff5a84d9fe859c40a7a0c9a207cb40df0e84a
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Fri Nov 30 08:07:06 2012 +0200

    [OTLayout] Return correct value from recursion
    
    Commit 4c4e8f0e754b79ac6190d21878eaaf0b790c7579 broke contextual lookups
    by making the recurse() function always return false.
    
    Reported by Khaled.  Test case: لا in Amiri.

diff --git a/src/hb-ot-layout-gsubgpos-private.hh b/src/hb-ot-layout-gsubgpos-private.hh
index 40e8aa9..fe4dcbc 100644
--- a/src/hb-ot-layout-gsubgpos-private.hh
+++ b/src/hb-ot-layout-gsubgpos-private.hh
@@ -71,7 +71,7 @@ struct hb_closure_context_t
     nesting_level_left--;
     recurse_func (this, lookup_index);
     nesting_level_left++;
-    return default_return_value ();
+    return VOID;
   }
 
   hb_face_t *face;
@@ -112,7 +112,6 @@ struct hb_would_apply_context_t
   inline return_t process (const T &obj) { return obj.would_apply (this); }
   static return_t default_return_value (void) { return false; }
   bool stop_sublookup_iteration (const return_t r) const { return r; }
-  return_t recurse (unsigned int lookup_index) { return true; }
 
   hb_face_t *face;
   const hb_codepoint_t *glyphs;
@@ -162,7 +161,7 @@ struct hb_collect_glyphs_context_t
     hb_collect_glyphs_context_t new_c (this->face, NULL, NULL, NULL, &output, nesting_level_left);
     recurse_func (&new_c, lookup_index);
     nesting_level_left++;
-    return default_return_value ();
+    return VOID;
   }
 
   hb_face_t *face;
@@ -236,9 +235,9 @@ struct hb_apply_context_t
       return default_return_value ();
 
     nesting_level_left--;
-    recurse_func (this, lookup_index);
+    bool ret = recurse_func (this, lookup_index);
     nesting_level_left++;
-    return default_return_value ();
+    return ret;
   }
 
   hb_font_t *font;



More information about the HarfBuzz mailing list