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

Behdad Esfahbod behdad at kemper.freedesktop.org
Mon Jul 23 05:51:13 UTC 2018


 src/dump-emoji.cc             |    6 ++----
 src/hb-aat-layout.cc          |    4 +---
 src/hb-face.cc                |    8 ++++----
 src/hb-open-file-private.hh   |    2 --
 src/hb-open-type-private.hh   |   18 ++----------------
 src/hb-ot-cmap-table.hh       |    2 +-
 src/hb-ot-color-cbdt-table.hh |    4 ++--
 src/hb-ot-color-sbix-table.hh |    4 +---
 src/hb-ot-color-svg-table.hh  |    4 +---
 src/hb-ot-glyf-table.hh       |    8 ++++----
 src/hb-ot-hmtx-table.hh       |   10 +++++-----
 src/hb-ot-kern-table.hh       |    2 +-
 src/hb-ot-layout.cc           |    6 +++---
 src/hb-ot-maxp-table.hh       |    2 +-
 src/hb-ot-os2-table.hh        |    2 +-
 src/hb-ot-post-table.hh       |    2 +-
 src/hb-subset.cc              |    4 +---
 src/main.cc                   |    3 +--
 18 files changed, 32 insertions(+), 59 deletions(-)

New commits:
commit 9401829d4e93f6f433957fa2d053f3b9d42da557
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun Jul 22 22:50:58 2018 -0700

    Remove Sanitizer<>

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 9a059a4e..c59bb6a5 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -362,20 +362,6 @@ struct hb_sanitize_context_t :
 };
 
 
-
-/* Template to sanitize an object. */
-template <typename Type>
-struct Sanitizer
-{
-  inline Sanitizer (unsigned int num_glyphs = 0) { c->set_num_glyphs (num_glyphs); }
-  inline hb_blob_t *sanitize (hb_blob_t *blob) { return c[0].template/*clang idiosyncrasy*/sanitize_blob<Type> (blob); }
-
-  private:
-  hb_sanitize_context_t c[1];
-};
-
-
-
 /*
  * Serialize
  */
