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

Behdad Esfahbod behdad at kemper.freedesktop.org
Fri Oct 27 02:34:44 UTC 2017


 src/Makefile.sources       |    2 
 src/hb-ot-post-macroman.hh |  294 +++++++++++++++++++++++++++++++++++++++++++++
 src/hb-ot-post-table.hh    |   55 +-------
 src/hb-private.hh          |    8 -
 src/hb-string-array.hh     |   74 +++++++++++
 5 files changed, 385 insertions(+), 48 deletions(-)

New commits:
commit 0e9256984e76f055f1868ecc497724977caba11d
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Oct 26 20:34:04 2017 -0600

    [post] Make format1 names array avoid relocations

diff --git a/src/Makefile.sources b/src/Makefile.sources
index 74d953f8..d162ebef 100644
--- a/src/Makefile.sources
+++ b/src/Makefile.sources
@@ -26,6 +26,7 @@ HB_BASE_sources = \
 	hb-ot-maxp-table.hh \
 	hb-ot-name-table.hh \
 	hb-ot-os2-table.hh \
+	hb-ot-post-macroman.hh \
 	hb-ot-post-table.hh \
 	hb-ot-tag.cc \
 	hb-private.hh \
diff --git a/src/hb-ot-post-macroman.hh b/src/hb-ot-post-macroman.hh
new file mode 100644
index 00000000..dbbb97e5
--- /dev/null
+++ b/src/hb-ot-post-macroman.hh
@@ -0,0 +1,294 @@
+/*
+ * Copyright © 2017  Google, Inc.
+ *
+ *  This is part of HarfBuzz, a text shaping library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Google Author(s): Behdad Esfahbod
+ */
+
+#ifndef HB_OT_POST_MACROMAN_HH
+#if 0 /* Make checks happy. */
+#define HB_OT_POST_MACROMAN_HH
+#include "hb-private.hh"
+#endif
+
+
+_S(".notdef")
+_S(".null")
+_S("nonmarkingreturn")
+_S("space")
+_S("exclam")
+_S("quotedbl")
+_S("numbersign")
+_S("dollar")
+_S("percent")
+_S("ampersand")
+_S("quotesingle")
+_S("parenleft")
+_S("parenright")
+_S("asterisk")
+_S("plus")
+_S("comma")
+_S("hyphen")
+_S("period")
+_S("slash")
+_S("zero")
+_S("one")
+_S("two")
+_S("three")
+_S("four")
+_S("five")
+_S("six")
+_S("seven")
+_S("eight")
+_S("nine")
+_S("colon")
+_S("semicolon")
+_S("less")
+_S("equal")
+_S("greater")
+_S("question")
+_S("at")
+_S("A")
+_S("B")
+_S("C")
+_S("D")
+_S("E")
+_S("F")
+_S("G")
+_S("H")
+_S("I")
+_S("J")
+_S("K")
+_S("L")
+_S("M")
+_S("N")
+_S("O")
+_S("P")
+_S("Q")
+_S("R")
+_S("S")
+_S("T")
+_S("U")
+_S("V")
+_S("W")
+_S("X")
+_S("Y")
+_S("Z")
+_S("bracketleft")
+_S("backslash")
+_S("bracketright")
+_S("asciicircum")
+_S("underscore")
+_S("grave")
+_S("a")
+_S("b")
+_S("c")
+_S("d")
+_S("e")
+_S("f")
+_S("g")
+_S("h")
+_S("i")
+_S("j")
+_S("k")
+_S("l")
+_S("m")
+_S("n")
+_S("o")
+_S("p")
+_S("q")
+_S("r")
+_S("s")
+_S("t")
+_S("u")
+_S("v")
+_S("w")
+_S("x")
+_S("y")
+_S("z")
+_S("braceleft")
+_S("bar")
+_S("braceright")
+_S("asciitilde")
+_S("Adieresis")
+_S("Aring")
+_S("Ccedilla")
+_S("Eacute")
+_S("Ntilde")
+_S("Odieresis")
+_S("Udieresis")
+_S("aacute")
+_S("agrave")
+_S("acircumflex")
+_S("adieresis")
+_S("atilde")
+_S("aring")
+_S("ccedilla")
+_S("eacute")
+_S("egrave")
+_S("ecircumflex")
+_S("edieresis")
+_S("iacute")
+_S("igrave")
+_S("icircumflex")
+_S("idieresis")
+_S("ntilde")
+_S("oacute")
+_S("ograve")
+_S("ocircumflex")
+_S("odieresis")
+_S("otilde")
+_S("uacute")
+_S("ugrave")
+_S("ucircumflex")
+_S("udieresis")
+_S("dagger")
+_S("degree")
+_S("cent")
+_S("sterling")
+_S("section")
+_S("bullet")
+_S("paragraph")
+_S("germandbls")
+_S("registered")
+_S("copyright")
+_S("trademark")
+_S("acute")
+_S("dieresis")
+_S("notequal")
+_S("AE")
+_S("Oslash")
+_S("infinity")
+_S("plusminus")
+_S("lessequal")
+_S("greaterequal")
+_S("yen")
+_S("mu")
+_S("partialdiff")
+_S("summation")
+_S("product")
+_S("pi")
+_S("integral")
+_S("ordfeminine")
+_S("ordmasculine")
+_S("Omega")
+_S("ae")
+_S("oslash")
+_S("questiondown")
+_S("exclamdown")
+_S("logicalnot")
+_S("radical")
+_S("florin")
+_S("approxequal")
+_S("Delta")
+_S("guillemotleft")
+_S("guillemotright")
+_S("ellipsis")
+_S("nonbreakingspace")
+_S("Agrave")
+_S("Atilde")
+_S("Otilde")
+_S("OE")
+_S("oe")
+_S("endash")
+_S("emdash")
+_S("quotedblleft")
+_S("quotedblright")
+_S("quoteleft")
+_S("quoteright")
+_S("divide")
+_S("lozenge")
+_S("ydieresis")
+_S("Ydieresis")
+_S("fraction")
+_S("currency")
+_S("guilsinglleft")
+_S("guilsinglright")
+_S("fi")
+_S("fl")
+_S("daggerdbl")
+_S("periodcentered")
+_S("quotesinglbase")
+_S("quotedblbase")
+_S("perthousand")
+_S("Acircumflex")
+_S("Ecircumflex")
+_S("Aacute")
+_S("Edieresis")
+_S("Egrave")
+_S("Iacute")
+_S("Icircumflex")
+_S("Idieresis")
+_S("Igrave")
+_S("Oacute")
+_S("Ocircumflex")
+_S("apple")
+_S("Ograve")
+_S("Uacute")
+_S("Ucircumflex")
+_S("Ugrave")
+_S("dotlessi")
+_S("circumflex")
+_S("tilde")
+_S("macron")
+_S("breve")
+_S("dotaccent")
+_S("ring")
+_S("cedilla")
+_S("hungarumlaut")
+_S("ogonek")
+_S("caron")
+_S("Lslash")
+_S("lslash")
+_S("Scaron")
+_S("scaron")
+_S("Zcaron")
+_S("zcaron")
+_S("brokenbar")
+_S("Eth")
+_S("eth")
+_S("Yacute")
+_S("yacute")
+_S("Thorn")
+_S("thorn")
+_S("minus")
+_S("multiply")
+_S("onesuperior")
+_S("twosuperior")
+_S("threesuperior")
+_S("onehalf")
+_S("onequarter")
+_S("threequarters")
+_S("franc")
+_S("Gbreve")
+_S("gbreve")
+_S("Idotaccent")
+_S("Scedilla")
+_S("scedilla")
+_S("Cacute")
+_S("cacute")
+_S("Ccaron")
+_S("ccaron")
+_S("dcroat")
+
+
+#endif /* HB_OT_POST_MACROMAN_HH */
diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh
index 3eae7f7f..6e4a23af 100644
--- a/src/hb-ot-post-table.hh
+++ b/src/hb-ot-post-table.hh
@@ -29,48 +29,13 @@
 
 #include "hb-open-type-private.hh"
 
