src/hb-ot-layout-gdef-table.hh |   13 +++++++-
 src/hb-ot-layout-gpos-table.hh |    3 +
 src/hb-ot-layout-gsub-table.hh |    3 +
 src/hb-ot-layout-gsubgpos.hh   |    5 +++
 src/hb-ot-layout.cc            |   63 +++++++++++++++++++++++++++--------------
 5 files changed, 65 insertions(+), 22 deletions(-)

New commits:
commit 574d888c8a409295a952361a39c8e83a52a0fc3d
Author: Behdad Esfahbod <beh...@behdad.org>
Date:   Sun Nov 25 16:51:22 2018 -0500

    [aat] Ignore GSUB table of Muthu Foundry if they have morx table
    
    Fixes https://github.com/harfbuzz/harfbuzz/issues/1410

diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh
index 907fd463..2589218d 100644
--- a/src/hb-ot-layout-gpos-table.hh
+++ b/src/hb-ot-layout-gpos-table.hh
@@ -1643,6 +1643,9 @@ struct GPOS : GSUBGPOS
   inline bool sanitize (hb_sanitize_context_t *c) const
   { return GSUBGPOS::sanitize<PosLookup> (c); }
 
+  HB_INTERNAL bool is_blacklisted (hb_blob_t *blob,
+                                  hb_face_t *face) const;
+
   typedef GSUBGPOS::accelerator_t<GPOS> accelerator_t;
 };
 
diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh
index 501f2308..27bd440d 100644
--- a/src/hb-ot-layout-gsub-table.hh
+++ b/src/hb-ot-layout-gsub-table.hh
@@ -1486,6 +1486,9 @@ struct GSUB : GSUBGPOS
   inline bool sanitize (hb_sanitize_context_t *c) const
   { return GSUBGPOS::sanitize<SubstLookup> (c); }
 
+  HB_INTERNAL bool is_blacklisted (hb_blob_t *blob,
+                                  hb_face_t *face) const;
+
   typedef GSUBGPOS::accelerator_t<GSUB> accelerator_t;
 };
 
diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh
index 3d70c55c..a9bfee15 100644
--- a/src/hb-ot-layout-gsubgpos.hh
+++ b/src/hb-ot-layout-gsubgpos.hh
@@ -2753,6 +2753,11 @@ struct GSUBGPOS
     inline void init (hb_face_t *face)
     {
       this->table = hb_sanitize_context_t().reference_table<T> (face);
+      if (unlikely (this->table->is_blacklisted (this->table.get_blob (), 
face)))
+      {
+       hb_blob_destroy (this->table.get_blob ());
+       this->table = hb_blob_get_empty ();
+      }
 
       this->lookup_count = table->get_lookup_count ();
 
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 6d6834fc..d0b22efe 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -34,15 +34,17 @@
 #include "hb-ot-map.hh"
 #include "hb-map.hh"
 
+#include "hb-ot-kern-table.hh"
 #include "hb-ot-layout-gdef-table.hh"
 #include "hb-ot-layout-gsub-table.hh"
 #include "hb-ot-layout-gpos-table.hh"
 #include "hb-ot-layout-base-table.hh" // Just so we compile it; unused 
otherwise
 #include "hb-ot-layout-jstf-table.hh" // Just so we compile it; unused 
otherwise
-#include "hb-ot-kern-table.hh"
 #include "hb-ot-name-table.hh"
+#include "hb-ot-os2-table.hh"
 
 #include "hb-aat-layout-lcar-table.hh"
+#include "hb-aat-layout-morx-table.hh"
 
 
 /**
@@ -284,6 +286,38 @@ hb_ot_layout_get_ligature_carets (hb_font_t      *font,
  * GSUB/GPOS
  */
 
+bool
+OT::GSUB::is_blacklisted (hb_blob_t *blob HB_UNUSED,
+                         hb_face_t *face) const
+{
+  /* Mac OS X prefers morx over GSUB.  It also ships with various Indic fonts,
+   * all by 'MUTF' foundry (Tamil MN, Tamil Sangam MN, etc.), that have broken
+   * GSUB/GPOS tables.  Some have GSUB with zero scripts, those are ignored by
+   * our morx/GSUB preference code.  But if GSUB has non-zero scripts, we tend
+   * to prefer it over morx because we want to be consistent with other 
OpenType
+   * shapers.
+   *
+   * To work around broken Indic Mac system fonts, we ignore GSUB table if
+   * OS/2 VendorId is 'MUTF' and font has morx table as well.
+   *
+   * https://github.com/harfbuzz/harfbuzz/issues/1410
+   * https://github.com/harfbuzz/harfbuzz/issues/1348
+   * https://github.com/harfbuzz/harfbuzz/issues/1391
+   */
+  if (unlikely (face->table.OS2->achVendID == HB_TAG ('M','U','T','F') &&
+               face->table.morx->has_data ()))
+    return true;
+
+  return false;
+}
+
+bool
+OT::GPOS::is_blacklisted (hb_blob_t *blob HB_UNUSED,
+                         hb_face_t *face HB_UNUSED) const
+{
+  return false;
+}
+
 static const OT::GSUBGPOS&
 get_gsubgpos_table (hb_face_t *face,
                    hb_tag_t   table_tag)
commit 4151c2848d8df75b6d0a4f5d79bee843158aa4a4
Author: Behdad Esfahbod <beh...@behdad.org>
Date:   Sun Nov 25 16:38:36 2018 -0500

    [GDEF] Move more code

diff --git a/src/hb-ot-layout-gdef-table.hh b/src/hb-ot-layout-gdef-table.hh
index a7ba9511..a0ae27e7 100644
--- a/src/hb-ot-layout-gdef-table.hh
+++ b/src/hb-ot-layout-gdef-table.hh
@@ -413,7 +413,15 @@ struct GDEF
 
   struct accelerator_t
   {
-    HB_INTERNAL void init (hb_face_t *face);
+    inline void init (hb_face_t *face)
+    {
+      this->table = hb_sanitize_context_t().reference_table<GDEF> (face);
+      if (unlikely (this->table->is_blacklisted (this->table.get_blob (), 
face)))
+      {
+       hb_blob_destroy (this->table.get_blob ());
+       this->table = hb_blob_get_empty ();
+      }
+    }
 
     inline void fini (void)
     {
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index bb87b5e5..6d6834fc 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -198,17 +198,6 @@ OT::GDEF::is_blacklisted (hb_blob_t *blob,
   return false;
 }
 
-void
-OT::GDEF::accelerator_t::init (hb_face_t *face)
-{
-  this->table = hb_sanitize_context_t().reference_table<GDEF> (face);
-  if (unlikely (this->table->is_blacklisted (this->table.get_blob (), face)))
-  {
-    hb_blob_destroy (this->table.get_blob ());
-    this->table = hb_blob_get_empty ();
-  }
-}
-
 static void
 _hb_ot_layout_set_glyph_props (hb_font_t *font,
                               hb_buffer_t *buffer)
commit 4f21703f225b6977196ef180e8d7300ea86d2cc3
Author: Behdad Esfahbod <beh...@behdad.org>
Date:   Sun Nov 25 15:59:18 2018 -0500

    [GDEF] Move code around

diff --git a/src/hb-ot-layout-gdef-table.hh b/src/hb-ot-layout-gdef-table.hh
index 2c4cbea8..a7ba9511 100644
--- a/src/hb-ot-layout-gdef-table.hh
+++ b/src/hb-ot-layout-gdef-table.hh
@@ -408,6 +408,9 @@ struct GDEF
     }
   }
 
+  HB_INTERNAL bool is_blacklisted (hb_blob_t *blob,
+                                  hb_face_t *face) const;
+
   struct accelerator_t
   {
     HB_INTERNAL void init (hb_face_t *face);
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 3cc1ef13..bb87b5e5 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -95,10 +95,9 @@ hb_ot_layout_kern (const hb_ot_shape_plan_t *plan,
  * GDEF
  */
 
-static bool
-_hb_ot_blacklist_gdef (unsigned int gdef_len,
-                      unsigned int gsub_len,
-                      unsigned int gpos_len)
+bool
+OT::GDEF::is_blacklisted (hb_blob_t *blob,
+                         hb_face_t *face) const
 {
   /* The ugly business of blacklisting individual fonts' tables happen here!
    * See this thread for why we finally had to bend in and do this:
@@ -118,7 +117,9 @@ _hb_ot_blacklist_gdef (unsigned int gdef_len,
    *     https://bugzilla.mozilla.org/show_bug.cgi?id=1279875
    */
 #define ENCODE(x,y,z) (((uint64_t) (x) << 48) | ((uint64_t) (y) << 24) | 
(uint64_t) (z))
-  switch ENCODE(gdef_len, gsub_len, gpos_len)
+  switch ENCODE(blob->length,
+               face->table.GSUB->table.get_length (),
+               face->table.GPOS->table.get_length ())
   {
     /* sha1sum:c5ee92f0bca4bfb7d06c4d03e8cf9f9cf75d2e8a Windows 7? timesi.ttf 
*/
     case ENCODE (442, 2874, 42038):
@@ -201,10 +202,7 @@ void
 OT::GDEF::accelerator_t::init (hb_face_t *face)
 {
   this->table = hb_sanitize_context_t().reference_table<GDEF> (face);
-
-  if (unlikely (_hb_ot_blacklist_gdef (this->table.get_length (),
-                                      face->table.GSUB->table.get_length (),
-                                      face->table.GPOS->table.get_length ())))
+  if (unlikely (this->table->is_blacklisted (this->table.get_blob (), face)))
   {
     hb_blob_destroy (this->table.get_blob ());
     this->table = hb_blob_get_empty ();
commit 4ed9fb1a0050f3151f9332f08c8bb2c13652c607
Author: Behdad Esfahbod <beh...@behdad.org>
Date:   Sun Nov 25 15:51:01 2018 -0500

    [GDEF] Minor

diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 9488fe82..3cc1ef13 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -117,7 +117,7 @@ _hb_ot_blacklist_gdef (unsigned int gdef_len,
    *     https://bugzilla.mozilla.org/show_bug.cgi?id=1279693
    *     https://bugzilla.mozilla.org/show_bug.cgi?id=1279875
    */
-#define ENCODE(x,y,z) ((int64_t) (x) << 32 | (int64_t) (y) << 16 | (z))
+#define ENCODE(x,y,z) (((uint64_t) (x) << 48) | ((uint64_t) (y) << 24) | 
(uint64_t) (z))
   switch ENCODE(gdef_len, gsub_len, gpos_len)
   {
     /* sha1sum:c5ee92f0bca4bfb7d06c4d03e8cf9f9cf75d2e8a Windows 7? timesi.ttf 
*/
_______________________________________________
HarfBuzz mailing list
HarfBuzz@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/harfbuzz

Reply via email to