mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-14 17:13:40 +00:00
commit
9d0bc085ee
11 changed files with 62 additions and 59 deletions
|
@ -8,7 +8,7 @@ namespace GPOS_impl {
|
|||
struct AnchorMatrix
|
||||
{
|
||||
HBUINT16 rows; /* Number of rows */
|
||||
UnsizedArrayOf<Offset16To<Anchor>>
|
||||
UnsizedArrayOf<Offset16To<Anchor, AnchorMatrix>>
|
||||
matrixZ; /* Matrix of offsets to Anchor tables--
|
||||
* from beginning of AnchorMatrix table */
|
||||
public:
|
||||
|
|
|
@ -11,21 +11,21 @@ struct EntryExitRecord
|
|||
{
|
||||
friend struct CursivePosFormat1;
|
||||
|
||||
bool sanitize (hb_sanitize_context_t *c, const void *base) const
|
||||
bool sanitize (hb_sanitize_context_t *c, const struct CursivePosFormat1 *base) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (entryAnchor.sanitize (c, base) && exitAnchor.sanitize (c, base));
|
||||
}
|
||||
|
||||
void collect_variation_indices (hb_collect_variation_indices_context_t *c,
|
||||
const void *src_base) const
|
||||
const struct CursivePosFormat1 *src_base) const
|
||||
{
|
||||
(src_base+entryAnchor).collect_variation_indices (c);
|
||||
(src_base+exitAnchor).collect_variation_indices (c);
|
||||
}
|
||||
|
||||
bool subset (hb_subset_context_t *c,
|
||||
const void *src_base) const
|
||||
const struct CursivePosFormat1 *src_base) const
|
||||
{
|
||||
TRACE_SERIALIZE (this);
|
||||
auto *out = c->serializer->embed (this);
|
||||
|
@ -38,11 +38,11 @@ struct EntryExitRecord
|
|||
}
|
||||
|
||||
protected:
|
||||
Offset16To<Anchor>
|
||||
Offset16To<Anchor, struct CursivePosFormat1>
|
||||
entryAnchor; /* Offset to EntryAnchor table--from
|
||||
* beginning of CursivePos
|
||||
* subtable--may be NULL */
|
||||
Offset16To<Anchor>
|
||||
Offset16To<Anchor, struct CursivePosFormat1>
|
||||
exitAnchor; /* Offset to ExitAnchor table--from
|
||||
* beginning of CursivePos
|
||||
* subtable--may be NULL */
|
||||
|
@ -262,7 +262,7 @@ struct CursivePosFormat1
|
|||
hb_requires (hb_is_iterator (Iterator))>
|
||||
void serialize (hb_subset_context_t *c,
|
||||
Iterator it,
|
||||
const void *src_base)
|
||||
const struct CursivePosFormat1 *src_base)
|
||||
{
|
||||
if (unlikely (!c->serializer->extend_min ((*this)))) return;
|
||||
this->format = 1;
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace Layout {
|
|||
namespace GPOS_impl {
|
||||
|
||||
template <typename Types>
|
||||
struct PairPosFormat2_4
|
||||
struct PairPosFormat2_4 : ValueBase
|
||||
{
|
||||
protected:
|
||||
HBUINT16 format; /* Format identifier--format = 2 */
|
||||
|
|
|
@ -9,7 +9,7 @@ namespace GPOS_impl {
|
|||
|
||||
|
||||
template <typename Types>
|
||||
struct PairSet
|
||||
struct PairSet : ValueBase
|
||||
{
|
||||
template <typename Types2>
|
||||
friend struct PairPosFormat1_3;
|
||||
|
|
|
@ -29,7 +29,7 @@ struct PairValueRecord
|
|||
|
||||
struct context_t
|
||||
{
|
||||
const void *base;
|
||||
const ValueBase *base;
|
||||
const ValueFormat *valueFormats;
|
||||
const ValueFormat *newFormats;
|
||||
unsigned len1; /* valueFormats[0].get_len() */
|
||||
|
@ -62,7 +62,7 @@ struct PairValueRecord
|
|||
|
||||
void collect_variation_indices (hb_collect_variation_indices_context_t *c,
|
||||
const ValueFormat *valueFormats,
|
||||
const void *base) const
|
||||
const ValueBase *base) const
|
||||
{
|
||||
unsigned record1_len = valueFormats[0].get_len ();
|
||||
unsigned record2_len = valueFormats[1].get_len ();
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace OT {
|
|||
namespace Layout {
|
||||
namespace GPOS_impl {
|
||||
|
||||
struct SinglePosFormat1
|
||||
struct SinglePosFormat1 : ValueBase
|
||||
{
|
||||
protected:
|
||||
HBUINT16 format; /* Format identifier--format = 1 */
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace OT {
|
|||
namespace Layout {
|
||||
namespace GPOS_impl {
|
||||
|
||||
struct SinglePosFormat2
|
||||
struct SinglePosFormat2 : ValueBase
|
||||
{
|
||||
protected:
|
||||
HBUINT16 format; /* Format identifier--format = 2 */
|
||||
|
|
|
@ -9,6 +9,8 @@ namespace GPOS_impl {
|
|||
|
||||
typedef HBUINT16 Value;
|
||||
|
||||
struct ValueBase {}; // Dummy base class tag for OffsetTo<Value> bases.
|
||||
|
||||
typedef UnsizedArrayOf<Value> ValueRecord;
|
||||
|
||||
struct ValueFormat : HBUINT16
|
||||
|
@ -78,7 +80,7 @@ struct ValueFormat : HBUINT16
|
|||
}
|
||||
|
||||
bool apply_value (hb_ot_apply_context_t *c,
|
||||
const void *base,
|
||||
const ValueBase *base,
|
||||
const Value *values,
|
||||
hb_glyph_position_t &glyph_pos) const
|
||||
{
|
||||
|
@ -165,7 +167,7 @@ struct ValueFormat : HBUINT16
|
|||
|
||||
void copy_values (hb_serialize_context_t *c,
|
||||
unsigned int new_format,
|
||||
const void *base,
|
||||
const ValueBase *base,
|
||||
const Value *values,
|
||||
const hb_hashmap_t<unsigned, hb_pair_t<unsigned, int>> *layout_variation_idx_delta_map) const
|
||||
{
|
||||
|
@ -217,7 +219,7 @@ struct ValueFormat : HBUINT16
|
|||
}
|
||||
|
||||
void collect_variation_indices (hb_collect_variation_indices_context_t *c,
|
||||
const void *base,
|
||||
const ValueBase *base,
|
||||
const hb_array_t<const Value>& values) const
|
||||
{
|
||||
unsigned format = *this;
|
||||
|
@ -252,7 +254,7 @@ struct ValueFormat : HBUINT16
|
|||
}
|
||||
|
||||
unsigned update_var_device_table_flags (const Value *values,
|
||||
const void *base,
|
||||
const ValueBase *base,
|
||||
const hb_hashmap_t<unsigned, hb_pair_t<unsigned, int>> *varidx_delta_map) const
|
||||
{
|
||||
unsigned format = *this;
|
||||
|
@ -271,7 +273,7 @@ struct ValueFormat : HBUINT16
|
|||
template<typename Iterator,
|
||||
hb_requires (hb_is_iterator (Iterator))>
|
||||
unsigned update_var_device_table_flags (Iterator it,
|
||||
const void* base,
|
||||
const ValueBase* base,
|
||||
const hb_hashmap_t<unsigned, hb_pair_t<unsigned, int>> *varidx_delta_map) const
|
||||
{
|
||||
unsigned new_format = 0;
|
||||
|
@ -282,7 +284,7 @@ struct ValueFormat : HBUINT16
|
|||
}
|
||||
|
||||
private:
|
||||
bool sanitize_value_devices (hb_sanitize_context_t *c, const void *base, const Value *values) const
|
||||
bool sanitize_value_devices (hb_sanitize_context_t *c, const ValueBase *base, const Value *values) const
|
||||
{
|
||||
unsigned int format = *this;
|
||||
|
||||
|
@ -299,17 +301,17 @@ struct ValueFormat : HBUINT16
|
|||
return true;
|
||||
}
|
||||
|
||||
static inline Offset16To<Device>& get_device (Value* value)
|
||||
static inline Offset16To<Device, ValueBase>& get_device (Value* value)
|
||||
{
|
||||
return *static_cast<Offset16To<Device> *> (value);
|
||||
return *static_cast<Offset16To<Device, ValueBase> *> (value);
|
||||
}
|
||||
static inline const Offset16To<Device>& get_device (const Value* value)
|
||||
static inline const Offset16To<Device, ValueBase>& get_device (const Value* value)
|
||||
{
|
||||
return *static_cast<const Offset16To<Device> *> (value);
|
||||
return *static_cast<const Offset16To<Device, ValueBase> *> (value);
|
||||
}
|
||||
static inline const Device& get_device (const Value* value,
|
||||
bool *worked,
|
||||
const void *base,
|
||||
const ValueBase *base,
|
||||
hb_sanitize_context_t &c)
|
||||
{
|
||||
if (worked) *worked |= bool (*value);
|
||||
|
@ -322,7 +324,7 @@ struct ValueFormat : HBUINT16
|
|||
}
|
||||
|
||||
void add_delta_to_value (HBINT16 *value,
|
||||
const void *base,
|
||||
const ValueBase *base,
|
||||
const Value *src_value,
|
||||
const hb_hashmap_t<unsigned, hb_pair_t<unsigned, int>> *layout_variation_idx_delta_map) const
|
||||
{
|
||||
|
@ -334,7 +336,8 @@ struct ValueFormat : HBUINT16
|
|||
*value += hb_second (*varidx_delta);
|
||||
}
|
||||
|
||||
bool copy_device (hb_serialize_context_t *c, const void *base,
|
||||
bool copy_device (hb_serialize_context_t *c,
|
||||
const ValueBase *base,
|
||||
const Value *src_value,
|
||||
const hb_hashmap_t<unsigned, hb_pair_t<unsigned, int>> *layout_variation_idx_delta_map,
|
||||
unsigned int new_format, Flags flag) const
|
||||
|
@ -375,7 +378,7 @@ struct ValueFormat : HBUINT16
|
|||
return (format & devices) != 0;
|
||||
}
|
||||
|
||||
bool sanitize_value (hb_sanitize_context_t *c, const void *base, const Value *values) const
|
||||
bool sanitize_value (hb_sanitize_context_t *c, const ValueBase *base, const Value *values) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
|
||||
|
@ -387,7 +390,7 @@ struct ValueFormat : HBUINT16
|
|||
return_trace (!has_device () || sanitize_value_devices (c, base, values));
|
||||
}
|
||||
|
||||
bool sanitize_values (hb_sanitize_context_t *c, const void *base, const Value *values, unsigned int count) const
|
||||
bool sanitize_values (hb_sanitize_context_t *c, const ValueBase *base, const Value *values, unsigned int count) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
unsigned size = get_size ();
|
||||
|
@ -401,7 +404,7 @@ struct ValueFormat : HBUINT16
|
|||
}
|
||||
|
||||
/* Just sanitize referenced Device tables. Doesn't check the values themselves. */
|
||||
bool sanitize_values_stride_unsafe (hb_sanitize_context_t *c, const void *base, const Value *values, unsigned int count, unsigned int stride) const
|
||||
bool sanitize_values_stride_unsafe (hb_sanitize_context_t *c, const ValueBase *base, const Value *values, unsigned int count, unsigned int stride) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
|
||||
|
@ -425,7 +428,7 @@ struct ValueFormat : HBUINT16
|
|||
}
|
||||
|
||||
void update_var_flag (const Value* value, Flags flag,
|
||||
unsigned int* format, const void *base,
|
||||
unsigned int* format, const ValueBase *base,
|
||||
const hb_hashmap_t<unsigned, hb_pair_t<unsigned, int>> *varidx_delta_map) const
|
||||
{
|
||||
if (*value)
|
||||
|
|
|
@ -38,8 +38,8 @@ struct SmallTypes {
|
|||
using HBUINT = HBUINT16;
|
||||
using HBGlyphID = HBGlyphID16;
|
||||
using Offset = Offset16;
|
||||
template <typename Type, bool has_null=true>
|
||||
using OffsetTo = OT::Offset16To<Type, has_null>;
|
||||
template <typename Type, typename BaseType=void, bool has_null=true>
|
||||
using OffsetTo = OT::Offset16To<Type, BaseType, has_null>;
|
||||
template <typename Type>
|
||||
using ArrayOf = OT::Array16Of<Type>;
|
||||
template <typename Type>
|
||||
|
@ -52,8 +52,8 @@ struct MediumTypes {
|
|||
using HBUINT = HBUINT24;
|
||||
using HBGlyphID = HBGlyphID24;
|
||||
using Offset = Offset24;
|
||||
template <typename Type, bool has_null=true>
|
||||
using OffsetTo = OT::Offset24To<Type, has_null>;
|
||||
template <typename Type, typename BaseType=void, bool has_null=true>
|
||||
using OffsetTo = OT::Offset24To<Type, BaseType, has_null>;
|
||||
template <typename Type>
|
||||
using ArrayOf = OT::Array24Of<Type>;
|
||||
template <typename Type>
|
||||
|
|
|
@ -315,7 +315,7 @@ struct ContextualSubtable
|
|||
bool has_glyph_classes;
|
||||
unsigned int mark;
|
||||
const ContextualSubtable *table;
|
||||
const UnsizedListOfOffset16To<Lookup<HBGlyphID16>, HBUINT, false> &subs;
|
||||
const UnsizedListOfOffset16To<Lookup<HBGlyphID16>, HBUINT, void, false> &subs;
|
||||
};
|
||||
|
||||
bool apply (hb_aat_apply_context_t *c) const
|
||||
|
@ -359,7 +359,7 @@ struct ContextualSubtable
|
|||
protected:
|
||||
StateTable<Types, EntryData>
|
||||
machine;
|
||||
NNOffsetTo<UnsizedListOfOffset16To<Lookup<HBGlyphID16>, HBUINT, false>, HBUINT>
|
||||
NNOffsetTo<UnsizedListOfOffset16To<Lookup<HBGlyphID16>, HBUINT, void, false>, HBUINT>
|
||||
substitutionTables;
|
||||
public:
|
||||
DEFINE_SIZE_STATIC (20);
|
||||
|
|
|
@ -309,7 +309,7 @@ struct _hb_has_null<Type, true>
|
|||
static Type *get_crap () { return &Crap (Type); }
|
||||
};
|
||||
|
||||
template <typename Type, typename OffsetType, bool has_null=true>
|
||||
template <typename Type, typename OffsetType, typename BaseType=void, bool has_null=true>
|
||||
struct OffsetTo : Offset<OffsetType, has_null>
|
||||
{
|
||||
using target_t = Type;
|
||||
|
@ -335,22 +335,22 @@ struct OffsetTo : Offset<OffsetType, has_null>
|
|||
}
|
||||
|
||||
template <typename Base,
|
||||
hb_enable_if (hb_is_convertible (const Base, const void *))>
|
||||
hb_enable_if (hb_is_convertible (const Base, const BaseType *))>
|
||||
friend const Type& operator + (const Base &base, const OffsetTo &offset) { return offset ((const void *) base); }
|
||||
template <typename Base,
|
||||
hb_enable_if (hb_is_convertible (const Base, const void *))>
|
||||
hb_enable_if (hb_is_convertible (const Base, const BaseType *))>
|
||||
friend const Type& operator + (const OffsetTo &offset, const Base &base) { return offset ((const void *) base); }
|
||||
template <typename Base,
|
||||
hb_enable_if (hb_is_convertible (Base, void *))>
|
||||
hb_enable_if (hb_is_convertible (Base, BaseType *))>
|
||||
friend Type& operator + (Base &&base, OffsetTo &offset) { return offset ((void *) base); }
|
||||
template <typename Base,
|
||||
hb_enable_if (hb_is_convertible (Base, void *))>
|
||||
hb_enable_if (hb_is_convertible (Base, BaseType *))>
|
||||
friend Type& operator + (OffsetTo &offset, Base &&base) { return offset ((void *) base); }
|
||||
|
||||
|
||||
template <typename ...Ts>
|
||||
template <typename Base, typename ...Ts>
|
||||
bool serialize_subset (hb_subset_context_t *c, const OffsetTo& src,
|
||||
const void *src_base, Ts&&... ds)
|
||||
const Base *src_base, Ts&&... ds)
|
||||
{
|
||||
*this = 0;
|
||||
if (src.is_null ())
|
||||
|
@ -414,7 +414,7 @@ struct OffsetTo : Offset<OffsetType, has_null>
|
|||
const void *src_base, unsigned dst_bias = 0)
|
||||
{ return serialize_copy (c, src, src_base, dst_bias, hb_serialize_context_t::Head); }
|
||||
|
||||
bool sanitize_shallow (hb_sanitize_context_t *c, const void *base) const
|
||||
bool sanitize_shallow (hb_sanitize_context_t *c, const BaseType *base) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
if (unlikely (!c->check_struct (this))) return_trace (false);
|
||||
|
@ -427,7 +427,7 @@ struct OffsetTo : Offset<OffsetType, has_null>
|
|||
#ifndef HB_OPTIMIZE_SIZE
|
||||
HB_ALWAYS_INLINE
|
||||
#endif
|
||||
bool sanitize (hb_sanitize_context_t *c, const void *base, Ts&&... ds) const
|
||||
bool sanitize (hb_sanitize_context_t *c, const BaseType *base, Ts&&... ds) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace (sanitize_shallow (c, base) &&
|
||||
|
@ -445,14 +445,14 @@ struct OffsetTo : Offset<OffsetType, has_null>
|
|||
DEFINE_SIZE_STATIC (sizeof (OffsetType));
|
||||
};
|
||||
/* Partial specializations. */
|
||||
template <typename Type, bool has_null=true> using Offset16To = OffsetTo<Type, HBUINT16, has_null>;
|
||||
template <typename Type, bool has_null=true> using Offset24To = OffsetTo<Type, HBUINT24, has_null>;
|
||||
template <typename Type, bool has_null=true> using Offset32To = OffsetTo<Type, HBUINT32, has_null>;
|
||||
template <typename Type, typename BaseType=void, bool has_null=true> using Offset16To = OffsetTo<Type, HBUINT16, BaseType, has_null>;
|
||||
template <typename Type, typename BaseType=void, bool has_null=true> using Offset24To = OffsetTo<Type, HBUINT24, BaseType, has_null>;
|
||||
template <typename Type, typename BaseType=void, bool has_null=true> using Offset32To = OffsetTo<Type, HBUINT32, BaseType, has_null>;
|
||||
|
||||
template <typename Type, typename OffsetType> using NNOffsetTo = OffsetTo<Type, OffsetType, false>;
|
||||
template <typename Type> using NNOffset16To = Offset16To<Type, false>;
|
||||
template <typename Type> using NNOffset24To = Offset24To<Type, false>;
|
||||
template <typename Type> using NNOffset32To = Offset32To<Type, false>;
|
||||
template <typename Type, typename OffsetType, typename BaseType=void> using NNOffsetTo = OffsetTo<Type, OffsetType, BaseType, false>;
|
||||
template <typename Type, typename BaseType=void> using NNOffset16To = Offset16To<Type, BaseType, false>;
|
||||
template <typename Type, typename BaseType=void> using NNOffset24To = Offset24To<Type, BaseType, false>;
|
||||
template <typename Type, typename BaseType=void> using NNOffset32To = Offset32To<Type, BaseType, false>;
|
||||
|
||||
|
||||
/*
|
||||
|
@ -555,17 +555,17 @@ struct UnsizedArrayOf
|
|||
};
|
||||
|
||||
/* Unsized array of offset's */
|
||||
template <typename Type, typename OffsetType, bool has_null=true>
|
||||
using UnsizedArray16OfOffsetTo = UnsizedArrayOf<OffsetTo<Type, OffsetType, has_null>>;
|
||||
template <typename Type, typename OffsetType, typename BaseType=void, bool has_null=true>
|
||||
using UnsizedArray16OfOffsetTo = UnsizedArrayOf<OffsetTo<Type, OffsetType, BaseType, has_null>>;
|
||||
|
||||
/* Unsized array of offsets relative to the beginning of the array itself. */
|
||||
template <typename Type, typename OffsetType, bool has_null=true>
|
||||
struct UnsizedListOfOffset16To : UnsizedArray16OfOffsetTo<Type, OffsetType, has_null>
|
||||
template <typename Type, typename OffsetType, typename BaseType=void, bool has_null=true>
|
||||
struct UnsizedListOfOffset16To : UnsizedArray16OfOffsetTo<Type, OffsetType, BaseType, has_null>
|
||||
{
|
||||
const Type& operator [] (int i_) const
|
||||
{
|
||||
unsigned int i = (unsigned int) i_;
|
||||
const OffsetTo<Type, OffsetType, has_null> *p = &this->arrayZ[i];
|
||||
const OffsetTo<Type, OffsetType, BaseType, has_null> *p = &this->arrayZ[i];
|
||||
if (unlikely ((const void *) p < (const void *) this->arrayZ)) return Null (Type); /* Overflowed. */
|
||||
_hb_compiler_memory_r_barrier ();
|
||||
return this+*p;
|
||||
|
@ -573,7 +573,7 @@ struct UnsizedListOfOffset16To : UnsizedArray16OfOffsetTo<Type, OffsetType, has_
|
|||
Type& operator [] (int i_)
|
||||
{
|
||||
unsigned int i = (unsigned int) i_;
|
||||
const OffsetTo<Type, OffsetType, has_null> *p = &this->arrayZ[i];
|
||||
const OffsetTo<Type, OffsetType, BaseType, has_null> *p = &this->arrayZ[i];
|
||||
if (unlikely ((const void *) p < (const void *) this->arrayZ)) return Crap (Type); /* Overflowed. */
|
||||
_hb_compiler_memory_r_barrier ();
|
||||
return this+*p;
|
||||
|
@ -583,7 +583,7 @@ struct UnsizedListOfOffset16To : UnsizedArray16OfOffsetTo<Type, OffsetType, has_
|
|||
bool sanitize (hb_sanitize_context_t *c, unsigned int count, Ts&&... ds) const
|
||||
{
|
||||
TRACE_SANITIZE (this);
|
||||
return_trace ((UnsizedArray16OfOffsetTo<Type, OffsetType, has_null>
|
||||
return_trace ((UnsizedArray16OfOffsetTo<Type, OffsetType, BaseType, has_null>
|
||||
::sanitize (c, count, this, std::forward<Ts> (ds)...)));
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue