[HarfBuzz] harfbuzz: Branch 'master' - 5 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Fri Oct 5 23:41:59 UTC 2018
src/hb-aat-layout-common.hh | 4
src/hb-face.cc | 2
src/hb-machinery.hh | 2
src/hb-ot-cmap-table.hh | 2
src/hb-ot-post-table.hh | 2
src/hb-ot-shape.cc | 4
src/hb-set.hh | 4
src/hb-subset.cc | 2
src/hb-vector.hh | 100 ++++++----
test/shaping/data/text-rendering-tests/DISABLED | 3
test/shaping/data/text-rendering-tests/Makefile.sources | 2
test/shaping/data/text-rendering-tests/fonts/TestMORXThirtyfive.ttf |binary
test/shaping/data/text-rendering-tests/fonts/TestMORXThirtysix.ttf |binary
test/shaping/data/text-rendering-tests/tests/MORX-35.tests | 2
test/shaping/data/text-rendering-tests/tests/MORX-36.tests | 1
15 files changed, 84 insertions(+), 46 deletions(-)
New commits:
commit 341206eb609202e4b2f0d03d29cb577ebe8390b9
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Oct 5 18:39:48 2018 +0200
[vector] Make hb_vector_t relocatable / nestable
Ugly, but...
Fixes https://github.com/harfbuzz/harfbuzz/issues/1227
diff --git a/src/hb-face.cc b/src/hb-face.cc
index 3916a4e2..bba1ee3f 100644
--- a/src/hb-face.cc
+++ b/src/hb-face.cc
@@ -634,7 +634,7 @@ _hb_face_builder_data_reference_blob (hb_face_builder_data_t *data)
unsigned int face_length = table_count * 16 + 12;
for (unsigned int i = 0; i < table_count; i++)
- face_length += hb_ceil_to_4 (hb_blob_get_length (data->tables.arrayZ[i].blob));
+ face_length += hb_ceil_to_4 (hb_blob_get_length (data->tables[i].blob));
char *buf = (char *) malloc (face_length);
if (unlikely (!buf))
diff --git a/src/hb-machinery.hh b/src/hb-machinery.hh
index f80cfdb2..9c73df2c 100644
--- a/src/hb-machinery.hh
+++ b/src/hb-machinery.hh
@@ -591,7 +591,7 @@ struct Supplier
}
inline Supplier (const hb_vector_t<Type> *v)
{
- head = v->arrayZ;
+ head = v->arrayZ();
len = v->len;
stride = sizeof (Type);
}
diff --git a/src/hb-ot-cmap-table.hh b/src/hb-ot-cmap-table.hh
index 3f5fa01f..52b4db6a 100644
--- a/src/hb-ot-cmap-table.hh
+++ b/src/hb-ot-cmap-table.hh
@@ -495,7 +495,7 @@ struct CmapSubtableLongSegmented
{
TRACE_SERIALIZE (this);
if (unlikely (!c->extend_min (*this))) return_trace (false);
- Supplier<CmapSubtableLongGroup> supplier (group_data.arrayZ, group_data.len);
+ Supplier<CmapSubtableLongGroup> supplier (group_data.arrayZ(), group_data.len);
if (unlikely (!groups.serialize (c, supplier, group_data.len))) return_trace (false);
return true;
}
diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh
index f81de37d..bd049f9a 100644
--- a/src/hb-ot-post-table.hh
+++ b/src/hb-ot-post-table.hh
@@ -242,7 +242,7 @@ struct post
if (index >= index_to_offset.len)
return hb_bytes_t ();
- unsigned int offset = index_to_offset.arrayZ[index];
+ unsigned int offset = index_to_offset[index];
const uint8_t *data = pool + offset;
unsigned int name_length = *data;
diff --git a/src/hb-set.hh b/src/hb-set.hh
index 353403e9..7ca32976 100644
--- a/src/hb-set.hh
+++ b/src/hb-set.hh
@@ -368,8 +368,8 @@ struct hb_set_t
if (!resize (count))
return;
population = other->population;
- memcpy (pages.arrayZ, other->pages.arrayZ, count * sizeof (pages.arrayZ[0]));
- memcpy (page_map.arrayZ, other->page_map.arrayZ, count * sizeof (page_map.arrayZ[0]));
+ memcpy (pages.arrayZ(), other->pages.arrayZ(), count * sizeof (pages.arrayZ()[0]));
+ memcpy (page_map.arrayZ(), other->page_map.arrayZ(), count * sizeof (page_map.arrayZ()[0]));
}
inline bool is_equal (const hb_set_t *other) const
diff --git a/src/hb-subset.cc b/src/hb-subset.cc
index 2bed3586..9f14b89b 100644
--- a/src/hb-subset.cc
+++ b/src/hb-subset.cc
@@ -77,7 +77,7 @@ _subset2 (hb_subset_plan_t *plan)
return false;
}
retry:
- hb_serialize_context_t serializer (buf.arrayZ, buf_size);
+ hb_serialize_context_t serializer (buf.arrayZ(), buf_size);
hb_subset_context_t c (plan, &serializer);
result = table->subset (&c);
if (serializer.ran_out_of_room)
diff --git a/src/hb-vector.hh b/src/hb-vector.hh
index 27087538..766e5fb8 100644
--- a/src/hb-vector.hh
+++ b/src/hb-vector.hh
@@ -35,35 +35,42 @@ template <typename Type, unsigned int StaticSize=8>
struct hb_vector_t
{
unsigned int len;
+ private:
unsigned int allocated; /* == 0 means allocation failed. */
- Type *arrayZ;
+ Type *arrayZ_;
Type static_array[StaticSize];
+ public:
void init (void)
{
len = 0;
allocated = ARRAY_LENGTH (static_array);
- arrayZ = static_array;
+ arrayZ_ = nullptr;
}
+ inline Type * arrayZ (void)
+ { return arrayZ_ ? arrayZ_ : static_array; }
+ inline const Type * arrayZ (void) const
+ { return arrayZ_ ? arrayZ_ : static_array; }
+
inline Type& operator [] (unsigned int i)
{
if (unlikely (i >= len))
return Crap (Type);
- return arrayZ[i];
+ return arrayZ()[i];
}
inline const Type& operator [] (unsigned int i) const
{
if (unlikely (i >= len))
return Null(Type);
- return arrayZ[i];
+ return arrayZ()[i];
}
inline Type *push (void)
{
if (unlikely (!resize (len + 1)))
return &Crap(Type);
- return &arrayZ[len - 1];
+ return &arrayZ()[len - 1];
}
inline Type *push (const Type& v)
{
@@ -91,17 +98,17 @@ struct hb_vector_t
Type *new_array = nullptr;
- if (arrayZ == static_array)
+ if (!arrayZ_)
{
new_array = (Type *) calloc (new_allocated, sizeof (Type));
if (new_array)
- memcpy (new_array, arrayZ, len * sizeof (Type));
+ memcpy (new_array, static_array, len * sizeof (Type));
}
else
{
bool overflows = (new_allocated < allocated) || hb_unsigned_mul_overflows (new_allocated, sizeof (Type));
if (likely (!overflows))
- new_array = (Type *) realloc (arrayZ, new_allocated * sizeof (Type));
+ new_array = (Type *) realloc (arrayZ_, new_allocated * sizeof (Type));
}
if (unlikely (!new_array))
@@ -110,7 +117,7 @@ struct hb_vector_t
return false;
}
- arrayZ = new_array;
+ arrayZ_ = new_array;
allocated = new_allocated;
return true;
@@ -123,7 +130,7 @@ struct hb_vector_t
return false;
if (size > len)
- memset (arrayZ + len, 0, (size - len) * sizeof (*arrayZ));
+ memset (arrayZ() + len, 0, (size - len) * sizeof (*arrayZ()));
len = size;
return true;
@@ -137,12 +144,13 @@ struct hb_vector_t
inline void remove (unsigned int i)
{
- if (unlikely (i >= len))
- return;
- memmove (static_cast<void *> (&arrayZ[i]),
- static_cast<void *> (&arrayZ[i + 1]),
- (len - i - 1) * sizeof (Type));
- len--;
+ if (unlikely (i >= len))
+ return;
+ Type *array = arrayZ();
+ memmove (static_cast<void *> (&array[i]),
+ static_cast<void *> (&array[i + 1]),
+ (len - i - 1) * sizeof (Type));
+ len--;
}
inline void shrink (int size_)
@@ -153,41 +161,55 @@ struct hb_vector_t
}
template <typename T>
- inline Type *find (T v) {
+ inline Type *find (T v)
+ {
+ Type *array = arrayZ();
for (unsigned int i = 0; i < len; i++)
- if (arrayZ[i] == v)
- return &arrayZ[i];
+ if (array[i] == v)
+ return &array[i];
return nullptr;
}
template <typename T>
- inline const Type *find (T v) const {
+ inline const Type *find (T v) const
+ {
+ const Type *array = arrayZ();
for (unsigned int i = 0; i < len; i++)
- if (arrayZ[i] == v)
- return &arrayZ[i];
+ if (array[i] == v)
+ return &array[i];
return nullptr;
}
inline void qsort (int (*cmp)(const void*, const void*))
{
- ::qsort (arrayZ, len, sizeof (Type), cmp);
+ ::qsort (arrayZ(), len, sizeof (Type), cmp);
}
inline void qsort (void)
{
- ::qsort (arrayZ, len, sizeof (Type), Type::cmp);
+ ::qsort (arrayZ(), len, sizeof (Type), Type::cmp);
}
inline void qsort (unsigned int start, unsigned int end)
{
- ::qsort (arrayZ + start, end - start, sizeof (Type), Type::cmp);
+ ::qsort (arrayZ() + start, end - start, sizeof (Type), Type::cmp);
}
template <typename T>
inline Type *lsearch (const T &x)
{
+ Type *array = arrayZ();
+ for (unsigned int i = 0; i < len; i++)
+ if (0 == array[i].cmp (&x))
+ return &array[i];
+ return nullptr;
+ }
+ template <typename T>
+ inline const Type *lsearch (const T &x) const
+ {
+ const Type *array = arrayZ();
for (unsigned int i = 0; i < len; i++)
- if (0 == this->arrayZ[i].cmp (&x))
- return &arrayZ[i];
+ if (0 == array[i].cmp (&x))
+ return &array[i];
return nullptr;
}
@@ -195,22 +217,23 @@ struct hb_vector_t
inline Type *bsearch (const T &x)
{
unsigned int i;
- return bfind (x, &i) ? &arrayZ[i] : nullptr;
+ return bfind (x, &i) ? &arrayZ()[i] : nullptr;
}
template <typename T>
inline const Type *bsearch (const T &x) const
{
unsigned int i;
- return bfind (x, &i) ? &arrayZ[i] : nullptr;
+ return bfind (x, &i) ? &arrayZ()[i] : nullptr;
}
template <typename T>
inline bool bfind (const T &x, unsigned int *i) const
{
int min = 0, max = (int) this->len - 1;
+ const Type *array = this->arrayZ();
while (min <= max)
{
int mid = (min + max) / 2;
- int c = this->arrayZ[mid].cmp (&x);
+ int c = array[mid].cmp (&x);
if (c < 0)
max = mid - 1;
else if (c > 0)
@@ -221,7 +244,7 @@ struct hb_vector_t
return true;
}
}
- if (max < 0 || (max < (int) this->len && this->arrayZ[max].cmp (&x) > 0))
+ if (max < 0 || (max < (int) this->len && array[max].cmp (&x) > 0))
max++;
*i = max;
return false;
@@ -229,17 +252,18 @@ struct hb_vector_t
inline void fini_deep (void)
{
+ Type *array = arrayZ();
unsigned int count = len;
for (unsigned int i = 0; i < count; i++)
- arrayZ[i].fini ();
+ array[i].fini ();
fini ();
}
inline void fini (void)
{
- if (arrayZ != static_array)
- free (arrayZ);
- arrayZ = nullptr;
+ if (arrayZ_)
+ free (arrayZ_);
+ arrayZ_ = nullptr;
allocated = len = 0;
}
};
commit 5469d80707d32c733b1c60f79ab2f217e879de55
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Oct 5 18:21:08 2018 +0200
Add hb_vector_t::fini_deep ()
diff --git a/src/hb-vector.hh b/src/hb-vector.hh
index da548cbb..27087538 100644
--- a/src/hb-vector.hh
+++ b/src/hb-vector.hh
@@ -227,6 +227,14 @@ struct hb_vector_t
return false;
}
+ inline void fini_deep (void)
+ {
+ unsigned int count = len;
+ for (unsigned int i = 0; i < count; i++)
+ arrayZ[i].fini ();
+ fini ();
+ }
+
inline void fini (void)
{
if (arrayZ != static_array)
commit 4831e615d173be9c7e140be0fa9017e4d9e499af
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Oct 5 18:14:13 2018 +0200
[morx] Fix memory access issue
If buffer was enlarged, info was being outdated.
Fixes https://github.com/harfbuzz/harfbuzz/issues/1225
diff --git a/src/hb-aat-layout-common.hh b/src/hb-aat-layout-common.hh
index b0faa1db..c6b519d8 100644
--- a/src/hb-aat-layout-common.hh
+++ b/src/hb-aat-layout-common.hh
@@ -546,8 +546,6 @@ struct StateTableDriver
template <typename context_t>
inline void drive (context_t *c)
{
- hb_glyph_info_t *info = buffer->info;
-
if (!c->in_place)
buffer->clear_output ();
@@ -556,7 +554,7 @@ struct StateTableDriver
for (buffer->idx = 0;;)
{
unsigned int klass = buffer->idx < buffer->len ?
- machine.get_class (info[buffer->idx].codepoint, num_glyphs) :
+ machine.get_class (buffer->info[buffer->idx].codepoint, num_glyphs) :
(unsigned) StateTable<EntryData>::CLASS_END_OF_TEXT;
const Entry<EntryData> *entry = machine.get_entryZ (state, klass);
if (unlikely (!entry))
commit 5a41cf6be69adb0b5b29976a33c4c6dd6ce7afc5
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Oct 5 11:33:19 2018 +0200
[test/text-rendering-tests] Update from upstream
diff --git a/test/shaping/data/text-rendering-tests/DISABLED b/test/shaping/data/text-rendering-tests/DISABLED
index 8539c0ee..4e8b1cf2 100644
--- a/test/shaping/data/text-rendering-tests/DISABLED
+++ b/test/shaping/data/text-rendering-tests/DISABLED
@@ -1,3 +1,6 @@
+# https://github.com/harfbuzz/harfbuzz/issues/1224
+tests/MORX-35.tests
+
# Non-Unicode cmap
tests/CMAP-3.tests
diff --git a/test/shaping/data/text-rendering-tests/Makefile.sources b/test/shaping/data/text-rendering-tests/Makefile.sources
index 79f22adb..29d064b7 100644
--- a/test/shaping/data/text-rendering-tests/Makefile.sources
+++ b/test/shaping/data/text-rendering-tests/Makefile.sources
@@ -55,6 +55,7 @@ TESTS = \
tests/MORX-32.tests \
tests/MORX-33.tests \
tests/MORX-34.tests \
+ tests/MORX-36.tests \
tests/MORX-3.tests \
tests/MORX-4.tests \
tests/MORX-5.tests \
@@ -67,6 +68,7 @@ TESTS = \
$(NULL)
DISBALED_TESTS = \
+ tests/MORX-35.tests \
tests/CMAP-3.tests \
tests/SHARAN-1.tests \
tests/SHBALI-1.tests \
diff --git a/test/shaping/data/text-rendering-tests/fonts/TestMORXThirtyfive.ttf b/test/shaping/data/text-rendering-tests/fonts/TestMORXThirtyfive.ttf
new file mode 100644
index 00000000..f1570631
Binary files /dev/null and b/test/shaping/data/text-rendering-tests/fonts/TestMORXThirtyfive.ttf differ
diff --git a/test/shaping/data/text-rendering-tests/fonts/TestMORXThirtysix.ttf b/test/shaping/data/text-rendering-tests/fonts/TestMORXThirtysix.ttf
new file mode 100644
index 00000000..6676e527
Binary files /dev/null and b/test/shaping/data/text-rendering-tests/fonts/TestMORXThirtysix.ttf differ
diff --git a/test/shaping/data/text-rendering-tests/tests/MORX-35.tests b/test/shaping/data/text-rendering-tests/tests/MORX-35.tests
new file mode 100644
index 00000000..1061034d
--- /dev/null
+++ b/test/shaping/data/text-rendering-tests/tests/MORX-35.tests
@@ -0,0 +1,2 @@
+../fonts/TestMORXThirtyfive.ttf:--font-size=1000 --ned --remove-default-ignorables --font-funcs=ft:U+0041:[A|B at 639,0|C at 1265,0]
+../fonts/TestMORXThirtyfive.ttf:--font-size=1000 --ned --remove-default-ignorables --font-funcs=ft:U+0058,U+0041,U+0059:[X|A at 586,0|B at 1225,0|C at 1851,0|E at 2447,0|Y at 3003,0]
diff --git a/test/shaping/data/text-rendering-tests/tests/MORX-36.tests b/test/shaping/data/text-rendering-tests/tests/MORX-36.tests
new file mode 100644
index 00000000..6b2340e6
--- /dev/null
+++ b/test/shaping/data/text-rendering-tests/tests/MORX-36.tests
@@ -0,0 +1 @@
+../fonts/TestMORXThirtysix.ttf::U+0041:*
commit a62f37d6fa412b799b7247b813f6e65a968e7645
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Oct 5 02:49:29 2018 +0200
Change vendor features from Harf/Buzz to HARF/BUZZ
https://github.com/harfbuzz/harfbuzz/commit/a01194aaf4c15160330b4042066263b2c963b658#commitcomment-30772041
"The tag space of tags consisting of four uppercase letters (A-Z) with no punctuation,
spaces, or numbers, is reserved as a vendor space. Font vendors may use such tags to
identify private features."
diff --git a/src/hb-ot-shape.cc b/src/hb-ot-shape.cc
index 7d22720e..453d995a 100644
--- a/src/hb-ot-shape.cc
+++ b/src/hb-ot-shape.cc
@@ -132,12 +132,12 @@ hb_ot_shape_collect_features (hb_ot_shape_planner_t *planner,
/* Random! */
map->enable_feature (HB_TAG ('r','a','n','d'), F_RANDOM, HB_OT_MAP_MAX_VALUE);
- map->enable_feature (HB_TAG('H','a','r','f'));
+ map->enable_feature (HB_TAG('H','A','R','F'));
if (planner->shaper->collect_features)
planner->shaper->collect_features (planner);
- map->enable_feature (HB_TAG('B','u','z','z'));
+ map->enable_feature (HB_TAG('B','U','Z','Z'));
for (unsigned int i = 0; i < ARRAY_LENGTH (common_features); i++)
map->add_feature (common_features[i]);
More information about the HarfBuzz
mailing list