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

Behdad Esfahbod behdad at kemper.freedesktop.org
Wed Nov 7 14:17:51 UTC 2018


 src/hb-ft.cc            |    6 +++---
 src/hb-ot-post-table.hh |   15 ++++++++++-----
 2 files changed, 13 insertions(+), 8 deletions(-)

New commits:
commit 9d5027696e418b7c2a5ccbc18faafe6b9290d08b
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Nov 7 09:16:53 2018 -0500

    [post] Return true on truncation
    
    Client can check that buffer was completely filled out and reallocate.

diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh
index b29096f1..18f9976b 100644
--- a/src/hb-ot-post-table.hh
+++ b/src/hb-ot-post-table.hh
@@ -148,10 +148,9 @@ struct post
         return false;
       if (!buf_len)
 	return true;
-      if (buf_len <= s.len) /* What to do with truncation? Returning false for now. */
-        return false;
-      strncpy (buf, s.arrayZ, s.len);
-      buf[s.len] = '\0';
+      unsigned int len = MIN (buf_len - 1, s.len);
+      strncpy (buf, s.arrayZ, len);
+      buf[len] = '\0';
       return true;
     }
 
commit 7d91f07edf29c4923716af6cee8eb94f948ac91f
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Nov 7 09:14:42 2018 -0500

    [post] Protect against huge empty tables

diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh
index 00bd1bcb..b29096f1 100644
--- a/src/hb-ot-post-table.hh
+++ b/src/hb-ot-post-table.hh
@@ -128,7 +128,9 @@ struct post
       pool = &StructAfter<uint8_t> (v2.glyphNameIndex);
 
       const uint8_t *end = (uint8_t *) table + table_length;
-      for (const uint8_t *data = pool; data < end && data + *data < end; data += 1 + *data)
+      for (const uint8_t *data = pool;
+	   index_to_offset.len < 65535 && data < end && data + *data < end;
+	   data += 1 + *data)
 	index_to_offset.push (data - pool);
     }
     inline void fini (void)
commit 5ed816ab5900ac4ff7feca3d98cbd92e62fd1754
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Nov 7 09:13:51 2018 -0500

    [post] Minor

diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh
index 1772a10c..00bd1bcb 100644
--- a/src/hb-ot-post-table.hh
+++ b/src/hb-ot-post-table.hh
@@ -49,12 +49,15 @@ namespace OT {
 
 struct postV2Tail
 {
+  friend struct post;
+
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
     return_trace (glyphNameIndex.sanitize (c));
   }
 
+  protected:
   ArrayOf<HBUINT16>	glyphNameIndex;	/* This is not an offset, but is the
 					 * ordinal number of the glyph in 'post'
 					 * string tables. */
@@ -62,6 +65,7 @@ struct postV2Tail
 			namesX;		/* Glyph names with length bytes [variable]
 					 * (a Pascal string). */
 
+  public:
   DEFINE_SIZE_ARRAY2 (2, glyphNameIndex, namesX);
 };
 
commit 64f0becd89cc2b0136c7dc1609abc9f957525cf8
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Wed Nov 7 09:10:55 2018 -0500

    [post] Fix bound checking

diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh
index b15a459b..1772a10c 100644
--- a/src/hb-ot-post-table.hh
+++ b/src/hb-ot-post-table.hh
@@ -124,7 +124,7 @@ struct post
       pool = &StructAfter<uint8_t> (v2.glyphNameIndex);
 
       const uint8_t *end = (uint8_t *) table + table_length;
-      for (const uint8_t *data = pool; data < end && data + *data <= end; data += 1 + *data)
+      for (const uint8_t *data = pool; data < end && data + *data < end; data += 1 + *data)
 	index_to_offset.push (data - pool);
     }
     inline void fini (void)
commit 7ec694ddf25a313483044256f7ed88b644432e15
Author: HinTak <htl10 at users.sourceforge.net>
Date:   Wed Nov 7 13:19:36 2018 +0000

    Use non-GRID-fitted values for metrics (#1363)
    
    * Use non-GRID-fitted values for metrics
    
    See freetype/src/base/ftobjs.c:ft_recompute_scaled_metrics() and
    the usage of GRID_FIT_METRICS inside.
    
    Fixes https://github.com/behdad/harfbuzz/issues/1262
    
    * Update hb-ft.cc

diff --git a/src/hb-ft.cc b/src/hb-ft.cc
index 8b80b960..9b9d787d 100644
--- a/src/hb-ft.cc
+++ b/src/hb-ft.cc
@@ -466,9 +466,9 @@ hb_ft_get_font_h_extents (hb_font_t *font HB_UNUSED,
   const hb_ft_font_t *ft_font = (const hb_ft_font_t *) font_data;
   hb_lock_t lock (ft_font->lock);
   FT_Face ft_face = ft_font->ft_face;
-  metrics->ascender = ft_face->size->metrics.ascender;
-  metrics->descender = ft_face->size->metrics.descender;
-  metrics->line_gap = ft_face->size->metrics.height - (ft_face->size->metrics.ascender - ft_face->size->metrics.descender);
+  metrics->ascender = FT_MulFix(ft_face->ascender, ft_face->size->metrics.y_scale);
+  metrics->descender = FT_MulFix(ft_face->descender, ft_face->size->metrics.y_scale);
+  metrics->line_gap = FT_MulFix( ft_face->height, ft_face->size->metrics.y_scale ) - (metrics->ascender - metrics->descender);
   if (font->y_scale < 0)
   {
     metrics->ascender = -metrics->ascender;


More information about the HarfBuzz mailing list