@@ -1285,7 +1271,7 @@ struct hb_table_lazy_loader_t
     hb_blob_t *b = (hb_blob_t *) hb_atomic_ptr_get (&blob);
     if (unlikely (!b))
     {
-      b = OT::Sanitizer<T>(face->get_num_glyphs ()).sanitize (face->reference_table (T::tableTag));
+      b = OT::hb_sanitize_context_t().reference_table<T> (face);
       if (!hb_atomic_ptr_cmpexch (&blob, nullptr, b))
       {
 	hb_blob_destroy (b);
commit 8e3e41272b3896274459c5961aac813ef2666321
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun Jul 22 22:49:26 2018 -0700

    Port rest of code away from Sanitizer<>

diff --git a/src/hb-face.cc b/src/hb-face.cc
index c492adc2..ad44eff5 100644
--- a/src/hb-face.cc
+++ b/src/hb-face.cc
@@ -53,7 +53,7 @@ hb_face_count (hb_blob_t *blob)
     return 0;
 
   /* TODO We shouldn't be sanitizing blob.  Port to run sanitizer and return if not sane. */
-  hb_blob_t *sanitized = OT::Sanitizer<OT::OpenTypeFontFile> ().sanitize (hb_blob_reference (blob));
+  hb_blob_t *sanitized = OT::hb_sanitize_context_t().sanitize_blob<OT::OpenTypeFontFile> (hb_blob_reference (blob));
   const OT::OpenTypeFontFile& ot = *sanitized->as<OT::OpenTypeFontFile> ();
   unsigned int ret = ot.get_face_count ();
   hb_blob_destroy (sanitized);
@@ -191,7 +191,7 @@ hb_face_create (hb_blob_t    *blob,
   if (unlikely (!blob))
     blob = hb_blob_get_empty ();
 
-  hb_face_for_data_closure_t *closure = _hb_face_for_data_closure_create (OT::Sanitizer<OT::OpenTypeFontFile>().sanitize (hb_blob_reference (blob)), index);
+  hb_face_for_data_closure_t *closure = _hb_face_for_data_closure_create (OT::hb_sanitize_context_t().sanitize_blob<OT::OpenTypeFontFile> (hb_blob_reference (blob)), index);
 
   if (unlikely (!closure))
     return hb_face_get_empty ();
diff --git a/src/main.cc b/src/main.cc
index 873d240a..c6e05fc3 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -51,8 +51,7 @@ main (int argc, char **argv)
   const char *font_data = hb_blob_get_data (blob, &len);
   printf ("Opened font file %s: %d bytes long\n", argv[1], len);
 
-  Sanitizer<OpenTypeFontFile> sanitizer;
-  hb_blob_t *font_blob = sanitizer.sanitize (blob);
+  hb_blob_t *font_blob = hb_sanitize_context_t().sanitize_blob<OpenTypeFontFile> (blob);
   const OpenTypeFontFile* sanitized = font_blob->as<OpenTypeFontFile> ();
   if (sanitized == &Null(OpenTypeFontFile))
   {
commit d6a8f64045ca3bf4c7d01520909fa0c7dfca4d64
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun Jul 22 22:47:19 2018 -0700

    Port dump-emoji away from Sanitizer<>

diff --git a/src/dump-emoji.cc b/src/dump-emoji.cc
index 99e8ef9f..400b890a 100644
--- a/src/dump-emoji.cc
+++ b/src/dump-emoji.cc
@@ -233,12 +233,10 @@ int main (int argc, char **argv)
   svg.dump (svg_callback);
   svg.fini ();
 
-  OT::Sanitizer<OT::COLR> sanitizerCOLR;
-  hb_blob_t* colr_blob = sanitizerCOLR.sanitize (face->reference_table (HB_OT_TAG_COLR));
+  hb_blob_t* colr_blob = OT::hb_sanitize_context_t().reference_table<OT::COLR> (face);
   const OT::COLR *colr = colr_blob->as<OT::COLR> ();
 
-  OT::Sanitizer<OT::CPAL> sanitizerCPAL;
-  hb_blob_t* cpal_blob = sanitizerCPAL.sanitize (face->reference_table (HB_OT_TAG_CPAL));
+  hb_blob_t* cpal_blob = OT::hb_sanitize_context_t().reference_table<OT::CPAL> (face);
   const OT::CPAL *cpal = cpal_blob->as<OT::CPAL> ();
 
   cairo_font_face_t *cairo_face;
commit 14f78d2b3bb1e1292efbd6a3e3f0d618179c171a
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun Jul 22 22:45:26 2018 -0700

    .

diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc
index 696dd355..405aafcc 100644
--- a/src/hb-aat-layout.cc
+++ b/src/hb-aat-layout.cc
@@ -61,9 +61,7 @@ _get_morx (hb_face_t *face, hb_blob_t **blob = nullptr)
 // static inline void
 // _hb_aat_layout_create (hb_face_t *face)
 // {
-//   OT::Sanitizer<AAT::morx> sanitizer;
-//   sanitizer.set_num_glyphs (face->get_num_glyphs ());
-//   hb_blob_t *morx_blob = sanitizer.sanitize (face->reference_table (HB_AAT_TAG_morx));
+//   hb_blob_t *morx_blob = OT::hb_sanitize_context_t().reference_table<AAT::morx> (face);
 //   morx_blob->as<AAT::morx> ();
 
 //   if (0)
commit 4547051f48ca6aa53309b81a768b5b44c4ab6e3b
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun Jul 22 22:44:22 2018 -0700

    Minor

diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh
index 226c48f6..d47bff66 100644
--- a/src/hb-open-file-private.hh
+++ b/src/hb-open-file-private.hh
@@ -484,8 +484,6 @@ struct ResourceForkHeader
 
 struct OpenTypeFontFile
 {
-  static const hb_tag_t tableTag	= HB_TAG ('_','_','_','_'); /* Sanitizer needs this. */
-
   enum {
     CFFTag		= HB_TAG ('O','T','T','O'), /* OpenType with Postscript outlines */
     TrueTypeTag	= HB_TAG ( 0 , 1 , 0 , 0 ), /* OpenType with TrueType outlines */
commit 740ae27d5c0f5ff87e2ff489fb49d5db1a0c95be
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun Jul 22 22:40:56 2018 -0700

    Port sbix off of Sanitizer<>

diff --git a/src/hb-ot-color-sbix-table.hh b/src/hb-ot-color-sbix-table.hh
index bf644a67..dcfeef46 100644
--- a/src/hb-ot-color-sbix-table.hh
+++ b/src/hb-ot-color-sbix-table.hh
@@ -96,9 +96,7 @@ struct sbix
   {
     inline void init (hb_face_t *face)
     {
-      /* XXX Using public API instead of private method to avoid link problem in dump_emoji.
-       * Kill that! */
-      sbix_blob = OT::Sanitizer<OT::sbix>(hb_face_get_glyph_count (face)/*face->get_num_glyphs ()*/).sanitize (face->reference_table (HB_OT_TAG_sbix));
+      sbix_blob = OT::hb_sanitize_context_t().reference_table<OT::sbix> (face);
       sbix_len = hb_blob_get_length (sbix_blob);
       sbix_table = sbix_blob->as<OT::sbix> ();
     }
commit 9583e0077d0a3a043f8b5bd23925014e04da8d32
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Sun Jul 22 22:40:32 2018 -0700

    Port more off of Sanitizer<>

diff --git a/src/hb-face.cc b/src/hb-face.cc
index 3c22f654..c492adc2 100644
--- a/src/hb-face.cc
+++ b/src/hb-face.cc
@@ -451,7 +451,7 @@ hb_face_get_upem (hb_face_t *face)
 void
 hb_face_t::load_upem (void) const
 {
-  hb_blob_t *head_blob = OT::Sanitizer<OT::head>().sanitize (reference_table (HB_OT_TAG_head));
+  hb_blob_t *head_blob = OT::hb_sanitize_context_t().reference_table<OT::head> (this);
   const OT::head *head_table = head_blob->as<OT::head> ();
   upem = head_table->get_upem ();
   hb_blob_destroy (head_blob);
@@ -495,7 +495,7 @@ hb_face_get_glyph_count (hb_face_t *face)
 void
 hb_face_t::load_num_glyphs (void) const
 {
-  hb_blob_t *maxp_blob = OT::Sanitizer<OT::maxp>().sanitize (reference_table (HB_OT_TAG_maxp));
+  hb_blob_t *maxp_blob = OT::hb_sanitize_context_t().reference_table<OT::maxp> (this);
   const OT::maxp *maxp_table = maxp_blob->as<OT::maxp> ();
   num_glyphs = maxp_table->get_num_glyphs ();
   hb_blob_destroy (maxp_blob);
diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 92a5142e..9a059a4e 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -346,7 +346,7 @@ struct hb_sanitize_context_t :
   }
 
   template <typename Type>
-  inline hb_blob_t *reference_table (hb_face_t *face, hb_tag_t tableTag = Type::tableTag)
+  inline hb_blob_t *reference_table (const hb_face_t *face, hb_tag_t tableTag = Type::tableTag)
   {
     return sanitize_blob<Type> (face->reference_table (tableTag));
   }
diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh
index 0ea37209..22cdbaf3 100644
--- a/src/hb-ot-cmap-table.hh
+++ b/src/hb-ot-cmap-table.hh
@@ -894,7 +894,7 @@ struct cmap
   {
     inline void init (hb_face_t *face)
     {
-      this->blob = OT::Sanitizer<OT::cmap>().sanitize (face->reference_table (HB_OT_TAG_cmap));
+      this->blob = OT::hb_sanitize_context_t().reference_table<OT::cmap> (face);
       const OT::cmap *cmap = this->blob->as<OT::cmap> ();
       const OT::CmapSubtable *subtable = nullptr;
       const OT::CmapSubtableFormat14 *subtable_uvs = nullptr;
diff --git a/src/hb-ot-color-cbdt-table.hh b/src/hb-ot-color-cbdt-table.hh
index d1dd9de4..21c2f477 100644
--- a/src/hb-ot-color-cbdt-table.hh
+++ b/src/hb-ot-color-cbdt-table.hh
@@ -394,8 +394,8 @@ struct CBDT
     {
       upem = hb_face_get_upem (face);
 
-      cblc_blob = Sanitizer<CBLC>().sanitize (face->reference_table (HB_OT_TAG_CBLC));
-      cbdt_blob = Sanitizer<CBDT>().sanitize (face->reference_table (HB_OT_TAG_CBDT));
+      cblc_blob = hb_sanitize_context_t().reference_table<CBLC> (face);
+      cbdt_blob = hb_sanitize_context_t().reference_table<CBDT> (face);
       cbdt_len = hb_blob_get_length (cbdt_blob);
 
       if (hb_blob_get_length (cblc_blob) == 0) {
diff --git a/src/hb-ot-color-svg-table.hh b/src/hb-ot-color-svg-table.hh
index ed6cf970..9bfd266c 100644
--- a/src/hb-ot-color-svg-table.hh
+++ b/src/hb-ot-color-svg-table.hh
@@ -96,11 +96,9 @@ struct SVG
   {
     inline void init (hb_face_t *face)
     {
-      OT::Sanitizer<OT::SVG> sanitizer;
-      svg_blob = sanitizer.sanitize (face->reference_table (HB_OT_TAG_SVG));
+      svg_blob = OT::hb_sanitize_context_t().reference_table<SVG> (face);
       svg_len = hb_blob_get_length (svg_blob);
       svg = svg_blob->as<OT::SVG> ();
-
     }
 
     inline void fini (void)
diff --git a/src/hb-ot-glyf-table.hh b/src/hb-ot-glyf-table.hh
index 89c867df..b670d792 100644
--- a/src/hb-ot-glyf-table.hh
+++ b/src/hb-ot-glyf-table.hh
@@ -103,7 +103,7 @@ struct glyf
   static bool
   _add_head_and_set_loca_version (hb_subset_plan_t *plan, bool use_short_loca)
   {
-    hb_blob_t *head_blob = OT::Sanitizer<OT::head>().sanitize (hb_face_reference_table (plan->source, HB_OT_TAG_head));
+    hb_blob_t *head_blob = OT::hb_sanitize_context_t().reference_table<OT::head> (plan->source);
     hb_blob_t *head_prime_blob = hb_blob_copy_writable_or_fail (head_blob);
     hb_blob_destroy (head_blob);
 
@@ -236,7 +236,7 @@ struct glyf
     {
       memset (this, 0, sizeof (accelerator_t));
 
-      hb_blob_t *head_blob = Sanitizer<head>().sanitize (face->reference_table (HB_OT_TAG_head));
+      hb_blob_t *head_blob = hb_sanitize_context_t().reference_table<head> (face);
       const head *head_table = head_blob->as<head> ();
       if (head_table == &Null(head) || (unsigned int) head_table->indexToLocFormat > 1 || head_table->glyphDataFormat != 0)
       {
@@ -247,9 +247,9 @@ struct glyf
       short_offset = 0 == head_table->indexToLocFormat;
       hb_blob_destroy (head_blob);
 
-      loca_blob = Sanitizer<loca>().sanitize (face->reference_table (HB_OT_TAG_loca));
+      loca_blob = hb_sanitize_context_t().reference_table<loca> (face);
       loca_table = loca_blob->as<loca> ();
-      glyf_blob = Sanitizer<glyf>().sanitize (face->reference_table (HB_OT_TAG_glyf));
+      glyf_blob = hb_sanitize_context_t().reference_table<glyf> (face);
       glyf_table = glyf_blob->as<glyf> ();
 
       num_glyphs = MAX (1u, hb_blob_get_length (loca_blob) / (short_offset ? 2 : 4)) - 1;
diff --git a/src/hb-ot-hmtx-table.hh b/src/hb-ot-hmtx-table.hh
index 2c626645..29cbc384 100644
--- a/src/hb-ot-hmtx-table.hh
+++ b/src/hb-ot-hmtx-table.hh
@@ -69,7 +69,7 @@ struct hmtxvmtx
   inline bool subset_update_header (hb_subset_plan_t *plan,
                                     unsigned int num_hmetrics) const
   {
-    hb_blob_t *src_blob = OT::Sanitizer<H> ().sanitize (plan->source->reference_table (H::tableTag));
+    hb_blob_t *src_blob = OT::hb_sanitize_context_t().reference_table<H> (plan->source, H::tableTag);
     hb_blob_t *dest_blob = hb_blob_copy_writable_or_fail(src_blob);
     hb_blob_destroy (src_blob);
 
@@ -195,7 +195,7 @@ struct hmtxvmtx
       bool got_font_extents = false;
       if (T::os2Tag)
       {
-	hb_blob_t *os2_blob = Sanitizer<os2> ().sanitize (face->reference_table (T::os2Tag));
+	hb_blob_t *os2_blob = hb_sanitize_context_t().reference_table<os2> (face);
 	const os2 *os2_table = os2_blob->as<os2> ();
 #define USE_TYPO_METRICS (1u<<7)
 	if (0 != (os2_table->fsSelection & USE_TYPO_METRICS))
@@ -208,7 +208,7 @@ struct hmtxvmtx
 	hb_blob_destroy (os2_blob);
       }
 
-      hb_blob_t *_hea_blob = Sanitizer<H> ().sanitize (face->reference_table (H::tableTag));
+      hb_blob_t *_hea_blob = hb_sanitize_context_t().reference_table<H> (face);
       const H *_hea_table = _hea_blob->as<H> ();
       num_advances = _hea_table->numberOfLongMetrics;
       if (!got_font_extents)
@@ -222,7 +222,7 @@ struct hmtxvmtx
 
       has_font_extents = got_font_extents;
 
-      blob = Sanitizer<hmtxvmtx> ().sanitize (face->reference_table (T::tableTag));
+      blob = hb_sanitize_context_t().reference_table<hmtxvmtx> (face, T::tableTag);
 
       /* Cap num_metrics() and num_advances() based on table length. */
       unsigned int len = hb_blob_get_length (blob);
@@ -240,7 +240,7 @@ struct hmtxvmtx
       }
       table = blob->as<hmtxvmtx> ();
 
-      var_blob = Sanitizer<HVARVVAR> ().sanitize (face->reference_table (T::variationsTag));
+      var_blob = hb_sanitize_context_t().reference_table<HVARVVAR> (face, T::variationsTag);
       var_table = var_blob->as<HVARVVAR> ();
     }
 
diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh
index b0fdea4a..b4d81095 100644
--- a/src/hb-ot-kern-table.hh
+++ b/src/hb-ot-kern-table.hh
@@ -362,7 +362,7 @@ struct kern
   {
     inline void init (hb_face_t *face)
     {
-      blob = Sanitizer<kern>().sanitize (face->reference_table (HB_OT_TAG_kern));
+      blob = hb_sanitize_context_t().reference_table<kern> (face);
       table = blob->as<kern> ();
       table_length = blob->length;
     }
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 3bfa1912..0eba88a6 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -54,13 +54,13 @@ _hb_ot_layout_create (hb_face_t *face)
   if (unlikely (!layout))
     return nullptr;
 
-  layout->gdef_blob = OT::Sanitizer<OT::GDEF>().sanitize (face->reference_table (HB_OT_TAG_GDEF));
+  layout->gdef_blob = OT::hb_sanitize_context_t().reference_table<OT::GDEF> (face);
   layout->gdef = layout->gdef_blob->as<OT::GDEF> ();
 
-  layout->gsub_blob = OT::Sanitizer<OT::GSUB>().sanitize (face->reference_table (HB_OT_TAG_GSUB));
+  layout->gsub_blob = OT::hb_sanitize_context_t().reference_table<OT::GSUB> (face);
   layout->gsub = layout->gsub_blob->as<OT::GSUB> ();
 
-  layout->gpos_blob = OT::Sanitizer<OT::GPOS>().sanitize (face->reference_table (HB_OT_TAG_GPOS));
+  layout->gpos_blob = OT::hb_sanitize_context_t().reference_table<OT::GPOS> (face);
   layout->gpos = layout->gpos_blob->as<OT::GPOS> ();
 
   layout->math.init (face);
diff --git a/src/hb-ot-maxp-table.hh b/src/hb-ot-maxp-table.hh
index 390b60d7..d3849fb1 100644
--- a/src/hb-ot-maxp-table.hh
+++ b/src/hb-ot-maxp-table.hh
@@ -100,7 +100,7 @@ struct maxp
 
   inline bool subset (hb_subset_plan_t *plan) const
   {
-    hb_blob_t *maxp_blob = OT::Sanitizer<OT::maxp>().sanitize (hb_face_reference_table (plan->source, HB_OT_TAG_maxp));
+    hb_blob_t *maxp_blob = OT::hb_sanitize_context_t().reference_table<OT::maxp> (plan->source);
     hb_blob_t *maxp_prime_blob = hb_blob_copy_writable_or_fail (maxp_blob);
     hb_blob_destroy (maxp_blob);
 
diff --git a/src/hb-ot-os2-table.hh b/src/hb-ot-os2-table.hh
index c52b7eb1..5aab56c4 100644
--- a/src/hb-ot-os2-table.hh
+++ b/src/hb-ot-os2-table.hh
@@ -51,7 +51,7 @@ struct os2
 
   inline bool subset (hb_subset_plan_t *plan) const
   {
-    hb_blob_t *os2_blob = OT::Sanitizer<OT::os2>().sanitize (hb_face_reference_table (plan->source, HB_OT_TAG_os2));
+    hb_blob_t *os2_blob = OT::hb_sanitize_context_t().reference_table<OT::os2> (plan->source);
     hb_blob_t *os2_prime_blob = hb_blob_create_sub_blob (os2_blob, 0, -1);
     // TODO(grieger): move to hb_blob_copy_writable_or_fail
     hb_blob_destroy (os2_blob);
diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh
index fed43d47..1d305801 100644
--- a/src/hb-ot-post-table.hh
+++ b/src/hb-ot-post-table.hh
@@ -110,7 +110,7 @@ struct post
     {
       index_to_offset.init ();
 
-      blob = Sanitizer<post>().sanitize (face->reference_table (HB_OT_TAG_post));
+      blob = hb_sanitize_context_t().reference_table<post> (face);
       const post *table = blob->as<post> ();
       unsigned int table_length = blob->length;
 
diff --git a/src/hb-subset.cc b/src/hb-subset.cc
index a65b58d2..308c7eb2 100644
--- a/src/hb-subset.cc
+++ b/src/hb-subset.cc
@@ -78,9 +78,7 @@ template<typename TableType>
 static bool
 _subset (hb_subset_plan_t *plan)
 {
-  OT::Sanitizer<TableType> sanitizer;
-
-  hb_blob_t *source_blob = sanitizer.sanitize (plan->source->reference_table (TableType::tableTag));
+  hb_blob_t *source_blob = OT::hb_sanitize_context_t().reference_table<TableType> (plan->source);
   const TableType *table = source_blob->as<TableType> ();
 
   hb_tag_t tag = TableType::tableTag;


More information about the HarfBuzz mailing list