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

Behdad Esfahbod behdad at kemper.freedesktop.org
Mon Feb 26 08:19:04 UTC 2018


 src/dev-run.sh                  |    4 -
 src/hb-aat-layout-ankr-table.hh |    2 
 src/hb-aat-layout-trak-table.hh |   95 +++++++++++++++++++++++++++++++---------
 src/hb-aat-layout.cc            |    2 
 util/options.hh                 |    2 
 5 files changed, 79 insertions(+), 26 deletions(-)

New commits:
commit f0bc6c0992c4302ae1a20f155ad256bfa331087c
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Mon Feb 26 00:18:17 2018 -0800

    [aat/trak] Clean up
    
    We always just used "unsigned int" for counter values. There's
    no use for uint16_t outside of a struct.
    
    Also, no need for explict casting where implicit does.

diff --git a/src/hb-aat-layout-trak-table.hh b/src/hb-aat-layout-trak-table.hh
index 7af62022..6c83760e 100644
--- a/src/hb-aat-layout-trak-table.hh
+++ b/src/hb-aat-layout-trak-table.hh
@@ -39,7 +39,7 @@ namespace AAT {
 
 struct TrackTableEntry
 {
-  inline bool sanitize (hb_sanitize_context_t *c, const void *base, uint16_t size) const
+  inline bool sanitize (hb_sanitize_context_t *c, const void *base, unsigned int size) const
   {
     TRACE_SANITIZE (this);
     return_trace (c->check_struct (this) && ((base+values).sanitize (c, size)));
@@ -74,8 +74,8 @@ struct TrackData
     if (!(c->check_struct (this)))
       return_trace (false);
 
-    uint16_t tracks = (uint16_t) nTracks;
-    uint16_t sizes = (uint16_t) nSizes;
+    unsigned int tracks = nTracks;
+    unsigned int sizes = nSizes;
 
     // It should have at least one track
     if (tracks < 1) return_trace (false);
@@ -86,7 +86,7 @@ struct TrackData
     if (!((base+sizeTable).sanitize (c, sizes)))
       return_trace (false);
 
-    for (uint16_t i = 0; i < tracks; ++i)
+    for (unsigned int i = 0; i < tracks; ++i)
       if (!(trackTable[i].sanitize (c, base, sizes)))
         return_trace (false);
 
@@ -106,8 +106,8 @@ struct TrackData
 
     /* TODO Clean this up. */
 
-    uint16_t tracks = (uint16_t) nTracks;
-    uint16_t sizes = (uint16_t) nSizes;
+    unsigned int tracks = nTracks;
+    unsigned int sizes = nSizes;
 
     const TrackTableEntry *trackTableEntry = nullptr;
     for (unsigned int i = 0; i < sizes; ++i)
commit bb82f01383db7cf05040fbd5881e17e263ef6369
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date:   Sun Feb 25 12:30:33 2018 +0330

    [aat] trak sanitization

diff --git a/src/dev-run.sh b/src/dev-run.sh
index 3b2257b1..c7018112 100755
--- a/src/dev-run.sh
+++ b/src/dev-run.sh
@@ -35,7 +35,7 @@ find src/ | entr printf '\0' | while read -d ""; do
 	fi
 done
 
-read -n 1 -p "[T]est, [D]ebug, [R]estart, [Q]uit?" answer
+read -n 1 -p "[T]est, [D]ebug, [R]estart, [Q]uit? " answer
 case "$answer" in
 t|T )
 	if [[ $CMAKENINJA ]]; then
@@ -48,7 +48,7 @@ d|D )
 	if [[ $CMAKENINJA ]]; then
 		echo "Not supported on cmake builds yet"
 	else
-		build/libtool --mode=execute $GDB build/util/hb-shape $@
+		build/libtool --mode=execute $GDB -- build/util/hb-shape $@
 	fi
 ;;
 r|R )
