diff options
author | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2017-10-26 23:41:55 +0000 |
---|---|---|
committer | Akira Kakuto <kakuto@fuk.kindai.ac.jp> | 2017-10-26 23:41:55 +0000 |
commit | ec34a32e9d1bd685a982b1bc60dcfe2a363799a9 (patch) | |
tree | f92b8200b33d8feb75a827945e74c19e92341278 /Build/source/libs/harfbuzz/harfbuzz-src/src | |
parent | e19c1e02379479fc40b5a776e48ab0bf416ecf3a (diff) |
harfbuzz 1.6.3. c++11 configuration is not yet done
git-svn-id: svn://tug.org/texlive/trunk@45614 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/libs/harfbuzz/harfbuzz-src/src')
7 files changed, 245 insertions, 14 deletions
diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/check-c-linkage-decls.sh b/Build/source/libs/harfbuzz/harfbuzz-src/src/check-c-linkage-decls.sh index b10310f5384..cd550867af2 100755 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/check-c-linkage-decls.sh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/check-c-linkage-decls.sh @@ -11,14 +11,14 @@ test "x$HBSOURCES" = x && HBSOURCES=`cd "$srcdir"; find . -maxdepth 1 -name 'hb* for x in $HBHEADERS; do - test -f $srcdir/$x && x=$srcdir/$x + test -f "$srcdir/$x" -a ! -f "$x" && x="$srcdir/$x" if ! grep -q HB_BEGIN_DECLS "$x" || ! grep -q HB_END_DECLS "$x"; then echo "Ouch, file $x does not have HB_BEGIN_DECLS / HB_END_DECLS, but it should" stat=1 fi done for x in $HBSOURCES; do - test -f $srcdir/$x && x=$srcdir/$x + test -f "$srcdir/$x" -a ! -f "$x" && x="$srcdir/$x" if grep -q HB_BEGIN_DECLS "$x" || grep -q HB_END_DECLS "$x"; then echo "Ouch, file $x has HB_BEGIN_DECLS / HB_END_DECLS, but it shouldn't" stat=1 diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/check-externs.sh b/Build/source/libs/harfbuzz/harfbuzz-src/src/check-externs.sh index 63cc7d5bb02..a6de375350c 100755 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/check-externs.sh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/check-externs.sh @@ -13,8 +13,9 @@ test "x$EGREP" = x && EGREP='grep -E' echo 'Checking that all public symbols are exported with HB_EXTERN' for x in $HBHEADERS; do - test -f "$srcdir/$x" && x="$srcdir/$x" - $EGREP -B1 '^hb_' "$x" | $EGREP -E -v '^(--|hb_|HB_EXTERN )' -A1 + test -f "$srcdir/$x" -a ! -f "$x" && x="$srcdir/$x" + $EGREP -B1 -n '^hb_' /dev/null "$x" | + $EGREP -v '(^--|:hb_|-HB_EXTERN )' -A1 done | grep . >&2 && stat=1 diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/check-header-guards.sh b/Build/source/libs/harfbuzz/harfbuzz-src/src/check-header-guards.sh index 09c5ea8b2b5..355d81b525d 100755 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/check-header-guards.sh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/check-header-guards.sh @@ -10,7 +10,7 @@ test "x$HBHEADERS" = x && HBHEADERS=`cd "$srcdir"; find . -maxdepth 1 -name 'hb* test "x$HBSOURCES" = x && HBSOURCES=`cd "$srcdir"; find . -maxdepth 1 -name 'hb-*.cc' -or -name 'hb-*.hh'` for x in $HBHEADERS $HBSOURCES; do - test -f "$srcdir/$x" && x="$srcdir/$x" + test -f "$srcdir/$x" -a ! -f "$x" && x="$srcdir/$x" echo "$x" | grep -q '[^h]$' && continue; xx=`echo "$x" | sed 's@.*/@@'` tag=`echo "$xx" | tr 'a-z.-' 'A-Z_'` diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/check-includes.sh b/Build/source/libs/harfbuzz/harfbuzz-src/src/check-includes.sh index 902f2357e2a..37e372d5122 100755 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/check-includes.sh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/check-includes.sh @@ -13,7 +13,7 @@ test "x$HBSOURCES" = x && HBSOURCES=`cd "$srcdir"; find . -maxdepth 1 -name 'hb- echo 'Checking that public header files #include "hb-common.h" or "hb.h" first (or none)' for x in $HBHEADERS; do - test -f "$srcdir/$x" && x="$srcdir/$x" + test -f "$srcdir/$x" -a ! -f "$x" && x="$srcdir/$x" grep '#.*\<include\>' "$x" /dev/null | head -n 1 done | grep -v '"hb-common[.]h"' | @@ -26,7 +26,7 @@ grep . >&2 && stat=1 echo 'Checking that source files #include "hb-*private.hh" first (or none)' for x in $HBSOURCES; do - test -f "$srcdir/$x" && x="$srcdir/$x" + test -f "$srcdir/$x" -a ! -f "$x" && x="$srcdir/$x" grep '#.*\<include\>' "$x" /dev/null | grep -v 'include _' | head -n 1 done | grep -v '"hb-.*private[.]hh"' | diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc index 06d1b80650a..c0ce89df3b5 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-font.cc @@ -38,7 +38,7 @@ #include "hb-ot-hmtx-table.hh" #include "hb-ot-os2-table.hh" #include "hb-ot-var-hvar-table.hh" -//#include "hb-ot-post-table.hh" +#include "hb-ot-post-table.hh" struct hb_ot_face_metrics_accelerator_t @@ -301,6 +301,40 @@ struct hb_ot_face_cbdt_accelerator_t } }; +struct hb_ot_face_post_accelerator_t +{ + hb_blob_t *post_blob; + unsigned int post_len; + const OT::post *post; + + inline void init (hb_face_t *face) + { + this->post_blob = OT::Sanitizer<OT::post>::sanitize (face->reference_table (HB_OT_TAG_post)); + this->post = OT::Sanitizer<OT::post>::lock_instance (this->post_blob); + this->post_len = hb_blob_get_length (this->post_blob); + } + + inline void fini (void) + { + hb_blob_destroy (this->post_blob); + } + + inline bool get_glyph_name (hb_codepoint_t glyph, + char *name, unsigned int size) const + { + return this->post->get_glyph_name (glyph, name, size, this->post_len); + } + + inline bool get_glyph_from_name (const char *name, int len, + hb_codepoint_t *glyph) const + { + if (unlikely (!len)) + return false; + + return this->post->get_glyph_from_name (name, len, glyph, this->post_len); + } +}; + typedef bool (*hb_cmap_get_glyph_func_t) (const void *obj, hb_codepoint_t codepoint, hb_codepoint_t *glyph); @@ -436,6 +470,7 @@ struct hb_ot_font_t hb_ot_face_metrics_accelerator_t v_metrics; OT::hb_lazy_loader_t<hb_ot_face_glyf_accelerator_t> glyf; OT::hb_lazy_loader_t<hb_ot_face_cbdt_accelerator_t> cbdt; + OT::hb_lazy_loader_t<hb_ot_face_post_accelerator_t> post; }; @@ -453,6 +488,7 @@ _hb_ot_font_create (hb_face_t *face) ot_font->h_metrics.ascender - ot_font->h_metrics.descender); /* TODO Can we do this lazily? */ ot_font->glyf.init (face); ot_font->cbdt.init (face); + ot_font->post.init (face); return ot_font; } @@ -467,6 +503,7 @@ _hb_ot_font_destroy (void *data) ot_font->v_metrics.fini (); ot_font->glyf.fini (); ot_font->cbdt.fini (); + ot_font->post.fini (); free (ot_font); } @@ -536,6 +573,28 @@ hb_ot_get_glyph_extents (hb_font_t *font HB_UNUSED, } static hb_bool_t +hb_ot_get_glyph_name (hb_font_t *font HB_UNUSED, + void *font_data, + hb_codepoint_t glyph, + char *name, unsigned int size, + void *user_data HB_UNUSED) +{ + const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data; + return ot_font->post->get_glyph_name (glyph, name, size); +} + +static hb_bool_t +hb_ot_get_glyph_from_name (hb_font_t *font HB_UNUSED, + void *font_data, + const char *name, int len, + hb_codepoint_t *glyph, + void *user_data HB_UNUSED) +{ + const hb_ot_font_t *ot_font = (const hb_ot_font_t *) font_data; + return ot_font->post->get_glyph_from_name (name, len, glyph); +} + +static hb_bool_t hb_ot_get_font_h_extents (hb_font_t *font HB_UNUSED, void *font_data, hb_font_extents_t *metrics, @@ -595,8 +654,8 @@ retry: //hb_font_funcs_set_glyph_v_kerning_func (funcs, hb_ot_get_glyph_v_kerning, nullptr, nullptr); hb_font_funcs_set_glyph_extents_func (funcs, hb_ot_get_glyph_extents, nullptr, nullptr); //hb_font_funcs_set_glyph_contour_point_func (funcs, hb_ot_get_glyph_contour_point, nullptr, nullptr); TODO - //hb_font_funcs_set_glyph_name_func (funcs, hb_ot_get_glyph_name, nullptr, nullptr); TODO - //hb_font_funcs_set_glyph_from_name_func (funcs, hb_ot_get_glyph_from_name, nullptr, nullptr); TODO + hb_font_funcs_set_glyph_name_func (funcs, hb_ot_get_glyph_name, nullptr, nullptr); + hb_font_funcs_set_glyph_from_name_func (funcs, hb_ot_get_glyph_from_name, nullptr, nullptr); hb_font_funcs_make_immutable (funcs); diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-post-table.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-post-table.hh index 82ab3882a80..3eae7f7f101 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-post-table.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-ot-post-table.hh @@ -29,6 +29,48 @@ #include "hb-open-type-private.hh" +#define NUM_FORMAT1_NAMES 258 + +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", +}; namespace OT { @@ -71,12 +113,141 @@ struct post return_trace (false); if (version.to_int () == 0x00020000) { - const postV2Tail &v2 = StructAfter<postV2Tail>(*this); + const postV2Tail &v2 = StructAfter<postV2Tail> (*this); return_trace (v2.sanitize (c)); } return_trace (true); } + inline bool get_glyph_name (hb_codepoint_t glyph, + char *buffer, unsigned int buffer_length, + unsigned int blob_len) const + { + if (version.to_int () == 0x00010000) + { + if (glyph >= NUM_FORMAT1_NAMES) + return false; + + if (!buffer_length) + return true; + strncpy (buffer, format1_names[glyph], buffer_length); + buffer[buffer_length - 1] = '\0'; + return true; + } + + if (version.to_int () == 0x00020000) + { + const postV2Tail &v2 = StructAfter<postV2Tail> (*this); + + if (glyph >= v2.numberOfGlyphs) + return false; + + if (!buffer_length) + return true; + + unsigned int index = v2.glyphNameIndex[glyph]; + if (index < NUM_FORMAT1_NAMES) + { + if (!buffer_length) + return true; + strncpy (buffer, format1_names[index], buffer_length); + buffer[buffer_length - 1] = '\0'; + return true; + } + index -= NUM_FORMAT1_NAMES; + + unsigned int offset = min_size + v2.min_size + 2 * v2.numberOfGlyphs; + unsigned char *data = (unsigned char *) this + offset; + unsigned char *end = (unsigned char *) this + blob_len; + for (unsigned int i = 0; data < end; i++) + { + unsigned int name_length = data[0]; + data++; + if (i == index) + { + if (unlikely (!name_length)) + return false; + + unsigned int remaining = end - data; + name_length = MIN (name_length, buffer_length - 1); + name_length = MIN (name_length, remaining); + memcpy (buffer, data, name_length); + buffer[name_length] = '\0'; + return true; + } + data += name_length; + } + + return false; + } + + return false; + } + + inline bool get_glyph_from_name (const char *name, int len, + hb_codepoint_t *glyph, + unsigned int blob_len) const + { + if (len < 0) + len = strlen (name); + + if (version.to_int () == 0x00010000) + { + for (int i = 0; i < NUM_FORMAT1_NAMES; i++) + { + if (strncmp (name, format1_names[i], len) == 0 && format1_names[i][len] == '\0') + { + *glyph = i; + return true; + } + } + return false; + } + + if (version.to_int () == 0x00020000) + { + const postV2Tail &v2 = StructAfter<postV2Tail> (*this); + unsigned int offset = min_size + v2.min_size + 2 * v2.numberOfGlyphs; + char* data = (char*) this + offset; + + + /* XXX The following code is wrong. */ + return false; + for (hb_codepoint_t gid = 0; gid < v2.numberOfGlyphs; gid++) + { + unsigned int index = v2.glyphNameIndex[gid]; + if (index < NUM_FORMAT1_NAMES) + { + if (strncmp (name, format1_names[index], len) == 0 && format1_names[index][len] == '\0') + { + *glyph = gid; + return true; + } + continue; + } + index -= NUM_FORMAT1_NAMES; + + for (unsigned int i = 0; data < (char*) this + blob_len; i++) + { + unsigned int name_length = data[0]; + unsigned int remaining = (char*) this + blob_len - data - 1; + name_length = MIN (name_length, remaining); + if (name_length == (unsigned int) len && strncmp (name, data + 1, len) == 0) + { + *glyph = gid; + return true; + } + data += name_length + 1; + } + return false; + } + + return false; + } + + return false; + } + public: FixedVersion<>version; /* 0x00010000 for version 1.0 * 0x00020000 for version 2.0 diff --git a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set-private.hh b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set-private.hh index 0454a1896e0..c970b89dda7 100644 --- a/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set-private.hh +++ b/Build/source/libs/harfbuzz/harfbuzz-src/src/hb-set-private.hh @@ -95,7 +95,7 @@ struct hb_set_t goto found; for (i++; i < len (); i++) if (v[i]) - for (unsigned int j = 0; j < ELT_BITS; j++) + for (j = 0; j < ELT_BITS; j++) if (v[i] & (elt_t (1) << j)) goto found; @@ -313,13 +313,13 @@ struct hb_set_t b = nb; for (; a && b; ) { - if (page_map[a].major == other->page_map[b].major) + if (page_map[a - 1].major == other->page_map[b - 1].major) { a--; b--; Op::process (page_at (--count).v, page_at (a).v, other->page_at (b).v); } - else if (page_map[a].major > other->page_map[b].major) + else if (page_map[a - 1].major > other->page_map[b - 1].major) { a--; if (Op::passthru_left) |