-#define NUM_FORMAT1_NAMES 258
+#define HB_STRING_ARRAY_NAME format1_names
+#define HB_STRING_ARRAY_LIST "hb-ot-post-macroman.hh"
+#include "hb-string-array.hh"
+#undef HB_STRING_ARRAY_LIST
+#undef HB_STRING_ARRAY_NAME
 
-static const char* const format1_names[NUM_FORMAT1_NAMES] =
-{
-  ".notdef", ".null", "nonmarkingreturn", "space", "exclam", "quotedbl",
-  "numbersign", "dollar", "percent", "ampersand", "quotesingle", "parenleft",
-  "parenright", "asterisk", "plus", "comma", "hyphen", "period", "slash",
-  "zero", "one", "two", "three", "four", "five", "six", "seven", "eight",
-  "nine", "colon", "semicolon", "less", "equal", "greater", "question", "at",
-  "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O",
-  "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "bracketleft",
-  "backslash", "bracketright", "asciicircum", "underscore", "grave", "a", "b",
-  "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q",
-  "r", "s", "t", "u", "v", "w", "x", "y", "z", "braceleft", "bar",
-  "braceright", "asciitilde", "Adieresis", "Aring", "Ccedilla", "Eacute",
-  "Ntilde", "Odieresis", "Udieresis", "aacute", "agrave", "acircumflex",
-  "adieresis", "atilde", "aring", "ccedilla", "eacute", "egrave",
-  "ecircumflex", "edieresis", "iacute", "igrave", "icircumflex", "idieresis",
-  "ntilde", "oacute", "ograve", "ocircumflex", "odieresis", "otilde", "uacute",
-  "ugrave", "ucircumflex", "udieresis", "dagger", "degree", "cent", "sterling",
-  "section", "bullet", "paragraph", "germandbls", "registered", "copyright",
-  "trademark", "acute", "dieresis", "notequal", "AE", "Oslash", "infinity",
-  "plusminus", "lessequal", "greaterequal", "yen", "mu", "partialdiff",
-  "summation", "product", "pi", "integral", "ordfeminine", "ordmasculine",
-  "Omega", "ae", "oslash", "questiondown", "exclamdown", "logicalnot",
-  "radical", "florin", "approxequal", "Delta", "guillemotleft",
-  "guillemotright", "ellipsis", "nonbreakingspace", "Agrave", "Atilde",
-  "Otilde", "OE", "oe", "endash", "emdash", "quotedblleft", "quotedblright",
-  "quoteleft", "quoteright", "divide", "lozenge", "ydieresis", "Ydieresis",
-  "fraction", "currency", "guilsinglleft", "guilsinglright", "fi", "fl",
-  "daggerdbl", "periodcentered", "quotesinglbase", "quotedblbase",
-  "perthousand", "Acircumflex", "Ecircumflex", "Aacute", "Edieresis", "Egrave",
-  "Iacute", "Icircumflex", "Idieresis", "Igrave", "Oacute", "Ocircumflex",
-  "apple", "Ograve", "Uacute", "Ucircumflex", "Ugrave", "dotlessi",
-  "circumflex", "tilde", "macron", "breve", "dotaccent", "ring", "cedilla",
-  "hungarumlaut", "ogonek", "caron", "Lslash", "lslash", "Scaron", "scaron",
-  "Zcaron", "zcaron", "brokenbar", "Eth", "eth", "Yacute", "yacute", "Thorn",
-  "thorn", "minus", "multiply", "onesuperior", "twosuperior", "threesuperior",
-  "onehalf", "onequarter", "threequarters", "franc", "Gbreve", "gbreve",
-  "Idotaccent", "Scedilla", "scedilla", "Cacute", "cacute", "Ccaron", "ccaron",
-  "dcroat",
-};
+#define NUM_FORMAT1_NAMES 258
 
 namespace OT {
 
@@ -130,7 +95,7 @@ struct post
 
       if (!buffer_length)
 	return true;
-      strncpy (buffer, format1_names[glyph], buffer_length);
+      strncpy (buffer, format1_names (glyph), buffer_length);
       buffer[buffer_length - 1] = '\0';
       return true;
     }
