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

Behdad Esfahbod behdad at kemper.freedesktop.org
Thu Apr 12 12:36:48 UTC 2018


 .travis.yml                                |    2 
 src/Makefile.am                            |   13 +-
 src/dump-emoji.cc                          |  182 +++++++++++++++++++++++++++--
 src/hb-aat-fmtx-table.hh                   |    9 -
 src/hb-aat-gcid-table.hh                   |   12 -
 src/hb-aat-layout-ankr-table.hh            |   19 +--
 src/hb-aat-layout-bsln-table.hh            |   10 -
 src/hb-aat-layout-common-private.hh        |    6 
 src/hb-aat-layout-feat-table.hh            |   10 -
 src/hb-aat-layout-kerx-table.hh            |   33 +++--
 src/hb-aat-layout-morx-table.hh            |   20 ++-
 src/hb-aat-layout-trak-table.hh            |   14 +-
 src/hb-aat-ltag-table.hh                   |   20 +--
 src/hb-common.cc                           |    4 
 src/hb-common.h                            |    6 
 src/hb-coretext.cc                         |   36 ++++-
 src/hb-directwrite.cc                      |   39 +++---
 src/hb-directwrite.h                       |    5 
 src/hb-ft.cc                               |    2 
 src/hb-graphite2.cc                        |   16 +-
 src/hb-open-file-private.hh                |    2 
 src/hb-open-type-private.hh                |    1 
 src/hb-ot-cmap-table.hh                    |   16 +-
 src/hb-ot-color-cbdt-table.hh              |   34 ++---
 src/hb-ot-color-colr-table.hh              |   49 ++++++-
 src/hb-ot-color-cpal-table.hh              |   78 +++++++-----
 src/hb-ot-color-sbix-table.hh              |   52 ++++----
 src/hb-ot-color-svg-table.hh               |   40 +++---
 src/hb-ot-glyf-table.hh                    |    4 
 src/hb-ot-hdmx-table.hh                    |   11 -
 src/hb-ot-head-table.hh                    |   10 -
 src/hb-ot-hhea-table.hh                    |   15 +-
 src/hb-ot-hmtx-table.hh                    |   14 +-
 src/hb-ot-kern-table.hh                    |   10 -
 src/hb-ot-layout-base-table.hh             |    3 
 src/hb-ot-layout-common-private.hh         |    8 -
 src/hb-ot-layout-gdef-table.hh             |    3 
 src/hb-ot-layout-gpos-table.hh             |    3 
 src/hb-ot-layout-gsub-table.hh             |    3 
 src/hb-ot-layout-jstf-table.hh             |    3 
 src/hb-ot-layout-private.hh                |    2 
 src/hb-ot-layout.h                         |    2 
 src/hb-ot-math-table.hh                    |    3 
 src/hb-ot-maxp-table.hh                    |    3 
 src/hb-ot-name-table.hh                    |    4 
 src/hb-ot-os2-table.hh                     |    3 
 src/hb-ot-post-table.hh                    |    8 -
 src/hb-ot-shape-complex-arabic.cc          |    4 
 src/hb-ot-shape-complex-indic-private.hh   |    2 
 src/hb-ot-shape-complex-indic.cc           |    4 
 src/hb-ot-shape-complex-khmer.cc           |    2 
 src/hb-ot-shape-complex-myanmar-private.hh |    2 
 src/hb-ot-shape-complex-myanmar.cc         |    2 
 src/hb-ot-shape-complex-thai.cc            |    2 
 src/hb-ot-shape-complex-use-private.hh     |    2 
 src/hb-ot-shape-complex-use.cc             |    2 
 src/hb-ot-shape-fallback.cc                |    2 
 src/hb-ot-tag.cc                           |    9 -
 src/hb-ot-var-avar-table.hh                |   14 +-
 src/hb-ot-var-fvar-table.hh                |   15 +-
 src/hb-ot-var-hvar-table.hh                |    7 -
 src/hb-ot-var-mvar-table.hh                |    4 
 src/hb-private.hh                          |   12 -
 src/hb-string-array.hh                     |    2 
 src/hb-unicode-private.hh                  |   18 +-
 test/api/test-buffer.c                     |    2 
 test/api/test-ot-tag.c                     |    6 
 test/api/test-shape.c                      |    2 
 68 files changed, 611 insertions(+), 346 deletions(-)

New commits:
commit 632713babbc349920f71f73cc304c9a18078fd6b
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date:   Thu Apr 12 14:17:03 2018 +0430

    Always enable atexit on Android (#971)
    
    Obviously one can use a newer NDK for building an updated HarfBuzz
    instead that now pretty old version however I am concerned if that
    version checking is working with clang that is used with the newer
    NDK versions.

diff --git a/src/hb-private.hh b/src/hb-private.hh
index e40217ee..3181eb57 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -226,11 +226,9 @@ static int errno = 0; /* Use something better? */
  * mingw32 headers say atexit is safe to use in shared libraries.
  */
 #    define HB_USE_ATEXIT 1
-#  elif defined(__ANDROID__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
-/* This was fixed in Android NKD r8 or r8b:
- * https://code.google.com/p/android/issues/detail?id=6455
- * which introduced GCC 4.6:
- * https://developer.android.com/tools/sdk/ndk/index.html
+#  elif defined(__ANDROID__)
+/* This is available since Android NKD r8 or r8b:
+ * https://issuetracker.google.com/code/p/android/issues/detail?id=6455
  */
 #    define HB_USE_ATEXIT 1
 #  elif defined(__APPLE__)
commit f24b0b9728f87d7599867a4ba6ec7d30da43b869
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date:   Thu Apr 12 13:40:45 2018 +0430

    Update the links and revive the dead ones

diff --git a/src/hb-common.cc b/src/hb-common.cc
index b16c9324..bc54db67 100644
--- a/src/hb-common.cc
+++ b/src/hb-common.cc
@@ -412,7 +412,7 @@ hb_script_from_iso15924_tag (hb_tag_t tag)
     case HB_TAG('Q','a','a','i'): return HB_SCRIPT_INHERITED;
     case HB_TAG('Q','a','a','c'): return HB_SCRIPT_COPTIC;
 
-    /* Script variants from http://unicode.org/iso15924/ */
+    /* Script variants from https://unicode.org/iso15924/ */
     case HB_TAG('C','y','r','s'): return HB_SCRIPT_CYRILLIC;
     case HB_TAG('L','a','t','f'): return HB_SCRIPT_LATIN;
     case HB_TAG('L','a','t','g'): return HB_SCRIPT_LATIN;
@@ -480,7 +480,7 @@ hb_script_to_iso15924_tag (hb_script_t script)
 hb_direction_t
 hb_script_get_horizontal_direction (hb_script_t script)
 {
-  /* http://goo.gl/x9ilM */
+  /* https://docs.google.com/spreadsheets/d/1Y90M0Ie3MUJ6UVCRDOypOtijlMDLNNyyLk36T6iMu0o */
   switch ((hb_tag_t) script)
   {
     /* Unicode-1.1 additions */
diff --git a/src/hb-common.h b/src/hb-common.h
index 26200ce1..9040f504 100644
--- a/src/hb-common.h
+++ b/src/hb-common.h
@@ -142,8 +142,8 @@ hb_language_get_default (void);
 
 /* hb_script_t */
 
-/* http://unicode.org/iso15924/ */
-/* http://goo.gl/x9ilM */
+/* https://unicode.org/iso15924/ */
+/* https://docs.google.com/spreadsheets/d/1Y90M0Ie3MUJ6UVCRDOypOtijlMDLNNyyLk36T6iMu0o */
 /* Unicode Character Database property: Script (sc) */
 typedef enum
 {
@@ -323,7 +323,7 @@ typedef enum
    * since technically enums are int, and indeed, hb_script_t ends up being signed.
    * See this thread for technicalities:
    *
-   *   http://lists.freedesktop.org/archives/harfbuzz/2014-March/004150.html
+   *   https://lists.freedesktop.org/archives/harfbuzz/2014-March/004150.html
    */
   _HB_SCRIPT_MAX_VALUE				= HB_TAG_MAX, /*< skip >*/
   _HB_SCRIPT_MAX_VALUE_SIGNED			= HB_TAG_MAX_SIGNED /*< skip >*/
diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index 8bb20016..7055e5f7 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -1005,7 +1005,7 @@ resize_and_retry:
     /* For right-to-left runs, CoreText returns the glyphs positioned such that
      * any trailing whitespace is to the left of (0,0).  Adjust coordinate system
      * to fix for that.  Test with any RTL string with trailing spaces.
-     * https://code.google.com/p/chromium/issues/detail?id=469028
+     * https://crbug.com/469028
      */
     if (HB_DIRECTION_IS_BACKWARD (buffer->props.direction))
     {
@@ -1058,7 +1058,7 @@ resize_and_retry:
 	 * However, even that wouldn't work if we were passed in the CGFont to
 	 * construct a hb_face to begin with.
 	 *
-	 * See: http://github.com/harfbuzz/harfbuzz/pull/36
+	 * See: https://github.com/harfbuzz/harfbuzz/pull/36
 	 *
 	 * Also see: https://bugs.chromium.org/p/chromium/issues/detail?id=597098
 	 */
@@ -1248,7 +1248,7 @@ resize_and_retry:
      * directions.  As such, disable the assert...  It wouldn't crash, but
      * cursoring will be off...
      *
-     * http://crbug.com/419769
+     * https://crbug.com/419769
      */
     if (0)
     {
diff --git a/src/hb-ft.cc b/src/hb-ft.cc
index e68960d5..aa6c1a10 100644
--- a/src/hb-ft.cc
+++ b/src/hb-ft.cc
@@ -177,7 +177,7 @@ hb_ft_get_nominal_glyph (hb_font_t *font HB_UNUSED,
       /* For symbol-encoded OpenType fonts, we duplicate the
        * U+F000..F0FF range at U+0000..U+00FF.  That's what
        * Windows seems to do, and that's hinted about at:
-       * http://www.microsoft.com/typography/otspec/recom.htm
+       * https://docs.microsoft.com/en-us/typography/opentype/spec/recom
        * under "Non-Standard (Symbol) Fonts". */
       g = FT_Get_Char_Index (ft_font->ft_face, 0xF000u + unicode);
       if (!g)
diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh
index 4114b35d..959ca97f 100644
--- a/src/hb-ot-cmap-table.hh
+++ b/src/hb-ot-cmap-table.hh
@@ -30,16 +30,16 @@
 #include "hb-open-type-private.hh"
 #include "hb-subset-plan.hh"
 
-namespace OT {
-
-
 /*
- * cmap -- Character To Glyph Index Mapping Table
+ * cmap -- Character to Glyph Index Mapping
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/cmap
  */
-
 #define HB_OT_TAG_cmap HB_TAG('c','m','a','p')
 
 
+namespace OT {
+
+
 struct CmapSubtableFormat0
 {
   inline bool get_glyph (hb_codepoint_t codepoint, hb_codepoint_t *glyph) const
@@ -738,7 +738,7 @@ struct cmap
 	/* For symbol-encoded OpenType fonts, we duplicate the
 	 * U+F000..F0FF range at U+0000..U+00FF.  That's what
 	 * Windows seems to do, and that's hinted about at:
-	 * http://www.microsoft.com/typography/otspec/recom.htm
+	 * https://docs.microsoft.com/en-us/typography/opentype/spec/recom
 	 * under "Non-Standard (Symbol) Fonts". */
 	return typed_obj->get_glyph (0xF000u + codepoint, glyph);
       }
diff --git a/src/hb-ot-layout-common-private.hh b/src/hb-ot-layout-common-private.hh
index e9240aaa..9251a6a9 100644
--- a/src/hb-ot-layout-common-private.hh
+++ b/src/hb-ot-layout-common-private.hh
@@ -270,7 +270,7 @@ struct Script
 typedef RecordListOf<Script> ScriptList;
 
 
-/* http://www.microsoft.com/typography/otspec/features_pt.htm#size */
+/* https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#size */
 struct FeatureParamsSize
 {
   inline bool sanitize (hb_sanitize_context_t *c) const
@@ -292,7 +292,7 @@ struct FeatureParamsSize
      *
      * The specification for this feature tag is in the "OpenType Layout Tag
      * Registry". You can see a copy of this at:
-     * http://partners.adobe.com/public/developer/opentype/index_tag8.html#size
+     * https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#tag-size
      *
      * Here is one set of rules to determine if the 'size' feature is built
      * correctly, or as by the older versions of MakeOTF. You may be able to do
@@ -382,7 +382,7 @@ struct FeatureParamsSize
   DEFINE_SIZE_STATIC (10);
 };
 
-/* http://www.microsoft.com/typography/otspec/features_pt.htm#ssxx */
+/* https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#ssxx */
 struct FeatureParamsStylisticSet
 {
   inline bool sanitize (hb_sanitize_context_t *c) const
@@ -416,7 +416,7 @@ struct FeatureParamsStylisticSet
   DEFINE_SIZE_STATIC (4);
 };
 
-/* http://www.microsoft.com/typography/otspec/features_ae.htm#cv01-cv99 */
+/* https://docs.microsoft.com/en-us/typography/opentype/spec/features_ae#cv01-cv99 */
 struct FeatureParamsCharacterVariants
 {
   inline bool sanitize (hb_sanitize_context_t *c) const
diff --git a/src/hb-ot-layout-private.hh b/src/hb-ot-layout-private.hh
index 870ba73f..9bcbf1cb 100644
--- a/src/hb-ot-layout-private.hh
+++ b/src/hb-ot-layout-private.hh
@@ -309,7 +309,7 @@ _hb_glyph_info_set_unicode_props (hb_glyph_info_t *info, hb_buffer_t *buffer)
        * processing on. */
 
       /* Only Mn and Mc can have non-zero ccc:
-       * http://www.unicode.org/policies/stability_policy.html#Property_Value
+       * https://unicode.org/policies/stability_policy.html#Property_Value
        * """
        * Canonical_Combining_Class, General_Category
        * All characters other than those with General_Category property values
diff --git a/src/hb-ot-layout.h b/src/hb-ot-layout.h
index 85938ba1..d82dc022 100644
--- a/src/hb-ot-layout.h
+++ b/src/hb-ot-layout.h
@@ -307,7 +307,7 @@ Xhb_ot_layout_lookup_position (hb_font_t            *font,
 #endif
 
 /* Optical 'size' feature info.  Returns true if found.
- * http://www.microsoft.com/typography/otspec/features_pt.htm#size */
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#size */
 HB_EXTERN hb_bool_t
 hb_ot_layout_get_size_params (hb_face_t    *face,
 			      unsigned int *design_size,       /* OUT.  May be NULL */
diff --git a/src/hb-ot-shape-complex-arabic.cc b/src/hb-ot-shape-complex-arabic.cc
index 47961bfd..124a67f3 100644
--- a/src/hb-ot-shape-complex-arabic.cc
+++ b/src/hb-ot-shape-complex-arabic.cc
@@ -421,7 +421,7 @@ retry:
 /*
  * Stretch feature: "stch".
  * See example here:
- * https://www.microsoft.com/typography/OpenTypeDev/syriac/intro.htm
+ * https://docs.microsoft.com/en-us/typography/script-development/syriac
  * We implement this in a generic way, such that the Arabic subtending
  * marks can use it as well.
  */
@@ -611,7 +611,7 @@ postprocess_glyphs_arabic (const hb_ot_shape_plan_t *plan,
   HB_BUFFER_DEALLOCATE_VAR (buffer, arabic_shaping_action);
 }
 
-/* http://www.unicode.org/reports/tr53/tr53-1.pdf */
+/* https://unicode.org/reports/tr53/tr53-1.pdf */
 
 static hb_codepoint_t
 modifier_combining_marks[] =
diff --git a/src/hb-ot-shape-complex-indic-private.hh b/src/hb-ot-shape-complex-indic-private.hh
index 867b9362..9554994a 100644
--- a/src/hb-ot-shape-complex-indic-private.hh
+++ b/src/hb-ot-shape-complex-indic-private.hh
@@ -42,7 +42,7 @@
 #define INDIC_TABLE_ELEMENT_TYPE uint16_t
 
 /* Cateories used in the OpenType spec:
- * https://www.microsoft.com/typography/otfntdev/devanot/shaping.aspx
+ * https://docs.microsoft.com/en-us/typography/script-development/devanagari
  */
 /* Note: This enum is duplicated in the -machine.rl source file.
  * Not sure how to avoid duplication. */
diff --git a/src/hb-ot-shape-complex-indic.cc b/src/hb-ot-shape-complex-indic.cc
index 32ad86a5..fdc8966e 100644
--- a/src/hb-ot-shape-complex-indic.cc
+++ b/src/hb-ot-shape-complex-indic.cc
@@ -435,7 +435,7 @@ update_consonant_positions (const hb_ot_shape_plan_t *plan,
 
 
 /* Rules from:
- * https://www.microsoft.com/typography/otfntdev/devanot/shaping.aspx */
+ * https://docs.microsqoft.com/en-us/typography/script-development/devanagari */
 
 static void
 initial_reordering_consonant_syllable (const hb_ot_shape_plan_t *plan,
@@ -1512,7 +1512,7 @@ decompose_indic (const hb_ot_shape_normalize_context_t *c,
      * The Uniscribe behavior is now documented in the newly published Sinhala
      * spec in 2012:
      *
-     *   http://www.microsoft.com/typography/OpenTypeDev/sinhala/intro.htm#shaping
+     *   https://docs.microsoft.com/en-us/typography/script-development/sinhala#shaping
      */
 
     const indic_shape_plan_t *indic_plan = (const indic_shape_plan_t *) c->plan->data;
diff --git a/src/hb-ot-shape-complex-khmer.cc b/src/hb-ot-shape-complex-khmer.cc
index 304879d8..e86eb87a 100644
--- a/src/hb-ot-shape-complex-khmer.cc
+++ b/src/hb-ot-shape-complex-khmer.cc
@@ -275,7 +275,7 @@ compare_khmer_order (const hb_glyph_info_t *pa, const hb_glyph_info_t *pb)
 
 
 /* Rules from:
- * https://www.microsoft.com/typography/otfntdev/devanot/shaping.aspx */
+ * https://docs.microsoft.com/en-us/typography/script-development/devanagari */
 
 static void
 initial_reordering_consonant_syllable (const hb_ot_shape_plan_t *plan,
diff --git a/src/hb-ot-shape-complex-myanmar-private.hh b/src/hb-ot-shape-complex-myanmar-private.hh
index 04f81bd1..14d011d6 100644
--- a/src/hb-ot-shape-complex-myanmar-private.hh
+++ b/src/hb-ot-shape-complex-myanmar-private.hh
@@ -68,7 +68,7 @@ set_myanmar_properties (hb_glyph_info_t &info)
   indic_position_t pos = (indic_position_t) (type >> 8);
 
   /* Myanmar
-   * http://www.microsoft.com/typography/OpenTypeDev/myanmar/intro.htm#analyze
+   * https://docs.microsoft.com/en-us/typography/script-development/myanmar#analyze
    */
   if (unlikely (hb_in_range<hb_codepoint_t> (u, 0xFE00u, 0xFE0Fu)))
     cat = (indic_category_t) OT_VS;
diff --git a/src/hb-ot-shape-complex-myanmar.cc b/src/hb-ot-shape-complex-myanmar.cc
index 3c57bc1f..4007ee91 100644
--- a/src/hb-ot-shape-complex-myanmar.cc
+++ b/src/hb-ot-shape-complex-myanmar.cc
@@ -161,7 +161,7 @@ compare_myanmar_order (const hb_glyph_info_t *pa, const hb_glyph_info_t *pb)
 
 
 /* Rules from:
- * http://www.microsoft.com/typography/OpenTypeDev/myanmar/intro.htm */
+ * https://docs.microsoft.com/en-us/typography/script-development/myanmar */
 
 static void
 initial_reordering_consonant_syllable (hb_buffer_t *buffer,
diff --git a/src/hb-ot-shape-complex-thai.cc b/src/hb-ot-shape-complex-thai.cc
index 6ba925c6..5902b36c 100644
--- a/src/hb-ot-shape-complex-thai.cc
+++ b/src/hb-ot-shape-complex-thai.cc
@@ -260,7 +260,7 @@ preprocess_text_thai (const hb_ot_shape_plan_t *plan,
 {
   /* This function implements the shaping logic documented here:
    *
-   *   http://linux.thai.net/~thep/th-otf/shaping.html
+   *   https://linux.thai.net/~thep/th-otf/shaping.html
    *
    * The first shaping rule listed there is needed even if the font has Thai
    * OpenType tables.  The rest do fallback positioning based on PUA codepoints.
diff --git a/src/hb-ot-shape-complex-use-private.hh b/src/hb-ot-shape-complex-use-private.hh
index f7ded133..b4bda8bb 100644
--- a/src/hb-ot-shape-complex-use-private.hh
+++ b/src/hb-ot-shape-complex-use-private.hh
@@ -38,7 +38,7 @@
 #define USE_TABLE_ELEMENT_TYPE uint8_t
 
 /* Cateories used in the Universal Shaping Engine spec:
- * https://www.microsoft.com/typography/OpenTypeDev/USE/intro.htm
+ * https://docs.microsoft.com/en-us/typography/script-development/use
  */
 /* Note: This enum is duplicated in the -machine.rl source file.
  * Not sure how to avoid duplication. */
diff --git a/src/hb-ot-shape-complex-use.cc b/src/hb-ot-shape-complex-use.cc
index ee7653b5..d18ccaaf 100644
--- a/src/hb-ot-shape-complex-use.cc
+++ b/src/hb-ot-shape-complex-use.cc
@@ -35,7 +35,7 @@
 
 /*
  * Universal Shaping Engine.
- * https://www.microsoft.com/typography/OpenTypeDev/USE/intro.htm
+ * https://docs.microsoft.com/en-us/typography/script-development/use
  */
 
 static const hb_tag_t
diff --git a/src/hb-ot-shape-fallback.cc b/src/hb-ot-shape-fallback.cc
index c7b46053..fbf31ab2 100644
--- a/src/hb-ot-shape-fallback.cc
+++ b/src/hb-ot-shape-fallback.cc
@@ -548,7 +548,7 @@ _hb_ot_shape_fallback_spaces (const hb_ot_shape_plan_t *plan,
 
 	case t::SPACE_NARROW:
 	  /* Half-space?
-	   * Unicode doc http://www.unicode.org/charts/PDF/U2000.pdf says ~1/4 or 1/5 of EM.
+	   * Unicode doc https://unicode.org/charts/PDF/U2000.pdf says ~1/4 or 1/5 of EM.
 	   * However, in my testing, many fonts have their regular space being about that
 	   * size.  To me, a percentage of the space width makes more sense.  Half is as
 	   * good as any. */
diff --git a/src/hb-ot-tag.cc b/src/hb-ot-tag.cc
index 1338c317..991d8e77 100644
--- a/src/hb-ot-tag.cc
+++ b/src/hb-ot-tag.cc
@@ -116,8 +116,7 @@ hb_ot_new_tag_to_script (hb_tag_t tag)
 
 /*
  * Complete list at:
- * https://www.microsoft.com/typography/otspec/scripttags.htm
- * https://www.microsoft.com/typography/otspec160/scripttagsProposed.htm
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/scripttags
  *
  * Most of the script tags are the same as the ISO 15924 tag but lowercased.
  * So we just do that, and handle the exceptional cases in a switch.
@@ -159,7 +158,7 @@ typedef struct {
 
 /*
  * Complete list at:
- * http://www.microsoft.com/typography/otspec/languagetags.htm
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/languagetags
  *
  * Generated by intersecting the OpenType language tag list from
  * Draft OpenType 1.5 spec, with with the ISO 639-3 codes from
@@ -176,7 +175,7 @@ typedef struct {
  * Updated as of 2015-05-06: OT1.7 on MS website has some newer
  * items that we don't have here, eg. Zazaki.  This is the new
  * items in OpenType 1.7 (red items), most of which we have:
- * http://www.microsoft.com/typography/otspec170/languagetags.htm
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/languagetags
  */
 
 static const LangTag ot_languages[] = {
@@ -1010,7 +1009,7 @@ hb_ot_tag_from_language (hb_language_t language)
 /**
  * hb_ot_tag_to_language:
  *
- * 
+ *
  *
  * Return value: (transfer none):
  *
diff --git a/src/hb-private.hh b/src/hb-private.hh
index e34bb76a..e40217ee 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -221,8 +221,8 @@ static int errno = 0; /* Use something better? */
 #    endif
 #  elif defined(_MSC_VER) || defined(__MINGW32__)
 /* For MSVC:
- * http://msdn.microsoft.com/en-ca/library/tze57ck3.aspx
- * http://msdn.microsoft.com/en-ca/library/zk17ww08.aspx
+ * https://msdn.microsoft.com/en-us/library/tze57ck3.aspx
+ * https://msdn.microsoft.com/en-us/library/zk17ww08.aspx
  * mingw32 headers say atexit is safe to use in shared libraries.
  */
 #    define HB_USE_ATEXIT 1
diff --git a/src/hb-string-array.hh b/src/hb-string-array.hh
index ba829b0c..d83553dd 100644
--- a/src/hb-string-array.hh
+++ b/src/hb-string-array.hh
@@ -42,7 +42,7 @@ static const union HB_STRING_ARRAY_TYPE_NAME {
   struct {
 /* I like to avoid storing the nul-termination byte since we don't need it,
  * but C++ does not allow that.
- * https://stackoverflow.com/questions/28433862/why-initializer-string-for-array-of-chars-is-too-long-compiles-fine-in-c-not
+ * https://stackoverflow.com/q/28433862
  */
 #define _S(s) char HB_PASTE (str, __LINE__)[sizeof (s)];
 #include HB_STRING_ARRAY_LIST
diff --git a/src/hb-unicode-private.hh b/src/hb-unicode-private.hh
index 82bb9a4d..5472ece2 100644
--- a/src/hb-unicode-private.hh
+++ b/src/hb-unicode-private.hh
@@ -202,8 +202,8 @@ HB_UNICODE_FUNCS_IMPLEMENT_CALLBACKS_SIMPLE
   }
 
   /* Space estimates based on:
-   * http://www.unicode.org/charts/PDF/U2000.pdf
-   * https://www.microsoft.com/typography/developers/fdsspec/spaces.aspx
+   * https://unicode.org/charts/PDF/U2000.pdf
+   * https://docs.microsoft.com/en-us/typography/develop/character-design-standards/whitespace
    */
   enum space_t {
     NOT_SPACE = 0,
@@ -276,10 +276,10 @@ extern HB_INTERNAL const hb_unicode_funcs_t _hb_unicode_funcs_nil;
  * We permute the "fixed-position" classes 10-26 into the order
  * described in the SBL Hebrew manual:
  *
- * http://www.sbl-site.org/Fonts/SBLHebrewUserManual1.5x.pdf
+ * https://www.sbl-site.org/Fonts/SBLHebrewUserManual1.5x.pdf
  *
  * (as recommended by:
- *  http://forum.fontlab.com/archive-old-microsoft-volt-group/vista-and-diacritic-ordering-t6751.0.html)
+ *  https://forum.fontlab.com/archive-old-microsoft-volt-group/vista-and-diacritic-ordering/msg22823/)
  *
  * More details here:
  * https://bugzilla.mozilla.org/show_bug.cgi?id=662055
@@ -306,8 +306,8 @@ extern HB_INTERNAL const hb_unicode_funcs_t _hb_unicode_funcs_nil;
  * Arabic
  *
  * Modify to move Shadda (ccc=33) before other marks.  See:
- * http://unicode.org/faq/normalization.html#8
- * http://unicode.org/faq/normalization.html#9
+ * https://unicode.org/faq/normalization.html#8
+ * https://unicode.org/faq/normalization.html#9
  */
 #define HB_MODIFIED_COMBINING_CLASS_CCC27 28 /* fathatan */
 #define HB_MODIFIED_COMBINING_CLASS_CCC28 29 /* dammatan */
@@ -346,9 +346,9 @@ extern HB_INTERNAL const hb_unicode_funcs_t _hb_unicode_funcs_nil;
 #define HB_MODIFIED_COMBINING_CLASS_CCC122 122 /* mai * */
 
 /* Tibetan
- * 
- * In case of multiple vowel-signs, use u first (but after achung) 
- * this allows Dzongkha multi-vowel shortcuts to render correctly 
+ *
+ * In case of multiple vowel-signs, use u first (but after achung)
+ * this allows Dzongkha multi-vowel shortcuts to render correctly
  */
 #define HB_MODIFIED_COMBINING_CLASS_CCC129 129 /* sign aa */
 #define HB_MODIFIED_COMBINING_CLASS_CCC130 132 /* sign i */
diff --git a/test/api/test-buffer.c b/test/api/test-buffer.c
index b9a0268c..5c98a9a1 100644
--- a/test/api/test-buffer.c
+++ b/test/api/test-buffer.c
@@ -445,7 +445,7 @@ static const utf8_validity_test_t utf8_validity_tests[] = {
   { "\xe2\x89\xa0\xe2\x89\xa0",  5, 3, FALSE },
   { "\xe2\x89\xa0\xe2\x89\xa0",  6, 6, TRUE },
 
-  /* examples from http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt */
+  /* examples from https://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt */
   /* greek 'kosme' */
   { "\xce\xba\xe1\xbd\xb9\xcf\x83\xce\xbc\xce\xb5", -1, 11, TRUE },
   /* first sequence of each length */
diff --git a/test/api/test-ot-tag.c b/test/api/test-ot-tag.c
index 6fe79b42..e821b362 100644
--- a/test/api/test-ot-tag.c
+++ b/test/api/test-ot-tag.c
@@ -31,7 +31,7 @@
 /* Unit tests for hb-ot-tag.h */
 
 
-/* https://www.microsoft.com/typography/otspec/scripttags.htm */
+/* https://docs.microsoft.com/en-us/typography/opentype/spec/scripttags */
 
 static void
 test_simple_tags (const char *s, hb_script_t script)
@@ -112,7 +112,7 @@ test_ot_tag_script_simple (void)
   /* Unicode-5.1 additions */
   test_simple_tags ("vai ", HB_SCRIPT_VAI);
 
-  /* https://www.microsoft.com/typography/otspec160/scripttagsProposed.htm */
+  /* https://docs.microsoft.com/en-us/typography/opentype/spec/scripttags */
 
   /* Unicode-5.2 additions */
   test_simple_tags ("mtei", HB_SCRIPT_MEETEI_MAYEK);
@@ -137,7 +137,7 @@ test_ot_tag_script_indic (void)
 
 
 
-/* https://www.microsoft.com/typography/otspec/languagetags.htm */
+/* https://docs.microsoft.com/en-us/typography/opentype/spec/languagetags */
 
 static void
 test_language_two_way (const char *tag_s, const char *lang_s)
diff --git a/test/api/test-shape.c b/test/api/test-shape.c
index c274f0f7..6232e738 100644
--- a/test/api/test-shape.c
+++ b/test/api/test-shape.c
@@ -154,7 +154,7 @@ test_shape_clusters (void)
   buffer =  hb_buffer_create ();
   hb_buffer_set_direction (buffer, HB_DIRECTION_LTR);
   {
-    /* https://code.google.com/p/chromium/issues/detail?id=497578 */
+    /* https://crbug.com/497578 */
     hb_codepoint_t test[] = {0xFFF1, 0xF0B6};
     hb_buffer_add_utf32 (buffer, test, 2, 0, 2);
   }
commit a02c3ee70f4ca9de1fd55f1d8d535f6bd0d32606
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date:   Thu Apr 12 13:38:19 2018 +0430

    Add or update tables specifications links

diff --git a/src/hb-aat-fmtx-table.hh b/src/hb-aat-fmtx-table.hh
index 6fabf3c5..a9185c37 100644
--- a/src/hb-aat-fmtx-table.hh
+++ b/src/hb-aat-fmtx-table.hh
@@ -27,17 +27,16 @@
 
 #include "hb-aat-layout-common-private.hh"
 
+/*
+ * fmtx -- Font Metrics
+ * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6fmtx.html
+ */
 #define HB_AAT_TAG_fmtx HB_TAG('f','m','t','x')
 
 
 namespace AAT {
 
 
-/*
- * fmtx -- Font metrics
- * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6fmtx.html
- */
-
 struct fmtx
 {
   static const hb_tag_t tableTag = HB_AAT_TAG_fmtx;
diff --git a/src/hb-aat-gcid-table.hh b/src/hb-aat-gcid-table.hh
index d0c45df3..01c2c5c3 100644
--- a/src/hb-aat-gcid-table.hh
+++ b/src/hb-aat-gcid-table.hh
@@ -27,15 +27,15 @@
 
 #include "hb-aat-layout-common-private.hh"
 
+/*
+ * gcid -- Glyphs CIDs
+ * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6gcid.html
+ */
 #define HB_AAT_TAG_gcid HB_TAG('g','c','i','d')
 
 
 namespace AAT {
 
-/*
- * gcid -- Glyphs CIDs
- * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6gcid.html
- */
 
 struct gcid
 {
diff --git a/src/hb-aat-layout-ankr-table.hh b/src/hb-aat-layout-ankr-table.hh
index b3ff925d..dc6582b6 100644
--- a/src/hb-aat-layout-ankr-table.hh
+++ b/src/hb-aat-layout-ankr-table.hh
@@ -27,16 +27,16 @@
 
 #include "hb-aat-layout-common-private.hh"
 
+/*
+ * ankr -- Anchor Point
+ * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6ankr.html
+ */
 #define HB_AAT_TAG_ankr HB_TAG('a','n','k','r')
 
 
 namespace AAT {
 
 
-/*
- * ankr -- Anchor point
- */
-
 struct Anchor
 {
   inline bool sanitize (hb_sanitize_context_t *c) const
diff --git a/src/hb-aat-layout-bsln-table.hh b/src/hb-aat-layout-bsln-table.hh
index 3b9e4fea..a35b4483 100644
--- a/src/hb-aat-layout-bsln-table.hh
+++ b/src/hb-aat-layout-bsln-table.hh
@@ -27,11 +27,16 @@
 
 #include "hb-aat-layout-common-private.hh"
 
+/*
+ * bsln -- Baseline
+ * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bsln.html
+ */
 #define HB_AAT_TAG_bsln HB_TAG('b','s','l','n')
 
 
 namespace AAT {
 
+
 struct BaselineTableFormat0Part
 {
   inline bool sanitize (hb_sanitize_context_t *c) const
@@ -108,11 +113,6 @@ struct BaselineTableFormat3Part
   DEFINE_SIZE_MIN (68);
 };
 
-/*
- * bsln -- Baseline table
- * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6bsln.html
- */
-
 struct bsln
 {
   static const hb_tag_t tableTag = HB_AAT_TAG_bsln;
diff --git a/src/hb-aat-layout-feat-table.hh b/src/hb-aat-layout-feat-table.hh
index 63355470..e7329fe1 100644
--- a/src/hb-aat-layout-feat-table.hh
+++ b/src/hb-aat-layout-feat-table.hh
@@ -27,11 +27,16 @@
 
 #include "hb-aat-layout-common-private.hh"
 
+/*
+ * feat -- Feature Name
+ * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6feat.html
+ */
 #define HB_AAT_TAG_feat HB_TAG('f','e','a','t')
 
 
 namespace AAT {
 
+
 struct SettingName
 {
   inline bool sanitize (hb_sanitize_context_t *c) const
@@ -86,11 +91,6 @@ struct FeatureName
   DEFINE_SIZE_STATIC (12);
 };
 
-/*
- * feat -- Feature name
- * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6feat.html
- */
-
 struct feat
 {
   static const hb_tag_t tableTag = HB_AAT_TAG_feat;
diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh
index bee102dd..756faeff 100644
--- a/src/hb-aat-layout-kerx-table.hh
+++ b/src/hb-aat-layout-kerx-table.hh
@@ -31,6 +31,10 @@
 #include "hb-open-type-private.hh"
 #include "hb-aat-layout-common-private.hh"
 
+/*
+ * kerx -- Extended Kerning
+ * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6kerx.html
+ */
 #define HB_AAT_TAG_kerx HB_TAG('k','e','r','x')
 
 
diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh
index ad3e41c0..f785e726 100644
--- a/src/hb-aat-layout-morx-table.hh
+++ b/src/hb-aat-layout-morx-table.hh
@@ -30,6 +30,10 @@
 #include "hb-open-type-private.hh"
 #include "hb-aat-layout-common-private.hh"
 
+/*
+ * morx -- Extended Glyph Metamorphosis
+ * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6morx.html
+ */
 #define HB_AAT_TAG_morx HB_TAG('m','o','r','x')
 
 
diff --git a/src/hb-aat-layout-trak-table.hh b/src/hb-aat-layout-trak-table.hh
index d720b0cf..a4714883 100644
--- a/src/hb-aat-layout-trak-table.hh
+++ b/src/hb-aat-layout-trak-table.hh
@@ -31,6 +31,10 @@
 #include "hb-aat-layout-common-private.hh"
 #include "hb-open-type-private.hh"
 
+/*
+ * trak -- Tracking
+ * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6trak.html
+ */
 #define HB_AAT_TAG_trak HB_TAG('t','r','a','k')
 
 
diff --git a/src/hb-aat-ltag-table.hh b/src/hb-aat-ltag-table.hh
index 6d6cb716..0796c671 100644
--- a/src/hb-aat-ltag-table.hh
+++ b/src/hb-aat-ltag-table.hh
@@ -27,11 +27,16 @@
 
 #include "hb-aat-layout-common-private.hh"
 
+/*
+ * ltag -- Language Tag
+ * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6ltag.html
+ */
 #define HB_AAT_TAG_ltag HB_TAG('l','t','a','g')
 
 
 namespace AAT {
 
+
 struct FTStringRange
 {
   inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
@@ -49,11 +54,6 @@ struct FTStringRange
   DEFINE_SIZE_STATIC (4);
 };
 
-/*
- * ltag -- Language tags
- * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6ltag.html
- */
-
 struct ltag
 {
   static const hb_tag_t tableTag = HB_AAT_TAG_ltag;
diff --git a/src/hb-ot-color-cbdt-table.hh b/src/hb-ot-color-cbdt-table.hh
index 76893b0a..528d144a 100644
--- a/src/hb-ot-color-cbdt-table.hh
+++ b/src/hb-ot-color-cbdt-table.hh
@@ -29,6 +29,18 @@
 
 #include "hb-open-type-private.hh"
 
+/*
+ * CBLC -- Color Bitmap Location
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/cblc
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/eblc
+ * CBDT -- Color Bitmap Data
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/cbdt
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/ebdt
+ */
+#define HB_OT_TAG_CBLC HB_TAG('C','B','L','C')
+#define HB_OT_TAG_CBDT HB_TAG('C','B','D','T')
+
+
 namespace OT {
 
 struct SmallGlyphMetrics
@@ -322,13 +334,6 @@ struct GlyphBitmapDataFormat19
   DEFINE_SIZE_ARRAY(4, data);
 };
 
-
-/*
- * CBLC -- Color Bitmap Location Table
- */
-
-#define HB_OT_TAG_CBLC HB_TAG('C','B','L','C')
-
 struct CBLC
 {
   friend struct CBDT;
@@ -372,11 +377,6 @@ struct CBLC
   DEFINE_SIZE_ARRAY(8, sizeTables);
 };
 
-/*
- * CBDT -- Color Bitmap Data Table
- */
-#define HB_OT_TAG_CBDT HB_TAG('C','B','D','T')
-
 struct CBDT
 {
   static const hb_tag_t tableTag = HB_OT_TAG_CBDT;
diff --git a/src/hb-ot-color-colr-table.hh b/src/hb-ot-color-colr-table.hh
index 5308b5a1..6e280a3d 100644
--- a/src/hb-ot-color-colr-table.hh
+++ b/src/hb-ot-color-colr-table.hh
@@ -28,12 +28,12 @@
 #include "hb-open-type-private.hh"
 
 /*
- * Color Palette
- * http://www.microsoft.com/typography/otspec/colr.htm
+ * COLR -- Color
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/colr
  */
-
 #define HB_OT_TAG_COLR HB_TAG('C','O','L','R')
 
+
 namespace OT {
 
 
diff --git a/src/hb-ot-color-cpal-table.hh b/src/hb-ot-color-cpal-table.hh
index 0b69c6cb..cb98f7d6 100644
--- a/src/hb-ot-color-cpal-table.hh
+++ b/src/hb-ot-color-cpal-table.hh
@@ -79,12 +79,12 @@ typedef enum { /*< flags >*/
 
 
 /*
- * Color Palette
- * http://www.microsoft.com/typography/otspec/cpal.htm
+ * CPAL -- Color Palette
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/cpal
  */
-
 #define HB_OT_TAG_CPAL HB_TAG('C','P','A','L')
 
+
 namespace OT {
 
 
diff --git a/src/hb-ot-color-sbix-table.hh b/src/hb-ot-color-sbix-table.hh
index 6c9b0052..7dea6140 100644
--- a/src/hb-ot-color-sbix-table.hh
+++ b/src/hb-ot-color-sbix-table.hh
@@ -27,8 +27,14 @@
 
 #include "hb-open-type-private.hh"
 
+/*
+ * sbix -- Standard Bitmap Graphics
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/sbix
+ * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6sbix.html
+ */
 #define HB_OT_TAG_sbix HB_TAG('s','b','i','x')
 
+
 namespace OT {
 
 
@@ -76,11 +82,6 @@ struct SBIXStrike
   DEFINE_SIZE_STATIC (8);
 };
 
-/*
- * sbix -- Standard Bitmap Graphics Table
- * https://docs.microsoft.com/en-us/typography/opentype/spec/sbix
- */
-
 struct sbix
 {
   static const hb_tag_t tableTag = HB_OT_TAG_sbix;
diff --git a/src/hb-ot-color-svg-table.hh b/src/hb-ot-color-svg-table.hh
index 139a012b..1357b788 100644
--- a/src/hb-ot-color-svg-table.hh
+++ b/src/hb-ot-color-svg-table.hh
@@ -28,12 +28,13 @@
 #include "hb-open-type-private.hh"
 
 /*
- * The SVG (Scalable Vector Graphics) table
+ * SVG -- SVG (Scalable Vector Graphics)
  * https://docs.microsoft.com/en-us/typography/opentype/spec/svg
  */
 
 #define HB_OT_TAG_SVG HB_TAG('S','V','G',' ')
 
+
 namespace OT {
 
 
diff --git a/src/hb-ot-glyf-table.hh b/src/hb-ot-glyf-table.hh
index 4eb2ad18..3e8b5eb4 100644
--- a/src/hb-ot-glyf-table.hh
+++ b/src/hb-ot-glyf-table.hh
@@ -38,8 +38,8 @@ namespace OT {
 
 /*
  * loca -- Index to Location
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/loca
  */
-
 #define HB_OT_TAG_loca HB_TAG('l','o','c','a')
 
 
@@ -63,8 +63,8 @@ struct loca
 
 /*
  * glyf -- TrueType Glyph Data
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/glyf
  */
-
 #define HB_OT_TAG_glyf HB_TAG('g','l','y','f')
 
 
diff --git a/src/hb-ot-hdmx-table.hh b/src/hb-ot-hdmx-table.hh
index c0b22b28..4ad78d2e 100644
--- a/src/hb-ot-hdmx-table.hh
+++ b/src/hb-ot-hdmx-table.hh
@@ -29,15 +29,16 @@
 
 #include "hb-open-type-private.hh"
 
-namespace OT {
-
-
 /*
- * hdmx - Horizontal Device Metric
+ * hdmx -- Horizontal Device Metrics
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/hdmx
  */
-
 #define HB_OT_TAG_hdmx HB_TAG('h','d','m','x')
 
+
+namespace OT {
+
+
 struct DeviceRecord
 {
   struct SubsetView
diff --git a/src/hb-ot-head-table.hh b/src/hb-ot-head-table.hh
index 1d458404..965e30a0 100644
--- a/src/hb-ot-head-table.hh
+++ b/src/hb-ot-head-table.hh
@@ -31,16 +31,16 @@
 
 #include "hb-open-type-private.hh"
 
-
-namespace OT {
-
-
 /*
  * head -- Font Header
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/head
  */
-
 #define HB_OT_TAG_head HB_TAG('h','e','a','d')
 
+
+namespace OT {
+
+
 struct head
 {
   friend struct OffsetTable;
diff --git a/src/hb-ot-hhea-table.hh b/src/hb-ot-hhea-table.hh
index 97952b4e..efb42b61 100644
--- a/src/hb-ot-hhea-table.hh
+++ b/src/hb-ot-hhea-table.hh
@@ -29,18 +29,19 @@
 
 #include "hb-open-type-private.hh"
 
-
-namespace OT {
-
-
 /*
- * hhea -- The Horizontal Header Table
- * vhea -- The Vertical Header Table
+ * hhea -- Horizontal Header
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/hhea
+ * vhea -- Vertical Header
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/vhea
  */
-
 #define HB_OT_TAG_hhea HB_TAG('h','h','e','a')
 #define HB_OT_TAG_vhea HB_TAG('v','h','e','a')
 
+
+namespace OT {
+
+
 template <typename T>
 struct _hea
 {
diff --git a/src/hb-ot-hmtx-table.hh b/src/hb-ot-hmtx-table.hh
index 2af9a5cc..bfc3e6a2 100644
--- a/src/hb-ot-hmtx-table.hh
+++ b/src/hb-ot-hmtx-table.hh
@@ -32,19 +32,19 @@
 #include "hb-ot-os2-table.hh"
 #include "hb-ot-var-hvar-table.hh"
 
-
-namespace OT {
-
-
 /*
- * hmtx -- The Horizontal Metrics Table
- * vmtx -- The Vertical Metrics Table
+ * hmtx -- Horizontal Metrics
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/hmtx
+ * vmtx -- Vertical Metrics
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/vmtx
  */
-
 #define HB_OT_TAG_hmtx HB_TAG('h','m','t','x')
 #define HB_OT_TAG_vmtx HB_TAG('v','m','t','x')
 
 
+namespace OT {
+
+
 struct LongMetric
 {
   UFWORD	advance; /* Advance width/height. */
diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh
index 4d379eaa..ec331698 100644
--- a/src/hb-ot-kern-table.hh
+++ b/src/hb-ot-kern-table.hh
@@ -29,15 +29,17 @@
 
 #include "hb-open-type-private.hh"
 
-namespace OT {
-
-
 /*
  * kern -- Kerning
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/kern
+ * https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6kern.html
  */
-
 #define HB_OT_TAG_kern HB_TAG('k','e','r','n')
 
+
+namespace OT {
+
+
 struct hb_glyph_pair_t
 {
   hb_codepoint_t left;
diff --git a/src/hb-ot-layout-base-table.hh b/src/hb-ot-layout-base-table.hh
index 20b8bd76..33dce890 100644
--- a/src/hb-ot-layout-base-table.hh
+++ b/src/hb-ot-layout-base-table.hh
@@ -36,7 +36,8 @@ namespace OT {
 #define NOT_INDEXED   ((unsigned int) -1)
 
 /*
- * BASE -- The BASE Table
+ * BASE -- Baseline
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/base
  */
 
 struct BaseCoordFormat1
diff --git a/src/hb-ot-layout-gdef-table.hh b/src/hb-ot-layout-gdef-table.hh
index 2d6c66e6..60a8d3ad 100644
--- a/src/hb-ot-layout-gdef-table.hh
+++ b/src/hb-ot-layout-gdef-table.hh
@@ -333,7 +333,8 @@ struct MarkGlyphSets
 
 
 /*
- * GDEF -- The Glyph Definition Table
+ * GDEF -- Glyph Definition
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/gdef
  */
 
 struct GDEF
diff --git a/src/hb-ot-layout-gpos-table.hh b/src/hb-ot-layout-gpos-table.hh
index 46ffcc66..62517077 100644
--- a/src/hb-ot-layout-gpos-table.hh
+++ b/src/hb-ot-layout-gpos-table.hh
@@ -1497,7 +1497,8 @@ struct PosLookup : Lookup
 typedef OffsetListOf<PosLookup> PosLookupList;
 
 /*
- * GPOS -- The Glyph Positioning Table
+ * GPOS -- Glyph Positioning
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/gpos
  */
 
 struct GPOS : GSUBGPOS
diff --git a/src/hb-ot-layout-gsub-table.hh b/src/hb-ot-layout-gsub-table.hh
index 5f67aed2..059f663d 100644
--- a/src/hb-ot-layout-gsub-table.hh
+++ b/src/hb-ot-layout-gsub-table.hh
@@ -1287,7 +1287,8 @@ struct SubstLookup : Lookup
 typedef OffsetListOf<SubstLookup> SubstLookupList;
 
 /*
- * GSUB -- The Glyph Substitution Table
+ * GSUB -- Glyph Substitution
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/gsub
  */
 
 struct GSUB : GSUBGPOS
diff --git a/src/hb-ot-layout-jstf-table.hh b/src/hb-ot-layout-jstf-table.hh
index adbaad64..7fabdebb 100644
--- a/src/hb-ot-layout-jstf-table.hh
+++ b/src/hb-ot-layout-jstf-table.hh
@@ -189,7 +189,8 @@ struct JstfScript
 
 
 /*
- * JSTF -- The Justification Table
+ * JSTF -- Justification
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/jstf
  */
 
 struct JSTF
diff --git a/src/hb-ot-math-table.hh b/src/hb-ot-math-table.hh
index 571ce01b..5fef2d28 100644
--- a/src/hb-ot-math-table.hh
+++ b/src/hb-ot-math-table.hh
@@ -678,7 +678,8 @@ struct MathVariants
 
 
 /*
- * MATH -- The MATH Table
+ * MATH -- Mathematical typesetting
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/math
  */
 
 struct MATH
diff --git a/src/hb-ot-maxp-table.hh b/src/hb-ot-maxp-table.hh
index 881dedad..92720746 100644
--- a/src/hb-ot-maxp-table.hh
+++ b/src/hb-ot-maxp-table.hh
@@ -34,7 +34,8 @@ namespace OT {
 
 
 /*
- * maxp -- The Maximum Profile Table
+ * maxp -- Maximum Profile
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/maxp
  */
 
 #define HB_OT_TAG_maxp HB_TAG('m','a','x','p')
diff --git a/src/hb-ot-name-table.hh b/src/hb-ot-name-table.hh
index eb013337..bff85df2 100644
--- a/src/hb-ot-name-table.hh
+++ b/src/hb-ot-name-table.hh
@@ -34,9 +34,9 @@ namespace OT {
 
 
 /*
- * name -- The Naming Table
+ * name -- Naming
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/name
  */
-
 #define HB_OT_TAG_name HB_TAG('n','a','m','e')
 
 
diff --git a/src/hb-ot-os2-table.hh b/src/hb-ot-os2-table.hh
index 6cb8d494..93c0fff2 100644
--- a/src/hb-ot-os2-table.hh
+++ b/src/hb-ot-os2-table.hh
@@ -34,9 +34,8 @@ namespace OT {
 
 /*
  * OS/2 and Windows Metrics
- * http://www.microsoft.com/typography/otspec/os2.htm
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/os2
  */
-
 #define HB_OT_TAG_os2 HB_TAG('O','S','/','2')
 
 struct os2
diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh
index c5ad6654..12e4cc92 100644
--- a/src/hb-ot-post-table.hh
+++ b/src/hb-ot-post-table.hh
@@ -38,16 +38,16 @@
 
 #define NUM_FORMAT1_NAMES 258
 
-namespace OT {
-
-
 /*
  * post -- PostScript
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/post
  */
-
 #define HB_OT_TAG_post HB_TAG('p','o','s','t')
 
 
+namespace OT {
+
+
 struct postV2Tail
 {
   inline bool sanitize (hb_sanitize_context_t *c) const
diff --git a/src/hb-ot-var-avar-table.hh b/src/hb-ot-var-avar-table.hh
index e305a67c..feaa525e 100644
--- a/src/hb-ot-var-avar-table.hh
+++ b/src/hb-ot-var-avar-table.hh
@@ -29,6 +29,14 @@
 
 #include "hb-open-type-private.hh"
 
+/*
+ * avar -- Axis Variations
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/avar
+ */
+
+#define HB_OT_TAG_avar HB_TAG('a','v','a','r')
+
+
 namespace OT {
 
 
@@ -88,12 +96,6 @@ struct SegmentMaps : ArrayOf<AxisValueMap>
   DEFINE_SIZE_ARRAY (2, array);
 };
 
-/*
- * avar — Axis Variations Table
- */
-
-#define HB_OT_TAG_avar HB_TAG('a','v','a','r')
-
 struct avar
 {
   static const hb_tag_t tableTag	= HB_OT_TAG_avar;
diff --git a/src/hb-ot-var-fvar-table.hh b/src/hb-ot-var-fvar-table.hh
index 17ff0e51..82d29968 100644
--- a/src/hb-ot-var-fvar-table.hh
+++ b/src/hb-ot-var-fvar-table.hh
@@ -29,6 +29,14 @@
 
 #include "hb-open-type-private.hh"
 
+/*
+ * fvar -- Font Variations
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/fvar
+ */
+
+#define HB_OT_TAG_fvar HB_TAG('f','v','a','r')
+
+
 namespace OT {
 
 
@@ -75,13 +83,6 @@ struct AxisRecord
   DEFINE_SIZE_STATIC (20);
 };
 
-
-/*
- * fvar — Font Variations Table
- */
-
-#define HB_OT_TAG_fvar HB_TAG('f','v','a','r')
-
 struct fvar
 {
   static const hb_tag_t tableTag	= HB_OT_TAG_fvar;
diff --git a/src/hb-ot-var-hvar-table.hh b/src/hb-ot-var-hvar-table.hh
index e20131b1..2b384db7 100644
--- a/src/hb-ot-var-hvar-table.hh
+++ b/src/hb-ot-var-hvar-table.hh
@@ -89,10 +89,11 @@ struct DeltaSetIndexMap
 
 
 /*
- * HVAR -- The Horizontal Metrics Variations Table
- * VVAR -- The Vertical Metrics Variations Table
+ * HVAR -- Horizontal Metrics Variations
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/hvar
+ * VVAR -- Vertical Metrics Variations
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/vvar
  */
-
 #define HB_OT_TAG_HVAR HB_TAG('H','V','A','R')
 #define HB_OT_TAG_VVAR HB_TAG('V','V','A','R')
 
diff --git a/src/hb-ot-var-mvar-table.hh b/src/hb-ot-var-mvar-table.hh
index e8357685..dfde782f 100644
--- a/src/hb-ot-var-mvar-table.hh
+++ b/src/hb-ot-var-mvar-table.hh
@@ -51,9 +51,9 @@ struct VariationValueRecord
 
 
 /*
- * MVAR -- Metrics Variations Table
+ * MVAR -- Metrics Variations
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/mvar
  */
-
 #define HB_OT_TAG_MVAR HB_TAG('M','V','A','R')
 
 struct MVAR
commit b799fc80777c1424e469a835f782b4e0f41c0043
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date:   Wed Apr 11 18:36:09 2018 +0430

    minor, use LOffsetTo and LArrayOf whenever possible (#966)

diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh
index 54255de8..ad3e41c0 100644
--- a/src/hb-aat-layout-morx-table.hh
+++ b/src/hb-aat-layout-morx-table.hh
@@ -302,9 +302,10 @@ struct ContextualSubtable
   }
 
   protected:
-  StateTable<EntryData>	machine;
-  OffsetTo<UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT32>, HBUINT32>
-			substitutionTables;
+  StateTable<EntryData>
+		machine;
+  LOffsetTo<UnsizedOffsetListOf<Lookup<GlyphID>, HBUINT32> >
+		substitutionTables;
   public:
   DEFINE_SIZE_STATIC (20);
 };
@@ -461,7 +462,8 @@ struct LigatureSubtable
   }
 
   protected:
-  StateTable<EntryData>	machine;
+  StateTable<EntryData>
+		machine;
   LOffsetTo<UnsizedArrayOf<HBUINT32> >
 		ligAction;	/* Offset to the ligature action table. */
   LOffsetTo<UnsizedArrayOf<HBUINT16> >
diff --git a/src/hb-aat-ltag-table.hh b/src/hb-aat-ltag-table.hh
index 2fd59b6a..6d6cb716 100644
--- a/src/hb-aat-ltag-table.hh
+++ b/src/hb-aat-ltag-table.hh
@@ -67,7 +67,7 @@ struct ltag
   protected:
   HBUINT32	version;	/* Table version; currently 1 */
   HBUINT32	flags;		/* Table flags; currently none defined */
-  ArrayOf<FTStringRange, HBUINT32>
+  LArrayOf<FTStringRange>
 		tagRanges;	/* Range for each tag's string */
   public:
   DEFINE_SIZE_ARRAY (12, tagRanges);
diff --git a/src/hb-open-file-private.hh b/src/hb-open-file-private.hh
index ac027520..28f967dd 100644
--- a/src/hb-open-file-private.hh
+++ b/src/hb-open-file-private.hh
@@ -234,7 +234,7 @@ struct TTCHeaderVersion1
   Tag		ttcTag;		/* TrueType Collection ID string: 'ttcf' */
   FixedVersion<>version;	/* Version of the TTC Header (1.0),
 				 * 0x00010000u */
-  ArrayOf<LOffsetTo<OffsetTable>, HBUINT32>
+  LArrayOf<LOffsetTo<OffsetTable> >
 		table;		/* Array of offsets to the OffsetTable for each font
 				 * from the beginning of the file */
   public:
diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh
index 02079898..4114b35d 100644
--- a/src/hb-ot-cmap-table.hh
+++ b/src/hb-ot-cmap-table.hh
@@ -284,8 +284,8 @@ struct CmapSubtableLongSegmented
   protected:
   HBUINT16	format;		/* Subtable format; set to 12. */
   HBUINT16	reservedZ;	/* Reserved; set to 0. */
-  HBUINT32		lengthZ;	/* Byte length of this subtable. */
-  HBUINT32		languageZ;	/* Ignore. */
+  HBUINT32	lengthZ;	/* Byte length of this subtable. */
+  HBUINT32	languageZ;	/* Ignore. */
   SortedArrayOf<CmapSubtableLongGroup, HBUINT32>
 		groups;		/* Groupings. */
   public:
commit cb3fa70cd4c33e9f1c736f778cb3b606d15c0936
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date:   Wed Apr 11 18:00:13 2018 +0430

    [dwrite] Cosmetic change (#963)

diff --git a/src/hb-directwrite.cc b/src/hb-directwrite.cc
index 3175fe05..01261891 100644
--- a/src/hb-directwrite.cc
+++ b/src/hb-directwrite.cc
@@ -1,4 +1,4 @@
-/*
+/*
  * Copyright © 2015-2018  Ebrahim Byagowi
  *
  *  This is part of HarfBuzz, a text shaping library.
@@ -304,8 +304,8 @@ public:
 
     inline bool ContainsTextPosition (uint32_t aTextPosition) const
     {
-      return aTextPosition >= mTextStart
-        && aTextPosition <  mTextStart + mTextLength;
+      return aTextPosition >= mTextStart &&
+	     aTextPosition <  mTextStart + mTextLength;
     }
 
     Run *nextRun;
@@ -485,11 +485,10 @@ protected:
     for (Run *run = &mRunHead; run; run = run->nextRun)
       if (run->ContainsTextPosition (textPosition))
       {
-        mCurrentRun = run;
-        return;
+	mCurrentRun = run;
+	return;
       }
-    //NS_NOTREACHED ("We should always be able to find the text position in one \
-            //                of our runs");
+    // NS_NOTREACHED ("We should always be able to find the text position in one of our runs");
   }
 
   void SplitCurrentRun (uint32_t splitPosition)
@@ -655,7 +654,7 @@ _hb_directwrite_shape_full (hb_shape_plan_t    *shape_plan,
     for (unsigned int i = 0; i < num_features; ++i)
     {
       typographic_features.features[i].nameTag = (DWRITE_FONT_FEATURE_TAG)
-        hb_uint32_swap (features[i].tag);
+	hb_uint32_swap (features[i].tag);
       typographic_features.features[i].parameter = features[i].value;
     }
   }
@@ -760,27 +759,27 @@ retry_getglyphs:
       uint16_t* modifiedGlyphIndices = new uint16_t[maxGlyphCount];
       float* modifiedGlyphAdvances = new float[maxGlyphCount];
       DWRITE_GLYPH_OFFSET* modifiedGlyphOffsets =
-        new DWRITE_GLYPH_OFFSET[maxGlyphCount];
+	new DWRITE_GLYPH_OFFSET[maxGlyphCount];
       uint32_t actualGlyphsCount;
       hr = analyzer1->GetJustifiedGlyphs (fontFace, fontEmSize, runHead->mScript,
-        textLength, glyphCount, maxGlyphCount, clusterMap, glyphIndices,
-        glyphAdvances, justifiedGlyphAdvances, justifiedGlyphOffsets,
-        glyphProperties, &actualGlyphsCount, modifiedClusterMap, modifiedGlyphIndices,
-        modifiedGlyphAdvances, modifiedGlyphOffsets);
+	textLength, glyphCount, maxGlyphCount, clusterMap, glyphIndices,
+	glyphAdvances, justifiedGlyphAdvances, justifiedGlyphOffsets,
+	glyphProperties, &actualGlyphsCount, modifiedClusterMap, modifiedGlyphIndices,
+	modifiedGlyphAdvances, modifiedGlyphOffsets);
 
       if (hr == HRESULT_FROM_WIN32 (ERROR_INSUFFICIENT_BUFFER))
       {
-        maxGlyphCount = actualGlyphsCount;
-        delete [] modifiedGlyphIndices;
-        delete [] modifiedGlyphAdvances;
-        delete [] modifiedGlyphOffsets;
+	maxGlyphCount = actualGlyphsCount;
+	delete [] modifiedGlyphIndices;
+	delete [] modifiedGlyphAdvances;
+	delete [] modifiedGlyphOffsets;
 
-        maxGlyphCount = actualGlyphsCount;
+	maxGlyphCount = actualGlyphsCount;
 
-        goto retry_getjustifiedglyphs;
+	goto retry_getjustifiedglyphs;
       }
       if (FAILED (hr))
-        FAIL ("Analyzer failed to get justified glyphs.");
+	FAIL ("Analyzer failed to get justified glyphs.");
 
       delete [] clusterMap;
       delete [] glyphIndices;
diff --git a/src/hb-directwrite.h b/src/hb-directwrite.h
index e743af21..9bfd1f72 100644
--- a/src/hb-directwrite.h
+++ b/src/hb-directwrite.h
@@ -30,8 +30,9 @@
 HB_BEGIN_DECLS
 
 HB_EXTERN hb_bool_t
-hb_directwrite_shape_experimental_width(hb_font_t *font, hb_buffer_t *buffer,
-  const hb_feature_t *features, unsigned int num_features, float width);
+hb_directwrite_shape_experimental_width (hb_font_t *font, hb_buffer_t *buffer,
+					 const hb_feature_t *features,
+					 unsigned int num_features, float width);
 
 HB_END_DECLS
 
commit 09d5e5468858f4403ce91aca46749397b23825d9
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date:   Wed Apr 11 17:41:48 2018 +0430

    [graphite] Use tabs instead 8 spaces (#965)

diff --git a/src/hb-graphite2.cc b/src/hb-graphite2.cc
index 5d95ca57..c20f6bef 100644
--- a/src/hb-graphite2.cc
+++ b/src/hb-graphite2.cc
@@ -383,11 +383,11 @@ _hb_graphite2_shape (hb_shape_plan_t    *shape_plan,
       pPos->x_offset = gr_slot_origin_X (is) * xscale - curradvx;
       pPos->y_offset = gr_slot_origin_Y (is) * yscale - curradvy;
       if (info->cluster != currclus) {
-        pPos->x_advance = info->var1.i32 * xscale;
-        curradvx += pPos->x_advance;
-        currclus = info->cluster;
+	pPos->x_advance = info->var1.i32 * xscale;
+	curradvx += pPos->x_advance;
+	currclus = info->cluster;
       } else
-        pPos->x_advance = 0.;
+	pPos->x_advance = 0.;
 
       pPos->y_advance = gr_slot_advance_Y (is, grface, nullptr) * yscale;
       curradvy += pPos->y_advance;
@@ -400,11 +400,11 @@ _hb_graphite2_shape (hb_shape_plan_t    *shape_plan,
     {
       if (info->cluster != currclus)
       {
-        pPos->x_advance = info->var1.i32 * xscale;
-        curradvx -= pPos->x_advance;
-        currclus = info->cluster;
+	pPos->x_advance = info->var1.i32 * xscale;
+	curradvx -= pPos->x_advance;
+	currclus = info->cluster;
       } else
-        pPos->x_advance = 0.;
+	pPos->x_advance = 0.;
 
       pPos->y_advance = gr_slot_advance_Y (is, grface, nullptr) * yscale;
       curradvy -= pPos->y_advance;
commit 211da5efdcaff203eafda2a5081cd81e3d6cc35b
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date:   Wed Apr 11 17:41:24 2018 +0430

    [aat] Cosmetic changes (#964)

diff --git a/src/hb-aat-gcid-table.hh b/src/hb-aat-gcid-table.hh
index 57fbbad4..d0c45df3 100644
--- a/src/hb-aat-gcid-table.hh
+++ b/src/hb-aat-gcid-table.hh
@@ -52,10 +52,10 @@ struct gcid
   HBUINT16	format;		/* Data format (set to 0) */
   HBUINT32	size;		/* Size of the table, including header */
   HBUINT16	registry;	/* The registry ID */
-  uint8_t	registryName[64];
+  HBUINT8	registryName[64];
 				/* The registry name in ASCII */
   HBUINT16	order;		/* The order ID */
-  uint8_t	orderName[64];	/* The order name in ASCII */
+  HBUINT8	orderName[64];	/* The order name in ASCII */
   HBUINT16	supplementVersion;
 				/* The supplement version */
   ArrayOf<HBUINT16>
diff --git a/src/hb-aat-layout-ankr-table.hh b/src/hb-aat-layout-ankr-table.hh
index d0453bd8..b3ff925d 100644
--- a/src/hb-aat-layout-ankr-table.hh
+++ b/src/hb-aat-layout-ankr-table.hh
@@ -64,11 +64,12 @@ struct ankr
   }
 
   protected:
-  HBUINT16			version; 	/* Version number (set to zero) */
-  HBUINT16			flags;		/* Flags (currently unused; set to zero) */
-  LOffsetTo<Lookup<HBUINT16> >	lookupTable;	/* Offset to the table's lookup table */
-  LOffsetTo<ArrayOf<Anchor, HBUINT32> >
-				anchors;	/* Offset to the glyph data table */
+  HBUINT16	version; 	/* Version number (set to zero) */
+  HBUINT16	flags;		/* Flags (currently unused; set to zero) */
+  LOffsetTo<Lookup<HBUINT16> >
+		lookupTable;	/* Offset to the table's lookup table */
+  LOffsetTo<LArrayOf<Anchor> >
+		anchors;	/* Offset to the glyph data table */
 
   public:
   DEFINE_SIZE_STATIC (12);
diff --git a/src/hb-aat-layout-common-private.hh b/src/hb-aat-layout-common-private.hh
index 454b141f..f7a7b86f 100644
--- a/src/hb-aat-layout-common-private.hh
+++ b/src/hb-aat-layout-common-private.hh
@@ -511,11 +511,11 @@ struct StateTable
   protected:
   HBUINT32	nClasses;	/* Number of classes, which is the number of indices
 				 * in a single line in the state array. */
-  OffsetTo<Lookup<HBUINT16>, HBUINT32>
+  LOffsetTo<Lookup<HBUINT16> >
 		classTable;	/* Offset to the class table. */
-  OffsetTo<UnsizedArrayOf<HBUINT16>, HBUINT32>
+  LOffsetTo<UnsizedArrayOf<HBUINT16> >
 		stateArrayTable;/* Offset to the state array. */
-  OffsetTo<UnsizedArrayOf<Entry<Extra> >, HBUINT32>
+  LOffsetTo<UnsizedArrayOf<Entry<Extra> > >
 		entryTable;	/* Offset to the entry array. */
 
   public:
diff --git a/src/hb-aat-layout-kerx-table.hh b/src/hb-aat-layout-kerx-table.hh
index d0624ecc..bee102dd 100644
--- a/src/hb-aat-layout-kerx-table.hh
+++ b/src/hb-aat-layout-kerx-table.hh
@@ -71,21 +71,22 @@ struct KerxSubTableFormat0
   {
     TRACE_SANITIZE (this);
     return_trace (c->check_struct (this) &&
-      c->check_array (records, records[0].static_size, nPairs));
+		  recordsZ.sanitize (c, nPairs));
   }
 
   protected:
   // TODO(ebraminio): A custom version of "BinSearchArrayOf<KerxPair> pairs;" is
   // needed here to use HBUINT32 instead
-  HBUINT32 nPairs;	/* The number of kerning pairs in this subtable */
-  HBUINT32 searchRange; /* The largest power of two less than or equal to the value of nPairs,
-                         * multiplied by the size in bytes of an entry in the subtable. */
-  HBUINT32 entrySelector; /* This is calculated as log2 of the largest power of two less
-                           * than or equal to the value of nPairs. */
-  HBUINT32 rangeShift;	/* The value of nPairs minus the largest power of two less than or equal to nPairs. */
-  KerxFormat0Records records[VAR]; /* VAR=nPairs */
+  HBUINT32	nPairs;		/* The number of kerning pairs in this subtable */
+  HBUINT32	searchRange;	/* The largest power of two less than or equal to the value of nPairs,
+				 * multiplied by the size in bytes of an entry in the subtable. */
+  HBUINT32	entrySelector;	/* This is calculated as log2 of the largest power of two less
+				 * than or equal to the value of nPairs. */
+  HBUINT32	rangeShift;	/* The value of nPairs minus the largest power of two less than or equal to nPairs. */
+  UnsizedArrayOf<KerxFormat0Records>
+		recordsZ;	/* VAR=nPairs */
   public:
-  DEFINE_SIZE_ARRAY (16, records);
+  DEFINE_SIZE_ARRAY (16, recordsZ);
 };
 
 struct KerxSubTableFormat1
@@ -94,7 +95,7 @@ struct KerxSubTableFormat1
   {
     TRACE_SANITIZE (this);
     return_trace (c->check_struct (this) &&
-      stateHeader.sanitize (c));
+		  stateHeader.sanitize (c));
   }
 
   protected:
@@ -196,10 +197,10 @@ struct KerxSubTableFormat6
   {
     TRACE_SANITIZE (this);
     return_trace (c->check_struct (this) &&
-      rowIndexTable.sanitize (c, this) &&
-      columnIndexTable.sanitize (c, this) &&
-      kerningArray.sanitize (c, this) &&
-      kerningVector.sanitize (c, this));
+		  rowIndexTable.sanitize (c, this) &&
+		  columnIndexTable.sanitize (c, this) &&
+		  kerningArray.sanitize (c, this) &&
+		  kerningVector.sanitize (c, this));
   }
 
   protected:
diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh
index 2ec25893..54255de8 100644
--- a/src/hb-aat-layout-morx-table.hh
+++ b/src/hb-aat-layout-morx-table.hh
@@ -462,11 +462,11 @@ struct LigatureSubtable
 
   protected:
   StateTable<EntryData>	machine;
-  OffsetTo<UnsizedArrayOf<HBUINT32>, HBUINT32>
+  LOffsetTo<UnsizedArrayOf<HBUINT32> >
 		ligAction;	/* Offset to the ligature action table. */
-  OffsetTo<UnsizedArrayOf<HBUINT16>, HBUINT32>
+  LOffsetTo<UnsizedArrayOf<HBUINT16> >
 		component;	/* Offset to the component table. */
-  OffsetTo<UnsizedArrayOf<GlyphID>, HBUINT32>
+  LOffsetTo<UnsizedArrayOf<GlyphID> >
 		ligature;	/* Offset to the actual ligature lists. */
   public:
   DEFINE_SIZE_STATIC (28);
diff --git a/src/hb-aat-layout-trak-table.hh b/src/hb-aat-layout-trak-table.hh
index ab743733..d720b0cf 100644
--- a/src/hb-aat-layout-trak-table.hh
+++ b/src/hb-aat-layout-trak-table.hh
@@ -122,12 +122,12 @@ struct TrackData
   }
 
   protected:
-  HBUINT16		nTracks;	/* Number of separate tracks included in this table. */
-  HBUINT16		nSizes;		/* Number of point sizes included in this table. */
-  LOffsetTo<UnsizedArrayOf<Fixed> >	/* Offset to array[nSizes] of size values. */
-			sizeTable;
+  HBUINT16	nTracks;	/* Number of separate tracks included in this table. */
+  HBUINT16	nSizes;		/* Number of point sizes included in this table. */
+  LOffsetTo<UnsizedArrayOf<Fixed> >
+		sizeTable;	/* Offset to array[nSizes] of size values. */
   UnsizedArrayOf<TrackTableEntry>
-			trackTable;	/* Array[nTracks] of TrackTableEntry records. */
+		trackTable;	/* Array[nTracks] of TrackTableEntry records. */
 
   public:
   DEFINE_SIZE_ARRAY (8, trackTable);
diff --git a/src/hb-aat-ltag-table.hh b/src/hb-aat-ltag-table.hh
index 61f69bc9..2fd59b6a 100644
--- a/src/hb-aat-ltag-table.hh
+++ b/src/hb-aat-ltag-table.hh
@@ -37,14 +37,14 @@ struct FTStringRange
   inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
   {
     TRACE_SANITIZE (this);
-    return_trace (c->check_struct (this) && tag (base).sanitize (c, length));
+    return_trace (c->check_struct (this) && (base+tag).sanitize (c, length));
   }
 
   protected:
   OffsetTo<UnsizedArrayOf<HBUINT8> >
-		tag;	/* Offset from the start of the table to
-			 * the beginning of the string */
-  HBUINT16	length;	/* String length (in bytes) */
+		tag;		/* Offset from the start of the table to
+				 * the beginning of the string */
+  HBUINT16	length;		/* String length (in bytes) */
   public:
   DEFINE_SIZE_STATIC (4);
 };
commit f8bb582bcc2af6cae531d8255da002f0c514f1a9
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date:   Wed Apr 11 17:13:20 2018 +0430

    [ot-color] Cosmetic changes (#962)

diff --git a/src/hb-open-type-private.hh b/src/hb-open-type-private.hh
index 5060b3eb..beefff14 100644
--- a/src/hb-open-type-private.hh
+++ b/src/hb-open-type-private.hh
@@ -909,7 +909,6 @@ struct UnsizedArrayOf
     return_trace (true);
   }
 
-  private:
   inline bool sanitize_shallow (hb_sanitize_context_t *c, unsigned int count) const
   {
     TRACE_SANITIZE (this);
diff --git a/src/hb-ot-color-cbdt-table.hh b/src/hb-ot-color-cbdt-table.hh
index cf1c69c1..76893b0a 100644
--- a/src/hb-ot-color-cbdt-table.hh
+++ b/src/hb-ot-color-cbdt-table.hh
@@ -301,23 +301,23 @@ struct BitmapSizeTable
 
 struct GlyphBitmapDataFormat17
 {
-  SmallGlyphMetrics		glyphMetrics;
-  ArrayOf<HBUINT8, HBUINT32>	data;
+  SmallGlyphMetrics	glyphMetrics;
+  LArrayOf<HBUINT8>	data;
   public:
   DEFINE_SIZE_ARRAY(9, data);
 };
 
 struct GlyphBitmapDataFormat18
 {
-  BigGlyphMetrics		glyphMetrics;
-  ArrayOf<HBUINT8, HBUINT32>	data;
+  BigGlyphMetrics	glyphMetrics;
+  LArrayOf<HBUINT8>	data;
   public:
   DEFINE_SIZE_ARRAY(12, data);
 };
 
 struct GlyphBitmapDataFormat19
 {
-  ArrayOf<HBUINT8, HBUINT32>	data;
+  LArrayOf<HBUINT8>	data;
   public:
   DEFINE_SIZE_ARRAY(4, data);
 };
diff --git a/src/hb-ot-color-cpal-table.hh b/src/hb-ot-color-cpal-table.hh
index 7feb3e1b..0b69c6cb 100644
--- a/src/hb-ot-color-cpal-table.hh
+++ b/src/hb-ot-color-cpal-table.hh
@@ -144,13 +144,13 @@ struct CPAL
   {
     TRACE_SANITIZE (this);
     if (!(c->check_struct (this) && // it checks colorRecordIndices also, see #get_size
-          (this+colorRecordsZ).sanitize (c, numColorRecords)))
+	  (this+colorRecordsZ).sanitize (c, numColorRecords)))
       return_trace (false);
 
     // Check for indices sanity so no need for doing it runtime
     for (unsigned int i = 0; i < numPalettes; ++i)
       if (colorRecordIndicesZ[i] + numPaletteEntries > numColorRecords)
-        return_trace (false);
+	return_trace (false);
 
     // If version is zero, we are done here; otherwise we need to check tail also
     if (version == 0)
diff --git a/src/hb-ot-color-sbix-table.hh b/src/hb-ot-color-sbix-table.hh
index bc3956d8..6c9b0052 100644
--- a/src/hb-ot-color-sbix-table.hh
+++ b/src/hb-ot-color-sbix-table.hh
@@ -45,7 +45,8 @@ struct SBIXGlyph
   Tag		graphicType;	/* Indicates the format of the embedded graphic
 				 * data: one of 'jpg ', 'png ' or 'tiff', or the
 				 * special format 'dupe'. */
-  HBUINT8	data[VAR];	/* The actual embedded graphic data. The total
+  UnsizedArrayOf<HBUINT8>
+		data;		/* The actual embedded graphic data. The total
 				 * length is inferred from sequential entries in
 				 * the glyphDataOffsets array and the fixed size
 				 * (8 bytes) of the preceding fields. */
@@ -61,18 +62,16 @@ struct SBIXStrike
   {
     TRACE_SANITIZE (this);
     return_trace (c->check_struct (this) &&
-		  c->check_array (imageOffsetsZ,
-				  sizeof (HBUINT32),
-				  1 + c->num_glyphs));
+		  imageOffsetsZ.sanitize_shallow (c, c->num_glyphs + 1));
   }
 
-  HBUINT16		ppem;		/* The PPEM size for which this strike was designed. */
-  HBUINT16		resolution;	/* The device pixel density (in PPI) for which this
-					 * strike was designed. (E.g., 96 PPI, 192 PPI.) */
   protected:
-  LOffsetTo<SBIXGlyph>	imageOffsetsZ[VAR]; // VAR=maxp.numGlyphs + 1
-					/* Offset from the beginning of the strike data header
-					 * to bitmap data for an individual glyph ID. */
+  HBUINT16	ppem;		/* The PPEM size for which this strike was designed. */
+  HBUINT16	resolution;	/* The device pixel density (in PPI) for which this
+				 * strike was designed. (E.g., 96 PPI, 192 PPI.) */
+  UnsizedArrayOf<LOffsetTo<SBIXGlyph> >
+		imageOffsetsZ;	/* Offset from the beginning of the strike data header
+				 * to bitmap data for an individual glyph ID. */
   public:
   DEFINE_SIZE_STATIC (8);
 };
@@ -112,19 +111,19 @@ struct sbix
     }
 
     inline void dump (void (*callback) (const uint8_t* data, unsigned int length,
-        unsigned int group, unsigned int gid)) const
+					unsigned int group, unsigned int gid)) const
     {
       for (unsigned group = 0; group < sbix_table->strikes.len; ++group)
       {
-        const SBIXStrike &strike = sbix_table->strikes[group](sbix_table);
-        for (unsigned int glyph = 0; glyph < num_glyphs; ++glyph)
-          if (strike.imageOffsetsZ[glyph + 1] - strike.imageOffsetsZ[glyph] > 0)
-          {
-            const SBIXGlyph &sbixGlyph = strike.imageOffsetsZ[glyph]((const void *) &strike);
-            callback ((const uint8_t*) sbixGlyph.data,
-              strike.imageOffsetsZ[glyph + 1] - strike.imageOffsetsZ[glyph] - 8,
-              group, glyph);
-          }
+	const SBIXStrike &strike = sbix_table->strikes[group](sbix_table);
+	for (unsigned int glyph = 0; glyph < num_glyphs; ++glyph)
+	  if (strike.imageOffsetsZ[glyph + 1] - strike.imageOffsetsZ[glyph] > 0)
+	  {
+	    const SBIXGlyph &sbixGlyph = strike.imageOffsetsZ[glyph]((const void *) &strike);
+	    callback ((const uint8_t*) &sbixGlyph.data,
+		      strike.imageOffsetsZ[glyph + 1] - strike.imageOffsetsZ[glyph] - 8,
+		      group, glyph);
+	  }
       }
     }
 
@@ -141,7 +140,7 @@ struct sbix
   HBUINT16	version;	/* Table version number — set to 1 */
   HBUINT16	flags;		/* Bit 0: Set to 1. Bit 1: Draw outlines.
 				 * Bits 2 to 15: reserved (set to 0). */
-  ArrayOf<LOffsetTo<SBIXStrike>, HBUINT32>
+  LArrayOf<LOffsetTo<SBIXStrike> >
 		strikes;	/* Offsets from the beginning of the 'sbix'
 				 * table to data for each individual bitmap strike. */
   public:
diff --git a/src/hb-ot-color-svg-table.hh b/src/hb-ot-color-svg-table.hh
index 6d0d9c4f..139a012b 100644
--- a/src/hb-ot-color-svg-table.hh
+++ b/src/hb-ot-color-svg-table.hh
@@ -45,19 +45,19 @@ struct SVGDocumentIndexEntry
   {
     TRACE_SANITIZE (this);
     return_trace (c->check_struct (this) &&
-      c->check_range (&svgDoc (base), svgDocLength));
+		  (base+svgDoc).sanitize (c, svgDocLength));
   }
 
   protected:
-  HBUINT16 startGlyphID;	/* The first glyph ID in the range described by
-                                 * this index entry. */
-  HBUINT16 endGlyphID;		/* The last glyph ID in the range described by
-                                 * this index entry. Must be >= startGlyphID. */
-  LOffsetTo<const uint8_t *>
-        svgDoc;			/* Offset from the beginning of the SVG Document Index
-                                 * to an SVG document. Must be non-zero. */
+  HBUINT16	startGlyphID;	/* The first glyph ID in the range described by
+				 * this index entry. */
+  HBUINT16	endGlyphID;	/* The last glyph ID in the range described by
+				 * this index entry. Must be >= startGlyphID. */
+  LOffsetTo<UnsizedArrayOf<HBUINT8> >
+		svgDoc;		/* Offset from the beginning of the SVG Document Index
+				 * to an SVG document. Must be non-zero. */
   HBUINT32 svgDocLength;	/* Length of the SVG document.
-                                 * Must be non-zero. */
+				 * Must be non-zero. */
   public:
   DEFINE_SIZE_STATIC (12);
 };
@@ -75,7 +75,7 @@ struct SVGDocumentIndex
 
   protected:
   ArrayOf<SVGDocumentIndexEntry>
-    entries;			/* Array of SVG Document Index Entries. */
+		entries;	/* Array of SVG Document Index Entries. */
   public:
   DEFINE_SIZE_ARRAY (2, entries);
 };
@@ -88,7 +88,7 @@ struct SVG
   {
     TRACE_SANITIZE (this);
     return_trace (c->check_struct (this) &&
-      svgDocIndex (this).sanitize (c));
+		  (this+svgDocIndex).sanitize (c));
   }
 
   struct accelerator_t
@@ -107,16 +107,17 @@ struct SVG
       hb_blob_destroy (svg_blob);
     }
 
-    inline void dump (void (*callback) (const uint8_t* data, unsigned int length,
-        unsigned int start_glyph, unsigned int end_glyph)) const
+    inline void
+    dump (void (*callback) (const uint8_t* data, unsigned int length,
+			    unsigned int start_glyph, unsigned int end_glyph)) const
     {
-      const SVGDocumentIndex &index = svg->svgDocIndex (svg);
+      const SVGDocumentIndex &index = svg+svg->svgDocIndex;
       const ArrayOf<SVGDocumentIndexEntry> &entries = index.entries;
       for (unsigned int i = 0; i < entries.len; ++i)
       {
-        const SVGDocumentIndexEntry &entry = entries[i];
-        callback ((const uint8_t*) &entry.svgDoc (&index), entry.svgDocLength,
-          entry.startGlyphID, entry.endGlyphID);
+	const SVGDocumentIndexEntry &entry = entries[i];
+	callback ((const uint8_t*) &entry.svgDoc (&index), entry.svgDocLength,
+						  entry.startGlyphID, entry.endGlyphID);
       }
     }
 
@@ -130,7 +131,7 @@ struct SVG
   protected:
   HBUINT16	version;	/* Table version (starting at 0). */
   LOffsetTo<SVGDocumentIndex>
-    svgDocIndex;		/* Offset (relative to the start of the SVG table) to the
+		svgDocIndex;	/* Offset (relative to the start of the SVG table) to the
 				 * SVG Documents Index. Must be non-zero. */
   HBUINT32	reserved;	/* Set to 0. */
   public:
commit 1e1e9086c09185a7bd6f65d1e391418642229616
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date:   Tue Apr 10 03:26:01 2018 +0430

    minor

diff --git a/src/dump-emoji.cc b/src/dump-emoji.cc
index db586bd2..16850d03 100644
--- a/src/dump-emoji.cc
+++ b/src/dump-emoji.cc
@@ -170,6 +170,7 @@ void colr_cpal_rendering (cairo_font_face_t *cairo_face, unsigned int upem, unsi
 void dump_glyphs (cairo_font_face_t *cairo_face, unsigned int upem, unsigned int num_glyphs)
 {
   // Dump every glyph available on the font
+  return; // disabled for now
   for (int i = 0; i < num_glyphs; ++i)
   {
     cairo_text_extents_t extents;
commit a62554af89b8324c73c623e64f87ec822c757515
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date:   Tue Apr 10 00:53:50 2018 +0430

    [colr/cpal] Improvements and add a sample renderer (#927)

diff --git a/src/Makefile.am b/src/Makefile.am
index c5a01e75..46fc141a 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -362,15 +362,11 @@ dist_check_SCRIPTS += \
 endif
 
 check_PROGRAMS += \
-	dump-emoji \
 	dump-indic-data \
 	dump-khmer-data \
 	dump-myanmar-data \
 	dump-use-data \
 	$(NULL)
-dump_emoji_SOURCES = dump-emoji.cc
-dump_emoji_CPPFLAGS = $(HBCFLAGS)
-dump_emoji_LDADD = libharfbuzz.la $(HBLIBS)
 dump_indic_data_SOURCES = dump-indic-data.cc hb-ot-shape-complex-indic-table.cc
 dump_indic_data_CPPFLAGS = $(HBCFLAGS)
 dump_indic_data_LDADD = libharfbuzz.la $(HBLIBS)
@@ -384,6 +380,15 @@ dump_use_data_SOURCES = dump-use-data.cc hb-ot-shape-complex-use-table.cc
 dump_use_data_CPPFLAGS = $(HBCFLAGS)
 dump_use_data_LDADD = libharfbuzz.la $(HBLIBS)
 
+if HAVE_FREETYPE
+if HAVE_CAIRO_FT
+check_PROGRAMS += dump-emoji
+dump_emoji_SOURCES = dump-emoji.cc
+dump_emoji_CPPFLAGS = $(HBCFLAGS) $(FREETYPE_CFLAGS) $(CAIRO_FT_CFLAGS)
+dump_emoji_LDADD = libharfbuzz.la $(HBLIBS) $(FREETYPE_LIBS) $(CAIRO_LIBS) $(CAIRO_FT_LIBS)
+endif # HAVE_CAIRO_FT
+endif # HAVE_FREETYPE
+
 check_PROGRAMS += test-ot-tag test-unicode-ranges
 TESTS += test-ot-tag test-unicode-ranges
 
diff --git a/src/dump-emoji.cc b/src/dump-emoji.cc
index a9595e41..db586bd2 100644
--- a/src/dump-emoji.cc
+++ b/src/dump-emoji.cc
@@ -25,9 +25,21 @@
 #include "hb.h"
 #include "hb-private.hh"
 #include "hb-ot-color-cbdt-table.hh"
+#include "hb-ot-color-colr-table.hh"
+#include "hb-ot-color-cpal-table.hh"
 #include "hb-ot-color-sbix-table.hh"
 #include "hb-ot-color-svg-table.hh"
 
+#include "hb-ft.h"
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_GLYPH_H
+
+#include <cairo.h>
+#include <cairo-ft.h>
+#include <cairo-svg.h>
+
 #ifdef HAVE_GLIB
 #include <glib.h>
 #endif
@@ -41,9 +53,9 @@ const void * const OT::_hb_NullPool[HB_NULL_POOL_SIZE / sizeof (void *)] = {};
 void cbdt_callback (const uint8_t* data, unsigned int length,
                     unsigned int group, unsigned int gid)
 {
-  char outName[255];
-  sprintf (outName, "out/cbdt-%d-%d.png", group, gid);
-  FILE *f = fopen (outName, "wb");
+  char output_path[255];
+  sprintf (output_path, "out/cbdt-%d-%d.png", group, gid);
+  FILE *f = fopen (output_path, "wb");
   fwrite (data, 1, length, f);
   fclose (f);
 }
@@ -51,9 +63,9 @@ void cbdt_callback (const uint8_t* data, unsigned int length,
 void sbix_callback (const uint8_t* data, unsigned int length,
                     unsigned int group, unsigned int gid)
 {
-  char outName[255];
-  sprintf (outName, "out/sbix-%d-%d.png", group, gid);
-  FILE *f = fopen (outName, "wb");
+  char output_path[255];
+  sprintf (output_path, "out/sbix-%d-%d.png", group, gid);
+  FILE *f = fopen (output_path, "wb");
   fwrite (data, 1, length, f);
   fclose (f);
 }
@@ -61,22 +73,145 @@ void sbix_callback (const uint8_t* data, unsigned int length,
 void svg_callback (const uint8_t* data, unsigned int length,
                    unsigned int start_glyph, unsigned int end_glyph)
 {
-  char outName[255];
+  char output_path[255];
   if (start_glyph == end_glyph)
-    sprintf (outName, "out/svg-%d.svg", start_glyph);
+    sprintf (output_path, "out/svg-%d.svg", start_glyph);
   else
-    sprintf (outName, "out/svg-%d-%d.svg", start_glyph, end_glyph);
+    sprintf (output_path, "out/svg-%d-%d.svg", start_glyph, end_glyph);
 
   // append "z" if the content is gzipped
   if ((data[0] == 0x1F) && (data[1] == 0x8B))
-    strcat (outName, "z");
+    strcat (output_path, "z");
 
-  FILE *f = fopen (outName, "wb");
+  FILE *f = fopen (output_path, "wb");
   fwrite (data, 1, length, f);
   fclose (f);
 }
 
-int main(int argc, char **argv)
+void colr_cpal_rendering (cairo_font_face_t *cairo_face, unsigned int upem, unsigned int num_glyphs,
+			  const OT::COLR *colr, const OT::CPAL *cpal)
+{
+  for (int i = 0; i < num_glyphs; ++i)
+  {
+    unsigned int first_layer_index, num_layers;
+    if (colr->get_base_glyph_record (i, &first_layer_index, &num_layers))
+    {
+      // Measure
+      cairo_text_extents_t extents;
+      {
+	cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
+	cairo_t *cr = cairo_create (surface);
+	cairo_set_font_face (cr, cairo_face);
+	cairo_set_font_size (cr, upem);
+
+	cairo_glyph_t *glyphs = (cairo_glyph_t *) calloc (num_layers, sizeof (cairo_glyph_t));
+	for (unsigned int j = 0; j < num_layers; ++j)
+	{
+	  hb_codepoint_t glyph_id;
+	  unsigned int color_index;
+	  colr->get_layer_record (first_layer_index + j, &glyph_id, &color_index);
+	  glyphs[j].index = glyph_id;
+	}
+	cairo_glyph_extents (cr, glyphs, num_layers, &extents);
+	free (glyphs);
+	cairo_surface_destroy (surface);
+	cairo_destroy (cr);
+      }
+
+      // Add a slight margin
+      extents.width += extents.width / 10;
+      extents.height += extents.height / 10;
+      extents.x_bearing -= extents.width / 20;
+      extents.y_bearing -= extents.height / 20;
+
+      // Render
+      unsigned int pallet_count = cpal->get_palette_count ();
+      for (unsigned int pallet = 0; pallet < pallet_count; ++pallet) {
+	char output_path[255];
+
+	// If we have more than one pallet, use a better namin
+	if (pallet_count == 1)
+	  sprintf (output_path, "out/colr-%d.svg", i);
+	else
+	  sprintf (output_path, "out/colr-%d-%d.svg", i, pallet);
+
+	cairo_surface_t *surface = cairo_svg_surface_create (output_path, extents.width, extents.height);
+	cairo_t *cr = cairo_create (surface);
+	cairo_set_font_face (cr, cairo_face);
+	cairo_set_font_size (cr, upem);
+
+	for (unsigned int j = 0; j < num_layers; ++j)
+	{
+	  hb_codepoint_t glyph_id;
+	  unsigned int color_index;
+	  colr->get_layer_record (first_layer_index + j, &glyph_id, &color_index);
+
+	  uint32_t color = cpal->get_color_record_argb (color_index, pallet);
+	  int alpha = color & 0xFF;
+	  int r = (color >> 8) & 0xFF;
+	  int g = (color >> 16) & 0xFF;
+	  int b = (color >> 24) & 0xFF;
+	  cairo_set_source_rgba (cr, r / 255.f, g / 255.f, b / 255.f, alpha);
+
+	  cairo_glyph_t glyph;
+	  glyph.index = glyph_id;
+	  glyph.x = -extents.x_bearing;
+	  glyph.y = -extents.y_bearing;
+	  cairo_show_glyphs (cr, &glyph, 1);
+	}
+
+	cairo_surface_destroy (surface);
+	cairo_destroy (cr);
+      }
+    }
+  }
+}
+
+void dump_glyphs (cairo_font_face_t *cairo_face, unsigned int upem, unsigned int num_glyphs)
+{
+  // Dump every glyph available on the font
+  for (int i = 0; i < num_glyphs; ++i)
+  {
+    cairo_text_extents_t extents;
+    cairo_glyph_t glyph = {0};
+    glyph.index = i;
+
+    // Measure
+    {
+      cairo_surface_t *surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
+      cairo_t *cr = cairo_create (surface);
+      cairo_set_font_face (cr, cairo_face);
+      cairo_set_font_size (cr, upem);
+
+      cairo_glyph_extents (cr, &glyph, 1, &extents);
+      cairo_surface_destroy (surface);
+      cairo_destroy (cr);
+    }
+
+    // Add a slight margin
+    extents.width += extents.width / 10;
+    extents.height += extents.height / 10;
+    extents.x_bearing -= extents.width / 20;
+    extents.y_bearing -= extents.height / 20;
+
+    // Render
+    {
+      char output_path[255];
+      sprintf (output_path, "out/%d.svg", i);
+      cairo_surface_t *surface = cairo_svg_surface_create (output_path, extents.width, extents.height);
+      cairo_t *cr = cairo_create (surface);
+      cairo_set_font_face (cr, cairo_face);
+      cairo_set_font_size (cr, upem);
+      glyph.x = -extents.x_bearing;
+      glyph.y = -extents.y_bearing;
+      cairo_show_glyphs (cr, &glyph, 1);
+      cairo_surface_destroy (surface);
+      cairo_destroy (cr);
+    }
+  }
+}
+
+int main (int argc, char **argv)
 {
   if (argc != 2) {
     fprintf (stderr, "usage: %s font-file.ttf\n", argv[0]);
@@ -133,6 +268,28 @@ 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));
+  const OT::COLR *colr = OT::Sanitizer<OT::COLR>::lock_instance (colr_blob);
+
+  OT::Sanitizer<OT::CPAL> sanitizerCPAL;
+  hb_blob_t* cpal_blob = sanitizerCPAL.sanitize (face->reference_table (HB_OT_TAG_CPAL));
+  const OT::CPAL *cpal = OT::Sanitizer<OT::CPAL>::lock_instance (cpal_blob);
+
+  cairo_font_face_t *cairo_face;
+  {
+    FT_Library library;
+    FT_Init_FreeType (&library);
+    FT_Face ftface;
+    FT_New_Face (library, argv[1], 0, &ftface);
+    cairo_face = cairo_ft_font_face_create_for_ft_face (ftface, 0);
+  }
+  unsigned int num_glyphs = hb_face_get_glyph_count (face);
+  unsigned int upem = hb_face_get_upem (face);
+  colr_cpal_rendering (cairo_face, upem, num_glyphs, colr, cpal);
+  dump_glyphs (cairo_face, upem, num_glyphs);
+
+
   hb_font_destroy (font);
   hb_face_destroy (face);
   hb_blob_destroy (blob);
diff --git a/src/hb-ot-color-colr-table.hh b/src/hb-ot-color-colr-table.hh
index c1cf6de5..5308b5a1 100644
--- a/src/hb-ot-color-colr-table.hh
+++ b/src/hb-ot-color-colr-table.hh
@@ -64,6 +64,10 @@ struct BaseGlyphRecord
     return_trace (c->check_struct (this));
   }
 
+  inline int cmp (hb_codepoint_t g) const {
+    return g < glyphid ? -1 : g > glyphid ? 1 : 0;
+  }
+
   protected:
   GlyphID	glyphid;	/* Glyph ID of reference glyph */
   HBUINT16	firstLayerIdx;	/* Index to the layer record */
@@ -72,6 +76,13 @@ struct BaseGlyphRecord
   DEFINE_SIZE_STATIC (6);
 };
 
+static int compare_bgr (const void *pa, const void *pb)
+{
+  const hb_codepoint_t *a = (const hb_codepoint_t *) pa;
+  const BaseGlyphRecord *b = (const BaseGlyphRecord *) pb;
+  return b->cmp (*a);
+}
+
 struct COLR
 {
   static const hb_tag_t tableTag = HB_OT_TAG_COLR;
@@ -80,17 +91,41 @@ struct COLR
   {
     TRACE_SANITIZE (this);
     return_trace (c->check_struct (this) &&
-		  (this+baseGlyphs).sanitize (c, numBaseGlyphs) &&
-		  (this+layers).sanitize (c, numLayers));
+		  (this+baseGlyphsZ).sanitize (c, numBaseGlyphs) &&
+		  (this+layersZ).sanitize (c, numLayers));
+  }
+
+  inline bool get_base_glyph_record (hb_codepoint_t glyph_id,
+				     unsigned int *first_layer /* OUT */,
+				     unsigned int *num_layers /* OUT */) const
+  {
+    const BaseGlyphRecord* record;
+    record = (BaseGlyphRecord *) bsearch (&glyph_id, &(this+baseGlyphsZ), numBaseGlyphs,
+					  sizeof (BaseGlyphRecord), compare_bgr);
+    if (!record)
+      return false;
+
+    *first_layer = record->firstLayerIdx;
+    *num_layers = record->numLayers;
+    return true;
+  }
+
+  inline void get_layer_record (unsigned int record,
+				hb_codepoint_t *glyph_id /* OUT */,
+				unsigned int *palette_index /* OUT */) const
+  {
+    const LayerRecord &layer = (this+layersZ)[record];
+    *glyph_id = layer.glyphid;
+    *palette_index = layer.colorIdx;
   }
 
   protected:
   HBUINT16	version;	/* Table version number */
   HBUINT16	numBaseGlyphs;	/* Number of Base Glyph Records */
   LOffsetTo<UnsizedArrayOf<BaseGlyphRecord> >
-		baseGlyphs;	/* Offset to Base Glyph records. */
+		baseGlyphsZ;	/* Offset to Base Glyph records. */
   LOffsetTo<UnsizedArrayOf<LayerRecord> >
-		layers;		/* Offset to Layer Records */
+		layersZ;	/* Offset to Layer Records */
   HBUINT16	numLayers;	/* Number of Layer Records */
   public:
   DEFINE_SIZE_STATIC (14);
diff --git a/src/hb-ot-color-cpal-table.hh b/src/hb-ot-color-cpal-table.hh
index e364c8a4..7feb3e1b 100644
--- a/src/hb-ot-color-cpal-table.hh
+++ b/src/hb-ot-color-cpal-table.hh
@@ -92,35 +92,44 @@ struct CPALV1Tail
 {
   friend struct CPAL;
 
-  inline bool sanitize (hb_sanitize_context_t *c, unsigned int palettes) const
+  inline bool
+  sanitize (hb_sanitize_context_t *c, const void *base, unsigned int palettes) const
   {
     TRACE_SANITIZE (this);
-    return_trace (
-      c->check_struct (this) &&
-      c->check_array ((const void*) &paletteFlags, sizeof (HBUINT32), palettes) &&
-      c->check_array ((const void*) &paletteLabel, sizeof (HBUINT16), palettes) &&
-      c->check_array ((const void*) &paletteEntryLabel, sizeof (HBUINT16), palettes));
+    return_trace (c->check_struct (this) &&
+		  (base+paletteFlagsZ).sanitize (c, palettes) &&
+		  (base+paletteLabelZ).sanitize (c, palettes) &&
+		  (base+paletteEntryLabelZ).sanitize (c, palettes));
   }
 
   private:
   inline hb_ot_color_palette_flags_t
   get_palette_flags (const void *base, unsigned int palette) const
   {
-    const HBUINT32* flags = &paletteFlags (base);
-    return (hb_ot_color_palette_flags_t) (uint32_t) flags[palette];
+    // range checked at the CPAL caller
+    return (hb_ot_color_palette_flags_t) (uint32_t) (base+paletteFlagsZ)[palette];
   }
 
   inline unsigned int
   get_palette_name_id (const void *base, unsigned int palette) const
   {
-    const HBUINT16* name_ids = &paletteLabel (base);
-    return name_ids[palette];
+    // range checked at the CPAL caller
+    return (base+paletteLabelZ)[palette];
   }
 
   protected:
-  LOffsetTo<HBUINT32> paletteFlags;
-  LOffsetTo<HBUINT16> paletteLabel;
-  LOffsetTo<HBUINT16> paletteEntryLabel;
+  LOffsetTo<UnsizedArrayOf<HBUINT32> >
+		paletteFlagsZ;		/* Offset from the beginning of CPAL table to
+					 * the Palette Type Array. Set to 0 if no array
+					 * is provided. */
+  LOffsetTo<UnsizedArrayOf<HBUINT16> >
+		paletteLabelZ;		/* Offset from the beginning of CPAL table to
+					 * the Palette Labels Array. Set to 0 if no
+					 * array is provided. */
+  LOffsetTo<UnsizedArrayOf<HBUINT16> >
+		paletteEntryLabelZ;	/* Offset from the beginning of CPAL table to
+					 * the Palette Entry Label Array. Set to 0
+					 * if no array is provided. */
   public:
   DEFINE_SIZE_STATIC (12);
 };
@@ -134,13 +143,13 @@ struct CPAL
   inline bool sanitize (hb_sanitize_context_t *c) const
   {
     TRACE_SANITIZE (this);
-    if (!(c->check_struct (this) && // This checks colorRecordIndicesX sanity also, see #get_size
-        c->check_array ((const void*) &colorRecordsZ, sizeof (BGRAColor), numColorRecords)))
+    if (!(c->check_struct (this) && // it checks colorRecordIndices also, see #get_size
+          (this+colorRecordsZ).sanitize (c, numColorRecords)))
       return_trace (false);
 
     // Check for indices sanity so no need for doing it runtime
     for (unsigned int i = 0; i < numPalettes; ++i)
-      if (colorRecordIndicesX[i] + numPaletteEntries > numColorRecords)
+      if (colorRecordIndicesZ[i] + numPaletteEntries > numColorRecords)
         return_trace (false);
 
     // If version is zero, we are done here; otherwise we need to check tail also
@@ -148,7 +157,7 @@ struct CPAL
       return_trace (true);
 
     const CPALV1Tail &v1 = StructAfter<CPALV1Tail> (*this);
-    return_trace (v1.sanitize (c, numPalettes));
+    return_trace (v1.sanitize (c, this, numPalettes));
   }
 
   inline unsigned int get_size (void) const
@@ -179,27 +188,32 @@ struct CPAL
     return numPalettes;
   }
 
-  inline hb_ot_color_t get_color_record_argb (unsigned int color_index, unsigned int palette) const
+  inline hb_ot_color_t
+  get_color_record_argb (unsigned int color_index, unsigned int palette) const
   {
     if (color_index >= numPaletteEntries || palette >= numPalettes)
       return 0;
 
-    const BGRAColor* records = &colorRecordsZ(this);
     // No need for more range check as it is already done on #sanitize
-    return records[colorRecordIndicesX[palette] + color_index];
+    return (this+colorRecordsZ)[colorRecordIndicesZ[palette] + color_index];
   }
 
   protected:
-  HBUINT16	version;
+  HBUINT16	version;		/* Table version number */
   /* Version 0 */
-  HBUINT16	numPaletteEntries;
-  HBUINT16	numPalettes;
-  HBUINT16	numColorRecords;
-  LOffsetTo<HBUINT32>	colorRecordsZ;
-  HBUINT16	colorRecordIndicesX[VAR];  // VAR=numPalettes
-/*CPALV1Tail	v1[VAR];*/
+  HBUINT16	numPaletteEntries;	/* Number of palette entries in each palette. */
+  HBUINT16	numPalettes;		/* Number of palettes in the table. */
+  HBUINT16	numColorRecords;	/* Total number of color records, combined for
+					 * all palettes. */
+  LOffsetTo<UnsizedArrayOf<BGRAColor> >
+		colorRecordsZ;		/* Offset from the beginning of CPAL table to
+					 * the first ColorRecord. */
+  UnsizedArrayOf<HBUINT16>
+		colorRecordIndicesZ;	/* Index of each palette’s first color record in
+					 * the combined color record array. */
+/*CPALV1Tail	v1;*/
   public:
-  DEFINE_SIZE_ARRAY (12, colorRecordIndicesX);
+  DEFINE_SIZE_ARRAY (12, colorRecordIndicesZ);
 };
 
 } /* namespace OT */
commit f25731a3606ff0972505eeb934477480019ffcd3
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date:   Tue Apr 10 00:51:57 2018 +0430

    [ci] Don't fail on brew warnings
    
    Not the best fix but it works and we don't care about brew warnings, so

diff --git a/.travis.yml b/.travis.yml
index 69b09c18..83b479ee 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -52,7 +52,7 @@ matrix:
         - brew update;
           # Workaround Travis/brew bug
         - brew uninstall libtool && brew install libtool
-        - brew install ragel freetype glib gobject-introspection cairo icu4c graphite2
+        - brew install ragel freetype glib gobject-introspection cairo icu4c graphite2 || true
         - brew link --force icu4c # icu4c is keg-only
       script:
         - ./autogen.sh
commit 58e569e5f7143a12cadcd6c42434558f9981e00e
Author: Ryan Schmidt <ryandesign at macports.org>
Date:   Thu Apr 5 17:03:36 2018 -0500

    Fix build with CoreText on OS X 10.7 and earlier (#952)

diff --git a/src/hb-coretext.cc b/src/hb-coretext.cc
index aba7cf44..8bb20016 100644
--- a/src/hb-coretext.cc
+++ b/src/hb-coretext.cc
@@ -168,6 +168,10 @@ create_ct_font (CGFontRef cg_font, CGFloat font_size)
   if (CFStringHasPrefix (cg_postscript_name, CFSTR (".SFNSText")) ||
       CFStringHasPrefix (cg_postscript_name, CFSTR (".SFNSDisplay")))
   {
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1080
+# define kCTFontUIFontSystem kCTFontSystemFontType
+# define kCTFontUIFontEmphasizedSystem kCTFontEmphasizedSystemFontType
+#endif
     CTFontUIFontType font_type = kCTFontUIFontSystem;
     if (CFStringHasSuffix (cg_postscript_name, CFSTR ("-Bold")))
       font_type = kCTFontUIFontEmphasizedSystem;
@@ -206,7 +210,18 @@ create_ct_font (CGFontRef cg_font, CGFloat font_size)
       return ct_font;
   }
 
-  CFURLRef original_url = (CFURLRef)CTFontCopyAttribute(ct_font, kCTFontURLAttribute);
+  CFURLRef original_url = NULL;
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+  ATSFontRef atsFont;
+  FSRef fsref;
+  OSStatus status;
+  atsFont = CTFontGetPlatformFont (ct_font, NULL);
+  status = ATSFontGetFileReference (atsFont, &fsref);
+  if (status == noErr)
+    original_url = CFURLCreateFromFSRef (NULL, &fsref);
+#else
+  original_url = (CFURLRef) CTFontCopyAttribute (ct_font, kCTFontURLAttribute);
+#endif
 
   /* Create font copy with cascade list that has LastResort first; this speeds up CoreText
    * font fallback which we don't need anyway. */
@@ -225,7 +240,15 @@ create_ct_font (CGFontRef cg_font, CGFloat font_size)
        * system locations that we cannot access from the sandboxed renderer
        * process in Blink. This can be detected by the new file URL location
        * that the newly found font points to. */
-      CFURLRef new_url = (CFURLRef) CTFontCopyAttribute (new_ct_font, kCTFontURLAttribute);
+      CFURLRef new_url = NULL;
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+      atsFont = CTFontGetPlatformFont (new_ct_font, NULL);
+      status = ATSFontGetFileReference (atsFont, &fsref);
+      if (status == noErr)
+        new_url = CFURLCreateFromFSRef (NULL, &fsref);
+#else
+      new_url = (CFURLRef) CTFontCopyAttribute (new_ct_font, kCTFontURLAttribute);
+#endif
       // Keep reconfigured font if URL cannot be retrieved (seems to be the case
       // on Mac OS 10.12 Sierra), speculative fix for crbug.com/625606
       if (!original_url || !new_url || CFEqual (original_url, new_url)) {
@@ -944,6 +967,9 @@ resize_and_retry:
 
       int level = HB_DIRECTION_IS_FORWARD (buffer->props.direction) ? 0 : 1;
       CFNumberRef level_number = CFNumberCreate (kCFAllocatorDefault, kCFNumberIntType, &level);
+#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060
+      extern const CFStringRef kCTTypesetterOptionForcedEmbeddingLevel;
+#endif
       CFDictionaryRef options = CFDictionaryCreate (kCFAllocatorDefault,
 						    (const void **) &kCTTypesetterOptionForcedEmbeddingLevel,
 						    (const void **) &level_number,


More information about the HarfBuzz mailing list