diff --git a/src/hb-aat-layout-trak-table.hh b/src/hb-aat-layout-trak-table.hh
index b248db2f..7af62022 100644
--- a/src/hb-aat-layout-trak-table.hh
+++ b/src/hb-aat-layout-trak-table.hh
@@ -39,11 +39,15 @@ namespace AAT {
 
 struct TrackTableEntry
 {
-  inline bool sanitize (hb_sanitize_context_t *c) const
+  inline bool sanitize (hb_sanitize_context_t *c, const void *base, uint16_t size) const
   {
     TRACE_SANITIZE (this);
-    /* XXX Sanitize values */
-    return_trace (c->check_struct (this));
+    return_trace (c->check_struct (this) && ((base+values).sanitize (c, size)));
+  }
+
+  inline Fixed get_track_value () const
+  {
+    return track;
   }
 
   inline float get_value (const void *base, unsigned int index) const
@@ -64,11 +68,29 @@ struct TrackTableEntry
 
 struct TrackData
 {
-  inline bool sanitize (hb_sanitize_context_t *c) const
+  inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
   {
     TRACE_SANITIZE (this);
-    /* TODO */
-    return_trace (c->check_struct (this));
+    if (!(c->check_struct (this)))
+      return_trace (false);
+
+    uint16_t tracks = (uint16_t) nTracks;
+    uint16_t sizes = (uint16_t) nSizes;
+
+    // It should have at least one track
+    if (tracks < 1) return_trace (false);
+
+    // We can not do interpolation with less than two
+    if (sizes < 2) return_trace (false);
+
+    if (!((base+sizeTable).sanitize (c, sizes)))
+      return_trace (false);
+
+    for (uint16_t i = 0; i < tracks; ++i)
+      if (!(trackTable[i].sanitize (c, base, sizes)))
+        return_trace (false);
+
+    return_trace (true);
   }
 
   inline float get_tracking (const void *base, float ptem) const
@@ -84,26 +106,37 @@ struct TrackData
 
     /* TODO Clean this up. */
 
-    // TODO: Make indexing work and use only an entry with zero track
-    const TrackTableEntry &trackTableEntry = trackTable[0];
+    uint16_t tracks = (uint16_t) nTracks;
+    uint16_t sizes = (uint16_t) nSizes;
+
+    const TrackTableEntry *trackTableEntry = nullptr;
+    for (unsigned int i = 0; i < sizes; ++i)
+      // For now we only seek for track entries with zero tracking value
+      if (trackTable[i].get_track_value () == 0)
+        trackTableEntry = &trackTable[0];
+
+    // We couldn't match any, exit
+    if (!trackTableEntry) return 0.;
 
     /* TODO bfind() */
     unsigned int size_index;
-    for (size_index = 0; size_index < nSizes; ++size_index)
-      if ((base+sizeTable)[size_index] >= fixed_size)
+    UnsizedArrayOf<Fixed> size_table = base+sizeTable;
+    for (size_index = 0; size_index < sizes; ++size_index)
+      if (size_table[size_index] >= fixed_size)
         break;
 
-    // We don't attempt to extrapolate to larger or smaller values
-    if (size_index == nSizes)
-      return trackTableEntry.get_value (base, nSizes - 1);
-    if (size_index == 0 || (base+sizeTable)[size_index] == fixed_size)
-      return trackTableEntry.get_value (base, size_index);
+    // TODO(ebraminio): We don't attempt to extrapolate to larger or
+    // smaller values for now but we should do, per spec
+    if (size_index == sizes)
+      return trackTableEntry->get_value (base, sizes - 1);
+    if (size_index == 0 || size_table[size_index] == fixed_size)
+      return trackTableEntry->get_value (base, size_index);
 
-    float s0 = (base+sizeTable)[size_index - 1].to_float ();
-    float s1 = (base+sizeTable)[size_index].to_float ();
+    float s0 = size_table[size_index - 1].to_float ();
+    float s1 = size_table[size_index].to_float ();
     float t = (csspx - s0) / (s1 - s0);
-    return t * trackTableEntry.get_value (base, size_index) +
-      (1.0 - t) * trackTableEntry.get_value (base, size_index - 1);
+    return t * trackTableEntry->get_value (base, size_index) +
+      (1.0 - t) * trackTableEntry->get_value (base, size_index - 1);
   }
 
   protected:
@@ -124,8 +157,28 @@ struct trak
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
-    /* TODO */
-    return_trace (c->check_struct (this));
+
+    if (!(c->check_struct (this)))
+      return_trace (false);
+
+    if ((format != 0) || (reserved != 0))
+      return_trace (false);
+
+    if (horizData)
+    {
+      const TrackData &trackData = this+horizData;
+      if (!trackData.sanitize (c, this))
+        return_trace (false);
+    }
+
+    if (vertData)
+    {
+      const TrackData &trackData = this+horizData;
+      if (!trackData.sanitize (c, this))
+        return_trace (false);
+    }
+
+    return_trace (true);
   }
 
   inline bool apply (hb_aat_apply_context_t *c) const
diff --git a/src/hb-aat-layout.cc b/src/hb-aat-layout.cc
index bdbe41f9..45268e3e 100644
--- a/src/hb-aat-layout.cc
+++ b/src/hb-aat-layout.cc
@@ -36,7 +36,7 @@
 #include "hb-aat-layout-trak-table.hh"
 
 /*
- * mort/morx
+ * morx/kerx/trak
  */
 
 static inline const AAT::ankr&
diff --git a/util/options.hh b/util/options.hh
index cfbbade2..09d7245f 100644
--- a/util/options.hh
+++ b/util/options.hh
@@ -454,7 +454,7 @@ struct font_options_t : option_group_t
     default_font_size = default_font_size_;
     x_ppem = 0;
     y_ppem = 0;
-    ptem = .0;
+    ptem = 0.;
     subpixel_bits = subpixel_bits_;
     font_file = nullptr;
     face_index = 0;
commit becb1d9eea15c07f9ea4e229be56f9aca0f768af
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date:   Mon Feb 26 11:29:48 2018 +0330

    [aat] minor
    
    Ops, this was done for testing

diff --git a/src/hb-aat-layout-ankr-table.hh b/src/hb-aat-layout-ankr-table.hh
index 2a903fda..e64ad094 100644
--- a/src/hb-aat-layout-ankr-table.hh
+++ b/src/hb-aat-layout-ankr-table.hh
@@ -43,7 +43,7 @@ struct GlyphDataTable
   {
     TRACE_SANITIZE (this);
     return_trace (c->check_struct (this) &&
-      (numPoints == 0) &&
+      (numPoints != 0) &&
       (anchorPoints.sanitize (c, numPoints)));
   }
 


More information about the HarfBuzz mailing list