[HarfBuzz] harfbuzz: Branch 'master' - 8 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Fri Nov 2 16:27:28 UTC 2018
src/hb-aat-layout-morx-table.hh | 4 +-
src/hb-aat-layout-trak-table.hh | 2 -
src/hb-dsalgs.hh | 26 +++++++++++-------
src/hb-open-file.hh | 2 -
src/hb-open-type.hh | 18 +++++-------
src/hb-ot-color-cpal-table.hh | 6 ++--
src/hb-ot-kern-table.hh | 56 ++++++++++++++++++++++++++++++++++++++++
src/hb-ot-layout-gsubgpos.hh | 22 +++++++++------
8 files changed, 100 insertions(+), 36 deletions(-)
New commits:
commit 0382b7184addf5b3723db40a57790e5e62ac1703
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Nov 2 12:23:26 2018 -0400
Use as_array in more places
diff --git a/src/hb-aat-layout-morx-table.hh b/src/hb-aat-layout-morx-table.hh
index d56af7bf..dab6ec1e 100644
--- a/src/hb-aat-layout-morx-table.hh
+++ b/src/hb-aat-layout-morx-table.hh
@@ -977,7 +977,7 @@ struct Chain
inline void apply (hb_aat_apply_context_t *c,
hb_mask_t flags) const
{
- const ChainSubtable<Types> *subtable = &StructAtOffset<ChainSubtable<Types> > (&featureZ, featureZ[0].static_size * featureCount);
+ const ChainSubtable<Types> *subtable = &StructAfter<ChainSubtable<Types> > (featureZ.as_array (featureCount));
unsigned int count = subtableCount;
for (unsigned int i = 0; i < count; i++)
{
@@ -1059,7 +1059,7 @@ struct Chain
if (!c->check_array (featureZ.arrayZ, featureCount))
return_trace (false);
- const ChainSubtable<Types> *subtable = &StructAtOffset<ChainSubtable<Types> > (&featureZ, featureZ[0].static_size * featureCount);
+ const ChainSubtable<Types> *subtable = &StructAfter<ChainSubtable<Types> > (featureZ.as_array (featureCount));
unsigned int count = subtableCount;
for (unsigned int i = 0; i < count; i++)
{
diff --git a/src/hb-ot-layout-gsubgpos.hh b/src/hb-ot-layout-gsubgpos.hh
index c4af4204..54ae429b 100644
--- a/src/hb-ot-layout-gsubgpos.hh
+++ b/src/hb-ot-layout-gsubgpos.hh
@@ -1308,7 +1308,8 @@ struct Rule
inline void closure (hb_closure_context_t *c, ContextClosureLookupContext &lookup_context) const
{
TRACE_CLOSURE (this);
- const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAtOffset<UnsizedArrayOf<LookupRecord> > (inputZ.arrayZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0));
+ const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord> >
+ (inputZ.as_array ((inputCount ? inputCount - 1 : 0)));
context_closure_lookup (c,
inputCount, inputZ.arrayZ,
lookupCount, lookupRecord.arrayZ,
@@ -1318,7 +1319,8 @@ struct Rule
inline void collect_glyphs (hb_collect_glyphs_context_t *c, ContextCollectGlyphsLookupContext &lookup_context) const
{
TRACE_COLLECT_GLYPHS (this);
- const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAtOffset<UnsizedArrayOf<LookupRecord> > (inputZ.arrayZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0));
+ const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord> >
+ (inputZ.as_array (inputCount ? inputCount - 1 : 0));
context_collect_glyphs_lookup (c,
inputCount, inputZ.arrayZ,
lookupCount, lookupRecord.arrayZ,
@@ -1328,14 +1330,16 @@ struct Rule
inline bool would_apply (hb_would_apply_context_t *c, ContextApplyLookupContext &lookup_context) const
{
TRACE_WOULD_APPLY (this);
- const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAtOffset<UnsizedArrayOf<LookupRecord> > (inputZ.arrayZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0));
+ const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord> >
+ (inputZ.as_array (inputCount ? inputCount - 1 : 0));
return_trace (context_would_apply_lookup (c, inputCount, inputZ.arrayZ, lookupCount, lookupRecord.arrayZ, lookup_context));
}
inline bool apply (hb_ot_apply_context_t *c, ContextApplyLookupContext &lookup_context) const
{
TRACE_APPLY (this);
- const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAtOffset<UnsizedArrayOf<LookupRecord> > (inputZ.arrayZ, inputZ[0].static_size * (inputCount ? inputCount - 1 : 0));
+ const UnsizedArrayOf<LookupRecord> &lookupRecord = StructAfter<UnsizedArrayOf<LookupRecord> >
+ (inputZ.as_array (inputCount ? inputCount - 1 : 0));
return_trace (context_apply_lookup (c, inputCount, inputZ.arrayZ, lookupCount, lookupRecord.arrayZ, lookup_context));
}
@@ -1686,7 +1690,7 @@ struct ContextFormat3
if (!(this+coverageZ[0]).intersects (c->glyphs))
return;
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ.arrayZ, coverageZ[0].static_size * glyphCount);
+ const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount));
struct ContextClosureLookupContext lookup_context = {
{intersects_coverage},
this
@@ -1702,7 +1706,7 @@ struct ContextFormat3
TRACE_COLLECT_GLYPHS (this);
(this+coverageZ[0]).add_coverage (c->input);
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ.arrayZ, coverageZ[0].static_size * glyphCount);
+ const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount));
struct ContextCollectGlyphsLookupContext lookup_context = {
{collect_coverage},
this
@@ -1718,7 +1722,7 @@ struct ContextFormat3
{
TRACE_WOULD_APPLY (this);
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ.arrayZ, coverageZ[0].static_size * glyphCount);
+ const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount));
struct ContextApplyLookupContext lookup_context = {
{match_coverage},
this
@@ -1735,7 +1739,7 @@ struct ContextFormat3
unsigned int index = (this+coverageZ[0]).get_coverage (c->buffer->cur().codepoint);
if (likely (index == NOT_COVERED)) return_trace (false);
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ.arrayZ, coverageZ[0].static_size * glyphCount);
+ const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount));
struct ContextApplyLookupContext lookup_context = {
{match_coverage},
this
@@ -1759,7 +1763,7 @@ struct ContextFormat3
if (!c->check_array (coverageZ.arrayZ, count)) return_trace (false);
for (unsigned int i = 0; i < count; i++)
if (!coverageZ[i].sanitize (c, this)) return_trace (false);
- const LookupRecord *lookupRecord = &StructAtOffset<LookupRecord> (coverageZ.arrayZ, coverageZ[0].static_size * count);
+ const LookupRecord *lookupRecord = &StructAfter<LookupRecord> (coverageZ.as_array (glyphCount));
return_trace (c->check_array (lookupRecord, lookupCount));
}
commit 91de9dfcf3bba7cbeef1e709679c8e24ab684c97
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Nov 2 12:14:21 2018 -0400
Fix &array_of<>
diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh
index c1b0a86a..f2bff063 100644
--- a/src/hb-dsalgs.hh
+++ b/src/hb-dsalgs.hh
@@ -556,6 +556,9 @@ struct hb_array_t
template <typename T> inline operator T * (void) { return arrayZ; }
template <typename T> inline operator const T * (void) const { return arrayZ; }
+ inline Type * operator & (void) { return arrayZ; }
+ inline const Type * operator & (void) const { return arrayZ; }
+
inline hb_array_t<Type> sub_array (unsigned int start_offset, unsigned int seg_count) const
{
unsigned int count = len;
diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh
index 7bce7ead..afd75be4 100644
--- a/src/hb-open-type.hh
+++ b/src/hb-open-type.hh
@@ -340,7 +340,7 @@ struct UnsizedArrayOf
inline const Type& operator [] (unsigned int i) const { return arrayZ[i]; }
inline Type& operator [] (unsigned int i) { return arrayZ[i]; }
- template <typename T> inline operator T * (void) { return arrayZ; }
+ template <typename T> inline operator T * (void) { return arrayZ; }
template <typename T> inline operator const T * (void) const { return arrayZ; }
inline unsigned int get_size (unsigned int len) const
@@ -452,7 +452,7 @@ struct ArrayOf
return arrayZ[i];
}
- template <typename T> inline operator T * (void) { return arrayZ; }
+ template <typename T> inline operator T * (void) { return arrayZ; }
template <typename T> inline operator const T * (void) const { return arrayZ; }
inline unsigned int get_size (void) const
commit 9b7cb137946013592c9a5a9f0a3464fb4613577b
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Nov 2 12:00:55 2018 -0400
Fixup
diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh
index 2249e128..c1b0a86a 100644
--- a/src/hb-dsalgs.hh
+++ b/src/hb-dsalgs.hh
@@ -551,7 +551,7 @@ struct hb_array_t
return arrayZ[i];
}
- inline unsigned int get_size (void) { return len * sizeof (Type); }
+ inline unsigned int get_size (void) const { return len * sizeof (Type); }
template <typename T> inline operator T * (void) { return arrayZ; }
template <typename T> inline operator const T * (void) const { return arrayZ; }
commit 6e06fe162ed79bb47f62aae03669cd72b99014a0
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Nov 2 11:56:55 2018 -0400
[kern] Implement Format3
Untested.
diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh
index 891f3eab..4f196789 100644
--- a/src/hb-ot-kern-table.hh
+++ b/src/hb-ot-kern-table.hh
@@ -239,6 +239,54 @@ struct KernSubTableFormat2
DEFINE_SIZE_MIN (8);
};
+struct KernSubTableFormat3
+{
+ inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, const char *end) const
+ {
+ hb_array_t<const FWORD> kernValue = kernValueZ.as_array (kernValueCount);
+ hb_array_t<const HBUINT8> leftClass = StructAfter<const UnsizedArrayOf<HBUINT8> > (kernValue).as_array (glyphCount);
+ hb_array_t<const HBUINT8> rightClass = StructAfter<const UnsizedArrayOf<HBUINT8> > (leftClass).as_array (glyphCount);
+ hb_array_t<const HBUINT8> kernIndex = StructAfter<const UnsizedArrayOf<HBUINT8> > (rightClass).as_array (leftClassCount * rightClassCount);
+
+ unsigned int i = leftClass[left] * rightClassCount + rightClass[right];
+ return kernValue[kernIndex[i]];
+ }
+
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (true); /* Disabled. See above. */
+ return_trace (c->check_struct (this) &&
+ c->check_range (kernValueZ,
+ kernValueCount +
+ glyphCount * 2 +
+ leftClassCount * rightClassCount));
+ }
+
+ protected:
+ HBUINT16 glyphCount; /* The number of glyphs in this font. */
+ HBUINT8 kernValueCount; /* The number of kerning values. */
+ HBUINT8 leftClassCount; /* The number of left-hand classes. */
+ HBUINT8 rightClassCount;/* The number of right-hand classes. */
+ HBUINT8 flags; /* Set to zero (reserved for future use). */
+ UnsizedArrayOf<FWORD>
+ kernValueZ; /* The kerning values.
+ * Length kernValueCount. */
+#if 0
+ UnsizedArrayOf<HBUINT8>
+ leftClass; /* The left-hand classes.
+ * Length glyphCount. */
+ UnsizedArrayOf<HBUINT8>
+ RightClass; /* The right-hand classes.
+ * Length glyphCount. */
+ UnsizedArrayOf<HBUINT8>
+ kernIndex; /* The indices into the kernValue array.
+ * Length leftClassCount * rightClassCount */
+#endif
+ public:
+ DEFINE_SIZE_ARRAY (6, kernValueZ);
+};
+
struct KernSubTable
{
inline int get_kerning (hb_codepoint_t left, hb_codepoint_t right, const char *end, unsigned int format) const
@@ -246,6 +294,7 @@ struct KernSubTable
switch (format) {
case 0: return u.format0.get_kerning (left, right);
case 2: return u.format2.get_kerning (left, right, end);
+ case 3: return u.format3.get_kerning (left, right, end);
default:return 0;
}
}
@@ -256,6 +305,7 @@ struct KernSubTable
switch (format) {
case 0: return_trace (u.format0.sanitize (c));
case 2: return_trace (u.format2.sanitize (c));
+ case 3: return_trace (u.format3.sanitize (c));
default:return_trace (true);
}
}
@@ -264,6 +314,7 @@ struct KernSubTable
union {
KernSubTableFormat0 format0;
KernSubTableFormat2 format2;
+ KernSubTableFormat3 format3;
} u;
public:
DEFINE_SIZE_MIN (0);
commit c6ef5dbd5c40cc8934756456221e080012a82530
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Nov 2 11:51:21 2018 -0400
Add cast operators to hb_array_t
diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh
index 0940dc53..2249e128 100644
--- a/src/hb-dsalgs.hh
+++ b/src/hb-dsalgs.hh
@@ -539,19 +539,24 @@ struct hb_bytes_t
unsigned int len;
};
-template <typename T>
+template <typename Type>
struct hb_array_t
{
inline hb_array_t (void) : arrayZ (nullptr), len (0) {}
- inline hb_array_t (T *array_, unsigned int len_) : arrayZ (array_), len (len_) {}
+ inline hb_array_t (Type *array_, unsigned int len_) : arrayZ (array_), len (len_) {}
- inline T& operator [] (unsigned int i) const
+ inline Type& operator [] (unsigned int i) const
{
- if (unlikely (i >= len)) return Null(T);
+ if (unlikely (i >= len)) return Null(Type);
return arrayZ[i];
}
- inline hb_array_t<T> sub_array (unsigned int start_offset, unsigned int seg_count) const
+ inline unsigned int get_size (void) { return len * sizeof (Type); }
+
+ template <typename T> inline operator T * (void) { return arrayZ; }
+ template <typename T> inline operator const T * (void) const { return arrayZ; }
+
+ inline hb_array_t<Type> sub_array (unsigned int start_offset, unsigned int seg_count) const
{
unsigned int count = len;
if (unlikely (start_offset > count))
@@ -559,17 +564,17 @@ struct hb_array_t
else
count -= start_offset;
count = MIN (count, seg_count);
- return hb_array_t<T> (arrayZ + start_offset, count);
+ return hb_array_t<Type> (arrayZ + start_offset, count);
}
inline hb_bytes_t as_bytes (void) const
{
- return hb_bytes_t (arrayZ, len * sizeof (T));
+ return hb_bytes_t (arrayZ, len * sizeof (Type));
}
inline void free (void) { ::free ((void *) arrayZ); arrayZ = nullptr; len = 0; }
- T *arrayZ;
+ Type *arrayZ;
unsigned int len;
};
commit 72462eb76584a2892f1d961c90fd289240ea9380
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Nov 2 11:46:24 2018 -0400
Add UnsizedArrayOf::as_array() instead of hb_array() template
diff --git a/src/hb-aat-layout-trak-table.hh b/src/hb-aat-layout-trak-table.hh
index de2071ad..c579c119 100644
--- a/src/hb-aat-layout-trak-table.hh
+++ b/src/hb-aat-layout-trak-table.hh
@@ -55,7 +55,7 @@ struct TrackTableEntry
unsigned int index,
unsigned int nSizes) const
{
- return hb_array (base+valuesZ, nSizes)[index];
+ return (base+valuesZ).as_array (nSizes)[index];
}
public:
diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh
index 59df860d..0940dc53 100644
--- a/src/hb-dsalgs.hh
+++ b/src/hb-dsalgs.hh
@@ -572,8 +572,6 @@ struct hb_array_t
T *arrayZ;
unsigned int len;
};
-template <typename T> static inline
-hb_array_t<T> hb_array (T *array, unsigned int len) { return hb_array_t<T> (array, len); }
struct HbOpOr
diff --git a/src/hb-open-file.hh b/src/hb-open-file.hh
index 80dc5e61..2ef6d775 100644
--- a/src/hb-open-file.hh
+++ b/src/hb-open-file.hh
@@ -330,7 +330,7 @@ struct ResourceTypeRecord
inline const ResourceRecord& get_resource_record (unsigned int i,
const void *type_base) const
{
- return hb_array (type_base+resourcesZ, get_resource_count ())[i];
+ return (type_base+resourcesZ).as_array (get_resource_count ())[i];
}
inline bool sanitize (hb_sanitize_context_t *c,
diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh
index 06257603..7bce7ead 100644
--- a/src/hb-open-type.hh
+++ b/src/hb-open-type.hh
@@ -346,6 +346,9 @@ struct UnsizedArrayOf
inline unsigned int get_size (unsigned int len) const
{ return len * Type::static_size; }
+ inline hb_array_t<Type> as_array (unsigned int len) { return hb_array_t<Type> (arrayZ, len); }
+ inline hb_array_t<const Type> as_array (unsigned int len) const { return hb_array_t<const Type> (arrayZ, len); }
+
inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const
{
TRACE_SANITIZE (this);
@@ -393,14 +396,6 @@ struct UnsizedArrayOf
public:
DEFINE_SIZE_ARRAY (0, arrayZ);
};
-} /* namespace OT */
-template <typename T> static inline
-hb_array_t<T> hb_array (OT::UnsizedArrayOf<T> &array, unsigned int len)
-{ return hb_array (array.arrayZ, len); }
-template <typename T> static inline
-hb_array_t<const T> hb_array (const OT::UnsizedArrayOf<T> &array, unsigned int len)
-{ return hb_array (array.arrayZ, len); }
-namespace OT {
/* Unsized array of offset's */
template <typename Type, typename OffsetType, bool has_null=true>
diff --git a/src/hb-ot-color-cpal-table.hh b/src/hb-ot-color-cpal-table.hh
index df4d9b4e..332f0dd7 100644
--- a/src/hb-ot-color-cpal-table.hh
+++ b/src/hb-ot-color-cpal-table.hh
@@ -55,7 +55,7 @@ struct CPALV1Tail
{
if (!paletteFlagsZ) return HB_OT_COLOR_PALETTE_FLAG_DEFAULT;
return (hb_ot_color_palette_flags_t) (uint32_t)
- hb_array (base+paletteFlagsZ, palette_count)[palette_index];
+ (base+paletteFlagsZ).as_array (palette_count)[palette_index];
}
inline hb_ot_name_id_t
@@ -64,7 +64,7 @@ struct CPALV1Tail
unsigned int palette_count) const
{
if (!paletteLabelsZ) return HB_OT_NAME_ID_INVALID;
- return hb_array (base+paletteLabelsZ, palette_count)[palette_index];
+ return (base+paletteLabelsZ).as_array (palette_count)[palette_index];
}
inline hb_ot_name_id_t
@@ -73,7 +73,7 @@ struct CPALV1Tail
unsigned int color_count) const
{
if (!colorLabelsZ) return HB_OT_NAME_ID_INVALID;
- return hb_array (base+colorLabelsZ, color_count)[color_index];
+ return (base+colorLabelsZ).as_array (color_count)[color_index];
}
public:
commit 1cf075ecb674cc0c7043bffe2fef5ef187c15335
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Nov 2 11:38:00 2018 -0400
Add get_size to UnsizedArrayOf
diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh
index 00bd134d..06257603 100644
--- a/src/hb-open-type.hh
+++ b/src/hb-open-type.hh
@@ -343,6 +343,9 @@ struct UnsizedArrayOf
template <typename T> inline operator T * (void) { return arrayZ; }
template <typename T> inline operator const T * (void) const { return arrayZ; }
+ inline unsigned int get_size (unsigned int len) const
+ { return len * Type::static_size; }
+
inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const
{
TRACE_SANITIZE (this);
commit a4a7a623893fd4c8db3a987d81a1c80243006f1e
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Fri Nov 2 11:16:43 2018 -0400
[kern] Add buffer message
diff --git a/src/hb-ot-kern-table.hh b/src/hb-ot-kern-table.hh
index 63551d31..891f3eab 100644
--- a/src/hb-ot-kern-table.hh
+++ b/src/hb-ot-kern-table.hh
@@ -483,7 +483,12 @@ struct kern
hb_kern_machine_t<accelerator_t> machine (*this);
+ if (!buffer->message (font, "start kern table"))
+ return;
+
machine.kern (font, buffer, kern_mask);
+
+ (void) buffer->message (font, "end kern table");
}
private:
More information about the HarfBuzz
mailing list