@@ -150,7 +115,7 @@ struct post
       {
 	if (!buffer_length)
 	  return true;
-	strncpy (buffer, format1_names[index], buffer_length);
+	strncpy (buffer, format1_names (index), buffer_length);
 	buffer[buffer_length - 1] = '\0';
 	return true;
       }
@@ -195,7 +160,7 @@ struct post
     {
       for (int i = 0; i < NUM_FORMAT1_NAMES; i++)
       {
-	if (strncmp (name, format1_names[i], len) == 0 && format1_names[i][len] == '\0')
+	if (strncmp (name, format1_names (i), len) == 0 && format1_names (i)[len] == '\0')
 	{
 	  *glyph = i;
 	  return true;
@@ -218,7 +183,7 @@ struct post
 	unsigned int index = v2.glyphNameIndex[gid];
 	if (index < NUM_FORMAT1_NAMES)
 	{
-	  if (strncmp (name, format1_names[index], len) == 0 && format1_names[index][len] == '\0')
+	  if (strncmp (name, format1_names (index), len) == 0 && format1_names (index)[len] == '\0')
 	  {
 	    *glyph = gid;
 	    return true;
commit 2a749680441bbe6b4aa8134bb6ce9f21a8b1bc3c
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Oct 26 19:48:33 2017 -0600

    Add hb-string-array.hh
    
    Used to build static string arrays that use no relocation.

diff --git a/src/Makefile.sources b/src/Makefile.sources
index 9fe8a40e..74d953f8 100644
--- a/src/Makefile.sources
+++ b/src/Makefile.sources
@@ -39,6 +39,7 @@ HB_BASE_sources = \
 	hb-shaper-impl-private.hh \
 	hb-shaper-private.hh \
 	hb-shaper.cc \
+	hb-string-array.hh \
 	hb-unicode-private.hh \
 	hb-unicode.cc \
 	hb-utf-private.hh \
diff --git a/src/hb-private.hh b/src/hb-private.hh
index 34476ca9..268a2b0a 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -54,6 +54,10 @@
 #include <stdarg.h>
 
 
+#define HB_PASTE1(a,b) a##b
+#define HB_PASTE(a,b) HB_PASTE1(a,b)
+
+
 /* Compile-time custom allocator support. */
 
 #if defined(hb_malloc_impl) \
@@ -98,8 +102,6 @@ private:
 
 // Static assertions
 #ifndef static_assert
-#define HB_PASTE1(a,b) a##b
-#define HB_PASTE(a,b) HB_PASTE1(a,b)
 #define static_assert(e, msg) \
 	HB_UNUSED typedef int HB_PASTE(static_assertion_failed_at_line_, __LINE__) [(e) ? 1 : -1]
 #endif // static_assert
diff --git a/src/hb-string-array.hh b/src/hb-string-array.hh
new file mode 100644
index 00000000..afad5d75
--- /dev/null
+++ b/src/hb-string-array.hh
@@ -0,0 +1,74 @@
+/*
+ * Copyright © 2017  Google, Inc.
+ *
+ *  This is part of HarfBuzz, a text shaping library.
+ *
+ * Permission is hereby granted, without written agreement and without
+ * license or royalty fees, to use, copy, modify, and distribute this
+ * software and its documentation for any purpose, provided that the
+ * above copyright notice and the following two paragraphs appear in
+ * all copies of this software.
+ *
+ * IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE TO ANY PARTY FOR
+ * DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
+ * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN
+ * IF THE COPYRIGHT HOLDER HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ *
+ * THE COPYRIGHT HOLDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING,
+ * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS
+ * ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
+ * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+ *
+ * Google Author(s): Behdad Esfahbod
+ */
+
+#ifndef HB_STRING_ARRAY_HH
+#if 0 /* Make checks happy. */
+#define HB_STRING_ARRAY_HH
+#endif
+
+#include "hb-private.hh"
+
+/* Based on Bruno Haible's code in Appendix B of Ulrich Drepper's dsohowto.pdf:
+ * https://software.intel.com/sites/default/files/m/a/1/e/dsohowto.pdf */
+
+#define HB_STRING_ARRAY_TYPE_NAME	HB_PASTE(HB_STRING_ARRAY_NAME, _msgstr_t)
+#define HB_STRING_ARRAY_POOL_NAME	HB_PASTE(HB_STRING_ARRAY_NAME, _msgstr)
+#define HB_STRING_ARRAY_OFFS_NAME	HB_PASTE(HB_STRING_ARRAY_NAME, _msgidx)
+
+static const union HB_STRING_ARRAY_TYPE_NAME {
+  struct {
+#define _S(s) char HB_PASTE (str, __LINE__)[sizeof (s)];
+#include HB_STRING_ARRAY_LIST
+#undef _S
+  } st;
+  char str[0];
+}
+HB_STRING_ARRAY_POOL_NAME =
+{
+  {
+#define _S(s) s,
+#include HB_STRING_ARRAY_LIST
+#undef _S
+  }
+};
+static const unsigned int HB_STRING_ARRAY_OFFS_NAME[] =
+{
+#define _S(s) offsetof (union HB_STRING_ARRAY_TYPE_NAME, st.HB_PASTE(str, __LINE__)),
+#include HB_STRING_ARRAY_LIST
+#undef _S
+};
+
+static inline const char *
+HB_STRING_ARRAY_NAME (unsigned int i)
+{
+  return HB_STRING_ARRAY_POOL_NAME.str + HB_STRING_ARRAY_OFFS_NAME[i];
+}
+
+#undef HB_STRING_ARRAY_TYPE_NAME
+#undef HB_STRING_ARRAY_POOL_NAME
+#undef HB_STRING_ARRAY_OFFS_NAME
+
+#endif /* HB_STRING_ARRAY_HH */
commit 6f08b12bc38166dee2f9740d396d617b32e887a3
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Oct 26 18:23:03 2017 -0600

    Minor

diff --git a/src/hb-private.hh b/src/hb-private.hh
index b139ed67..34476ca9 100644
--- a/src/hb-private.hh
+++ b/src/hb-private.hh
@@ -98,10 +98,10 @@ private:
 
 // Static assertions
 #ifndef static_assert
-#define _PASTE1(a,b) a##b
-#define _PASTE(a,b) _PASTE1(a,b)
+#define HB_PASTE1(a,b) a##b
+#define HB_PASTE(a,b) HB_PASTE1(a,b)
 #define static_assert(e, msg) \
-	HB_UNUSED typedef int _PASTE(static_assertion_failed_at_line_, __LINE__) [(e) ? 1 : -1]
+	HB_UNUSED typedef int HB_PASTE(static_assertion_failed_at_line_, __LINE__) [(e) ? 1 : -1]
 #endif // static_assert
 
 #endif // __cplusplus < 201103L


More information about the HarfBuzz mailing list