Merge branch 'master' into cff-renaming

This commit is contained in:
Michiharu Ariza 2018-12-21 14:58:53 -08:00
commit 785408d4f7
14 changed files with 267 additions and 21 deletions

15
NEWS
View File

@ -1,3 +1,18 @@
Overview of changes leading to 2.3.0
Thursday, December 20, 2018
====================================
- Fix regression on big-endian architectures. Ouch!
- Misc bug and build fixes.
- Fix subsetting of simple GSUB/GDEF.
- Merge CFF / CFF2 support contributed by Adobe. This mostly involves
the subsetter, but also get_glyph_extents on CFF fonts.
New API in hb-aat.h:
+hb_aat_layout_has_substitution()
+hb_aat_layout_has_positioning()
+hb_aat_layout_has_tracking()
Overview of changes leading to 2.2.0 Overview of changes leading to 2.2.0
Thursday, November 29, 2018 Thursday, November 29, 2018
==================================== ====================================

View File

@ -1,6 +1,6 @@
AC_PREREQ([2.64]) AC_PREREQ([2.64])
AC_INIT([HarfBuzz], AC_INIT([HarfBuzz],
[2.2.0], [2.3.0],
[https://github.com/harfbuzz/harfbuzz/issues/new], [https://github.com/harfbuzz/harfbuzz/issues/new],
[harfbuzz], [harfbuzz],
[http://harfbuzz.org/]) [http://harfbuzz.org/])

View File

@ -384,14 +384,20 @@ dump_use_data_SOURCES = dump-use-data.cc hb-ot-shape-complex-use-table.cc
dump_use_data_CPPFLAGS = $(HBCFLAGS) dump_use_data_CPPFLAGS = $(HBCFLAGS)
dump_use_data_LDADD = libharfbuzz.la $(HBLIBS) dump_use_data_LDADD = libharfbuzz.la $(HBLIBS)
check_PROGRAMS += test-ot-tag test-unicode-ranges COMPILED_TESTS = test-iter test-ot-tag test-unicode-ranges
TESTS += test-ot-tag test-unicode-ranges check_PROGRAMS += $(COMPILED_TESTS)
TESTS += $(COMPILED_TESTS)
test_iter_SOURCES = test-iter.cc hb-static.cc
test_iter_CPPFLAGS = $(HBCFLAGS) -DMAIN
test_iter_LDADD = libharfbuzz.la $(HBLIBS)
test_ot_tag_SOURCES = hb-ot-tag.cc test_ot_tag_SOURCES = hb-ot-tag.cc
test_ot_tag_CPPFLAGS = $(HBCFLAGS) -DMAIN test_ot_tag_CPPFLAGS = $(HBCFLAGS) -DMAIN
test_ot_tag_LDADD = libharfbuzz.la $(HBLIBS) test_ot_tag_LDADD = libharfbuzz.la $(HBLIBS)
test_unicode_ranges_SOURCES = test-unicode-ranges.cc test_unicode_ranges_SOURCES = test-unicode-ranges.cc
test_unicode_ranges_CPPFLAGS = $(HBCFLAGS) -DMAIN
test_unicode_ranges_LDADD = libharfbuzz.la $(HBLIBS) test_unicode_ranges_LDADD = libharfbuzz.la $(HBLIBS)
TESTS_ENVIRONMENT = \ TESTS_ENVIRONMENT = \

View File

@ -36,6 +36,7 @@ HB_BASE_sources = \
hb-face.hh \ hb-face.hh \
hb-font.cc \ hb-font.cc \
hb-font.hh \ hb-font.hh \
hb-iter.hh \
hb-kern.hh \ hb-kern.hh \
hb-machinery.hh \ hb-machinery.hh \
hb-map.cc \ hb-map.cc \

View File

@ -209,7 +209,7 @@ hb_aat_layout_compile_map (const hb_aat_map_builder_t *mapper,
* @face: * @face:
* *
* Returns: * Returns:
* Since: REPLACEME * Since: 2.3.0
*/ */
hb_bool_t hb_bool_t
hb_aat_layout_has_substitution (hb_face_t *face) hb_aat_layout_has_substitution (hb_face_t *face)
@ -270,7 +270,7 @@ hb_aat_layout_remove_deleted_glyphs (hb_buffer_t *buffer)
* @face: * @face:
* *
* Returns: * Returns:
* Since: REPLACEME * Since: 2.3.0
*/ */
hb_bool_t hb_bool_t
hb_aat_layout_has_positioning (hb_face_t *face) hb_aat_layout_has_positioning (hb_face_t *face)
@ -300,7 +300,7 @@ hb_aat_layout_position (const hb_ot_shape_plan_t *plan,
* @face: * @face:
* *
* Returns: * Returns:
* Since: REPLACEME * Since: 2.3.0
*/ */
hb_bool_t hb_bool_t
hb_aat_layout_has_tracking (hb_face_t *face) hb_aat_layout_has_tracking (hb_face_t *face)

View File

@ -36,7 +36,7 @@ struct hb_sorted_array_t;
template <typename Type> template <typename Type>
struct hb_array_t struct hb_array_t
{ {
typedef Type ItemType; typedef Type item_t;
enum { item_size = hb_static_size (Type) }; enum { item_size = hb_static_size (Type) };
/* /*

105
src/hb-iter.hh Normal file
View File

@ -0,0 +1,105 @@
/*
* Copyright © 2018 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_ITER_HH
#define HB_ITER_HH
#include "hb.hh"
/* Unified iterator object.
*
* The goal of this template is to make the same iterator interface
* available to all types, and make it very easy and compact to use.
* hb_iter_tator objects are small, light-weight, objects that can be
* copied by value. If the collection / object being iterated on
* is writable, then the iterator returns lvalues, otherwise it
* returns rvalues.
*/
/* Base class for all iterators. */
template <typename Iter, typename Item = typename Iter::__item_type__>
struct hb_iter_t
{
typedef Iter iter_t;
typedef Item item_t;
/* https://en.wikipedia.org/wiki/Curiously_recurring_template_pattern */
const iter_t* thiz () const { return static_cast<const iter_t *> (this); }
iter_t* thiz () { return static_cast< iter_t *> (this); }
/* Operators. */
operator iter_t () { return iter(); }
explicit_operator bool () const { return more (); }
item_t& operator * () { return item (); }
item_t& operator [] (unsigned i) { return item (i); }
iter_t& operator += (unsigned count) { forward (count); return *thiz(); }
iter_t& operator ++ () { next (); return *thiz(); }
iter_t& operator -= (unsigned count) { rewind (count); return *thiz(); }
iter_t& operator -- () { prev (); return *thiz(); }
iter_t operator + (unsigned count) { iter_t c (*thiz()); c += count; return c; }
iter_t operator ++ (int) { iter_t c (*thiz()); ++*thiz(); return c; }
iter_t operator - (unsigned count) { iter_t c (*thiz()); c -= count; return c; }
iter_t operator -- (int) { iter_t c (*thiz()); --*thiz(); return c; }
/* Methods. */
iter_t iter () const { return *thiz(); }
item_t& item () const { return thiz()->__item__ (); }
item_t& item_at (unsigned i) const { return thiz()->__item_at__ (i); }
bool more () const { return thiz()->__more__ (); }
void next () { thiz()->__next__ (); }
void forward (unsigned n) { thiz()->__forward__ (n); }
void prev () { thiz()->__prev__ (); }
void rewind (unsigned n) { thiz()->__rewind__ (n); }
unsigned len () const { return thiz()->__len__ (); }
/*
* Subclasses overrides:
*/
/* Access: Implement __item__(), or __item_at__() if random-access. */
item_t& __item__ () const { return thiz()->item_at (0); }
item_t& __item_at__ (unsigned i) const { return *(thiz() + i); }
/* Termination: Implement __more__() or __end__(). */
bool __more__ () const { return item () != thiz()->__end__ (); }
const item_t& __end__ () const { return iter_t::__sentinel__; }
/* Advancing: Implement __next__(), or __forward__() if random-access. */
void __next__ () { thiz()->forward (1); }
void __forward__ (unsigned n) { while (n--) next (); }
/* Rewinding: Implement __prev__() or __rewind__() if bidirectional. */
void __prev__ () { thiz()->rewind (1); }
void __rewind__ (unsigned n) { while (n--) prev (); }
/* Population: Implement __len__() if known. */
unsigned __len__ () const
{ iter_t c (*thiz()); unsigned l = 0; while (c) { c++; l++; }; return l; }
};
#endif /* HB_ITER_HH */

View File

@ -390,7 +390,7 @@ struct hb_sanitize_context_t :
{ {
if (this->may_edit (obj, hb_static_size (Type))) if (this->may_edit (obj, hb_static_size (Type)))
{ {
const_cast<Type *> (obj)->set (v); hb_assign (* const_cast<Type *> (obj), v);
return true; return true;
} }
return false; return false;
@ -599,6 +599,8 @@ struct hb_serialize_context_t
memcpy (ret, &obj, size); memcpy (ret, &obj, size);
return ret; return ret;
} }
template <typename Type>
hb_serialize_context_t &operator << (const Type &obj) { embed (obj); return *this; }
template <typename Type> template <typename Type>
Type *extend_size (Type &obj, unsigned int size) Type *extend_size (Type &obj, unsigned int size)
@ -665,7 +667,6 @@ template <typename Type>
struct BEInt<Type, 1> struct BEInt<Type, 1>
{ {
public: public:
typedef Type type;
void set (Type V) { v = V; } void set (Type V) { v = V; }
operator Type () const { return v; } operator Type () const { return v; }
private: uint8_t v; private: uint8_t v;
@ -674,7 +675,6 @@ template <typename Type>
struct BEInt<Type, 2> struct BEInt<Type, 2>
{ {
public: public:
typedef Type type;
void set (Type V) void set (Type V)
{ {
v[0] = (V >> 8) & 0xFF; v[0] = (V >> 8) & 0xFF;
@ -703,7 +703,6 @@ template <typename Type>
struct BEInt<Type, 3> struct BEInt<Type, 3>
{ {
public: public:
typedef Type type;
void set (Type V) void set (Type V)
{ {
v[0] = (V >> 16) & 0xFF; v[0] = (V >> 16) & 0xFF;

View File

@ -59,7 +59,10 @@ struct hb_null_size
{ enum { value = _hb_null_size<T, _hb_bool_type<true> >::value }; }; { enum { value = _hb_null_size<T, _hb_bool_type<true> >::value }; };
#define hb_null_size(T) hb_null_size<T>::value #define hb_null_size(T) hb_null_size<T>::value
/* This doesn't belong here, but since is copy/paste from above, put it here. */ /* These doesn't belong here, but since is copy/paste from above, put it here. */
/* hb_static_size (T)
* Returns T::static_size if T::min_size is defined, or sizeof (T) otherwise. */
template <typename T, typename B> template <typename T, typename B>
struct _hb_static_size struct _hb_static_size
@ -74,6 +77,25 @@ struct hb_static_size
#define hb_static_size(T) hb_static_size<T>::value #define hb_static_size(T) hb_static_size<T>::value
/* hb_assign (obj, value)
* Calls obj.set (value) if obj.min_size is defined and value has different type
* from obj, or obj = v otherwise. */
template <typename T, typename V, typename B>
struct _hb_assign
{ static inline void value (T &o, const V v) { o = v; } };
template <typename T, typename V>
struct _hb_assign<T, V, _hb_bool_type<(bool) (1 + (unsigned int) T::min_size)> >
{ static inline void value (T &o, const V v) { o.set (v); } };
template <typename T>
struct _hb_assign<T, T, _hb_bool_type<(bool) (1 + (unsigned int) T::min_size)> >
{ static inline void value (T &o, const T v) { o = v; } };
template <typename T, typename V>
static inline void hb_assign (T &o, const V v)
{ _hb_assign<T, V, _hb_bool_type<true> >::value (o, v); };
/* /*
* Null() * Null()
*/ */

View File

@ -352,7 +352,7 @@ static inline Type& operator + (Base &base, OffsetTo<Type, OffsetType, has_null>
template <typename Type> template <typename Type>
struct UnsizedArrayOf struct UnsizedArrayOf
{ {
typedef Type ItemType; typedef Type item_t;
enum { item_size = hb_static_size (Type) }; enum { item_size = hb_static_size (Type) };
HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (UnsizedArrayOf, Type); HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (UnsizedArrayOf, Type);
@ -508,7 +508,7 @@ struct SortedUnsizedArrayOf : UnsizedArrayOf<Type>
template <typename Type, typename LenType=HBUINT16> template <typename Type, typename LenType=HBUINT16>
struct ArrayOf struct ArrayOf
{ {
typedef Type ItemType; typedef Type item_t;
enum { item_size = hb_static_size (Type) }; enum { item_size = hb_static_size (Type) };
HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2 (ArrayOf, Type, LenType); HB_NO_CREATE_COPY_ASSIGN_TEMPLATE2 (ArrayOf, Type, LenType);
@ -553,12 +553,13 @@ struct ArrayOf
if (unlikely (!c->extend (*this))) return_trace (false); if (unlikely (!c->extend (*this))) return_trace (false);
return_trace (true); return_trace (true);
} }
bool serialize (hb_serialize_context_t *c, hb_array_t<const Type> items) template <typename T>
bool serialize (hb_serialize_context_t *c, hb_array_t<const T> items)
{ {
TRACE_SERIALIZE (this); TRACE_SERIALIZE (this);
if (unlikely (!serialize (c, items.len))) return_trace (false); if (unlikely (!serialize (c, items.len))) return_trace (false);
for (unsigned int i = 0; i < items.len; i++) for (unsigned int i = 0; i < items.len; i++)
arrayZ[i] = items[i]; hb_assign (arrayZ[i], items[i]);
return_trace (true); return_trace (true);
} }

View File

@ -34,7 +34,7 @@
template <typename Type, unsigned int PreallocedCount=8> template <typename Type, unsigned int PreallocedCount=8>
struct hb_vector_t struct hb_vector_t
{ {
typedef Type ItemType; typedef Type item_t;
enum { item_size = hb_static_size (Type) }; enum { item_size = hb_static_size (Type) };
HB_NO_COPY_ASSIGN_TEMPLATE2 (hb_vector_t, Type, PreallocedCount); HB_NO_COPY_ASSIGN_TEMPLATE2 (hb_vector_t, Type, PreallocedCount);
@ -89,6 +89,8 @@ struct hb_vector_t
return arrayZ()[i]; return arrayZ()[i];
} }
explicit_operator bool () const { return len; }
hb_array_t<Type> as_array () hb_array_t<Type> as_array ()
{ return hb_array (arrayZ(), len); } { return hb_array (arrayZ(), len); }
hb_array_t<const Type> as_array () const hb_array_t<const Type> as_array () const

View File

@ -37,10 +37,10 @@ HB_BEGIN_DECLS
#define HB_VERSION_MAJOR 2 #define HB_VERSION_MAJOR 2
#define HB_VERSION_MINOR 2 #define HB_VERSION_MINOR 3
#define HB_VERSION_MICRO 0 #define HB_VERSION_MICRO 0
#define HB_VERSION_STRING "2.2.0" #define HB_VERSION_STRING "2.3.0"
#define HB_VERSION_ATLEAST(major,minor,micro) \ #define HB_VERSION_ATLEAST(major,minor,micro) \
((major)*10000+(minor)*100+(micro) <= \ ((major)*10000+(minor)*100+(micro) <= \

97
src/test-iter.cc Normal file
View File

@ -0,0 +1,97 @@
/*
* Copyright © 2018 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
*/
#include "hb-iter.hh"
#include "hb-array.hh"
template <typename T>
struct array_iter_t : hb_iter_t<array_iter_t<T>, T>
{
array_iter_t (hb_array_t<T> arr_) : arr (arr_) {}
typedef T __item_type__;
T& __item_at__ (unsigned i) const { return arr[i]; }
bool __more__ () const { return arr.len; }
void __forward__ (unsigned n) { arr += n; }
void __rewind__ (unsigned n) { arr -= n; }
unsigned __len__ () const { return arr.len; }
private:
hb_array_t<T> arr;
};
template <typename T>
struct some_array_t
{
some_array_t (hb_array_t<T> arr_) : arr (arr_) {}
typedef array_iter_t<T> iter_t;
array_iter_t<T> iter () { return array_iter_t<T> (arr); }
operator array_iter_t<T> () { return iter (); }
operator hb_iter_t<array_iter_t<T> > () { return iter (); }
private:
hb_array_t<T> arr;
};
template <typename I, typename V> inline void
hb_fill (hb_iter_t<I> &i, const V &v)
{
for (; i; i++)
hb_assign (*i, v);
}
template <typename S, typename D> inline bool
hb_copy (hb_iter_t<D> &id, hb_iter_t<S> &is)
{
for (; id && is; ++id, ++is)
*id = *is;
return !id;
}
int
main (int argc, char **argv)
{
const int src[10] = {};
int dst[20];
hb_vector_t<int> v;
array_iter_t<const int> s (src); /* Implicit conversion from static array. */
array_iter_t<const int> s2 (v); /* Implicit conversion from vector. */
array_iter_t<int> t (dst);
some_array_t<const int> a (src);
s2 = s;
hb_fill (t, 42);
hb_copy (t, s);
// hb_copy (t, a.iter ());
return 0;
}

View File

@ -24,8 +24,6 @@
* Google Author(s): Garret Rieger * Google Author(s): Garret Rieger
*/ */
#include "hb.hh"
#include "hb-ot-os2-unicode-ranges.hh" #include "hb-ot-os2-unicode-ranges.hh"
static void static void