[HarfBuzz] harfbuzz: Branch 'master' - 7 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Mon Oct 22 23:24:28 UTC 2018
src/dump-emoji.cc | 24 ++----
src/hb-aat-layout-trak-table.hh | 6 -
src/hb-dsalgs.hh | 6 -
src/hb-open-file.hh | 4 -
src/hb-open-type.hh | 3
src/hb-ot-color-cpal-table.hh | 147 +++++++++++++++++++---------------------
src/hb-ot-color.cc | 7 +
src/hb-static.cc | 1
8 files changed, 99 insertions(+), 99 deletions(-)
New commits:
commit d7865107ea4664e04c03a1d79678cdcadc0d5ea5
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Oct 22 16:18:34 2018 -0700
Remove const from hb_array_t details
Will come in through <T> if desired.
diff --git a/src/hb-aat-layout-trak-table.hh b/src/hb-aat-layout-trak-table.hh
index 16729d16..c2c50bbb 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_t<FWORD> ((base+valuesZ).arrayZ, nSizes)[index];
+ return hb_array_t<const FWORD> ((base+valuesZ).arrayZ, nSizes)[index];
}
public:
@@ -88,7 +88,7 @@ struct TrackData
const void *base) const
{
unsigned int sizes = nSizes;
- hb_array_t<Fixed> size_table ((base+sizeTable).arrayZ, sizes);
+ hb_array_t<const Fixed> size_table ((base+sizeTable).arrayZ, sizes);
float s0 = size_table[idx].to_float ();
float s1 = size_table[idx + 1].to_float ();
@@ -134,7 +134,7 @@ struct TrackData
if (sizes == 1) return trackTableEntry->get_value (base, 0, sizes);
/* TODO bfind() */
- hb_array_t<Fixed> size_table ((base+sizeTable).arrayZ, sizes);
+ hb_array_t<const Fixed> size_table ((base+sizeTable).arrayZ, sizes);
unsigned int size_index;
for (size_index = 0; size_index < sizes - 1; size_index++)
if (size_table[size_index].to_float () >= csspx)
diff --git a/src/hb-dsalgs.hh b/src/hb-dsalgs.hh
index 7e1b7eb1..27c1a96e 100644
--- a/src/hb-dsalgs.hh
+++ b/src/hb-dsalgs.hh
@@ -513,9 +513,9 @@ template <typename T>
struct hb_array_t
{
inline hb_array_t (void) : arrayZ (nullptr), len (0) {}
- inline hb_array_t (const T *array_, unsigned int len_) : arrayZ (array_), len (len_) {}
+ inline hb_array_t (T *array_, unsigned int len_) : arrayZ (array_), len (len_) {}
- inline const T& operator [] (unsigned int i) const
+ inline T& operator [] (unsigned int i) const
{
if (unlikely (i >= len)) return Null(T);
return arrayZ[i];
@@ -534,7 +534,7 @@ struct hb_array_t
inline void free (void) { ::free ((void *) arrayZ); arrayZ = nullptr; len = 0; }
- const T *arrayZ;
+ T *arrayZ;
unsigned int len;
};
diff --git a/src/hb-open-file.hh b/src/hb-open-file.hh
index 817791ab..a973455d 100644
--- a/src/hb-open-file.hh
+++ b/src/hb-open-file.hh
@@ -330,8 +330,8 @@ struct ResourceTypeRecord
inline const ResourceRecord& get_resource_record (unsigned int i,
const void *type_base) const
{
- return hb_array_t<ResourceRecord> ((type_base+resourcesZ).arrayZ,
- get_resource_count ()) [i];
+ return hb_array_t<const ResourceRecord> ((type_base+resourcesZ).arrayZ,
+ get_resource_count ()) [i];
}
inline bool sanitize (hb_sanitize_context_t *c,
commit f3336580dd0c6959a1871f92b4a37f7c0a4b2160
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Oct 22 16:16:21 2018 -0700
[color] Use hb_array_t in CPAL
Doesn't work though, ouch :(. Need to figure out if it's unreasonable
to expect Null(T) inside hb_array_t<T> to see the later specialization
of Null for NameID.
diff --git a/src/hb-open-type.hh b/src/hb-open-type.hh
index be0d8b01..dc2f1f7c 100644
--- a/src/hb-open-type.hh
+++ b/src/hb-open-type.hh
@@ -150,7 +150,8 @@ struct Tag : HBUINT32
typedef HBUINT16 GlyphID;
/* Name-table index, same as uint16 (length = 16 bits) */
-typedef HBUINT16 NameID;
+struct NameID : HBUINT16 {};
+DECLARE_NULL_NAMESPACE_BYTES (OT, NameID);
/* Script/language-system/feature index */
struct Index : HBUINT16 {
diff --git a/src/hb-ot-color-cpal-table.hh b/src/hb-ot-color-cpal-table.hh
index beef2fce..205613e4 100644
--- a/src/hb-ot-color-cpal-table.hh
+++ b/src/hb-ot-color-cpal-table.hh
@@ -53,10 +53,9 @@ struct CPALV1Tail
unsigned int palette_index,
unsigned int palette_count) const
{
- if (unlikely (palette_index >= palette_count || !paletteFlagsZ))
- return HB_OT_COLOR_PALETTE_FLAG_DEFAULT;
-
- return (hb_ot_color_palette_flags_t) (uint32_t) (base+paletteFlagsZ)[palette_index];
+ if (!paletteFlagsZ) return HB_OT_COLOR_PALETTE_FLAG_DEFAULT;
+ return (hb_ot_color_palette_flags_t) (uint32_t)
+ hb_array_t<const HBUINT32> ((base+paletteFlagsZ).arrayZ, palette_count)[palette_index];
}
inline unsigned int
@@ -64,10 +63,10 @@ struct CPALV1Tail
unsigned int palette_index,
unsigned int palette_count) const
{
- if (unlikely (palette_index >= palette_count || !paletteLabelZ))
- return HB_NAME_ID_INVALID;
-
- return (base+paletteLabelZ)[palette_index];
+ /* XXX the Null(NameID) returned by hb_array_t is wrong. Figure out why
+ * and remove the explicit bound check. */
+ if (!paletteLabelsZ || palette_index >= palette_count) return HB_NAME_ID_INVALID;
+ return hb_array_t<const NameID> ((base+paletteLabelsZ).arrayZ, palette_count)[palette_index];
}
inline unsigned int
@@ -75,21 +74,23 @@ struct CPALV1Tail
unsigned int color_index,
unsigned int color_count) const
{
- if (unlikely (color_index >= color_count || !paletteEntryLabelZ))
- return HB_NAME_ID_INVALID;
-
- return (base+paletteEntryLabelZ)[color_index];
+ /* XXX the Null(NameID) returned by hb_array_t is wrong. Figure out why
+ * and remove the explicit bound check. */
+ if (!colorLabelsZ || color_index >= color_count) return HB_NAME_ID_INVALID;
+ return hb_array_t<const NameID> ((base+colorLabelsZ).arrayZ, color_count)[color_index];
}
public:
- inline bool sanitize (hb_sanitize_context_t *c, const void *base,
- unsigned int palette_count, unsigned int color_count) const
+ inline bool sanitize (hb_sanitize_context_t *c,
+ const void *base,
+ unsigned int palette_count,
+ unsigned int color_count) const
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
- (!paletteFlagsZ || (base+paletteFlagsZ).sanitize (c, palette_count)) &&
- (!paletteLabelZ || (base+paletteLabelZ).sanitize (c, palette_count)) &&
- (!paletteEntryLabelZ || (base+paletteEntryLabelZ).sanitize (c, color_count)));
+ (!paletteFlagsZ || (base+paletteFlagsZ).sanitize (c, palette_count)) &&
+ (!paletteLabelsZ || (base+paletteLabelsZ).sanitize (c, palette_count)) &&
+ (!colorLabelsZ || (base+colorLabelsZ).sanitize (c, color_count)));
}
protected:
@@ -97,13 +98,13 @@ struct CPALV1Tail
paletteFlagsZ; /* Offset from the beginning of CPAL table to
* the Palette Type Array. Set to 0 if no array
* is provided. */
- LOffsetTo<UnsizedArrayOf<HBUINT16>, false>
- paletteLabelZ; /* Offset from the beginning of CPAL table to
- * the Palette Labels Array. Set to 0 if no
+ LOffsetTo<UnsizedArrayOf<NameID>, false>
+ paletteLabelsZ; /* Offset from the beginning of CPAL table to
+ * the palette labels array. Set to 0 if no
* array is provided. */
- LOffsetTo<UnsizedArrayOf<HBUINT16>, false>
- paletteEntryLabelZ; /* Offset from the beginning of CPAL table to
- * the Palette Entry Label Array. Set to 0
+ LOffsetTo<UnsizedArrayOf<NameID>, false>
+ colorLabelsZ; /* Offset from the beginning of CPAL table to
+ * the color labels array. Set to 0
* if no array is provided. */
public:
DEFINE_SIZE_STATIC (12);
diff --git a/src/hb-static.cc b/src/hb-static.cc
index e5507960..53889a5a 100644
--- a/src/hb-static.cc
+++ b/src/hb-static.cc
@@ -40,6 +40,7 @@
hb_vector_size_impl_t const _hb_NullPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)] = {};
/*thread_local*/ hb_vector_size_impl_t _hb_CrapPool[(HB_NULL_POOL_SIZE + sizeof (hb_vector_size_impl_t) - 1) / sizeof (hb_vector_size_impl_t)] = {};
+DEFINE_NULL_NAMESPACE_BYTES (OT, NameID) = {0xFF,0xFF};
DEFINE_NULL_NAMESPACE_BYTES (OT, Index) = {0xFF,0xFF};
DEFINE_NULL_NAMESPACE_BYTES (OT, LangSys) = {0x00,0x00, 0xFF,0xFF, 0x00,0x00};
DEFINE_NULL_NAMESPACE_BYTES (OT, RangeRecord) = {0x00,0x01, 0x00,0x00, 0x00, 0x00};
commit 5ae18855d115577ff796158d483db7b890d9956f
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Oct 22 14:54:55 2018 -0700
[color] Check for null CPAL arrays
We cannot use a nullable offset here though.
diff --git a/src/hb-ot-color-cpal-table.hh b/src/hb-ot-color-cpal-table.hh
index abb79ce9..beef2fce 100644
--- a/src/hb-ot-color-cpal-table.hh
+++ b/src/hb-ot-color-cpal-table.hh
@@ -53,7 +53,7 @@ struct CPALV1Tail
unsigned int palette_index,
unsigned int palette_count) const
{
- if (unlikely (palette_index >= palette_count))
+ if (unlikely (palette_index >= palette_count || !paletteFlagsZ))
return HB_OT_COLOR_PALETTE_FLAG_DEFAULT;
return (hb_ot_color_palette_flags_t) (uint32_t) (base+paletteFlagsZ)[palette_index];
@@ -64,7 +64,7 @@ struct CPALV1Tail
unsigned int palette_index,
unsigned int palette_count) const
{
- if (unlikely (palette_index >= palette_count))
+ if (unlikely (palette_index >= palette_count || !paletteLabelZ))
return HB_NAME_ID_INVALID;
return (base+paletteLabelZ)[palette_index];
@@ -75,7 +75,7 @@ struct CPALV1Tail
unsigned int color_index,
unsigned int color_count) const
{
- if (unlikely (color_index >= color_count))
+ if (unlikely (color_index >= color_count || !paletteEntryLabelZ))
return HB_NAME_ID_INVALID;
return (base+paletteEntryLabelZ)[color_index];
@@ -87,9 +87,9 @@ struct CPALV1Tail
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
- (base+paletteFlagsZ).sanitize (c, palette_count) &&
- (base+paletteLabelZ).sanitize (c, palette_count) &&
- (base+paletteEntryLabelZ).sanitize (c, color_count));
+ (!paletteFlagsZ || (base+paletteFlagsZ).sanitize (c, palette_count)) &&
+ (!paletteLabelZ || (base+paletteLabelZ).sanitize (c, palette_count)) &&
+ (!paletteEntryLabelZ || (base+paletteEntryLabelZ).sanitize (c, color_count)));
}
protected:
commit 69ab72e4aa7cbf197873d38f7e623866b4e40502
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Oct 22 14:51:40 2018 -0700
[color] More CPAL rename
diff --git a/src/hb-ot-color-cpal-table.hh b/src/hb-ot-color-cpal-table.hh
index 5d23ee8d..abb79ce9 100644
--- a/src/hb-ot-color-cpal-table.hh
+++ b/src/hb-ot-color-cpal-table.hh
@@ -47,46 +47,49 @@ struct CPALV1Tail
{
friend struct CPAL;
- inline bool
- sanitize (hb_sanitize_context_t *c, const void *base,
- unsigned int palette_count, unsigned int color_count) const
- {
- TRACE_SANITIZE (this);
- return_trace (c->check_struct (this) &&
- (base+paletteFlagsZ).sanitize (c, palette_count) &&
- (base+paletteLabelZ).sanitize (c, palette_count) &&
- (base+paletteEntryLabelZ).sanitize (c, color_count));
- }
-
private:
inline hb_ot_color_palette_flags_t
- get_palette_flags (const void *base, unsigned int palette_index,
- unsigned int palettes_count) const
+ get_palette_flags (const void *base,
+ unsigned int palette_index,
+ unsigned int palette_count) const
{
- if (unlikely (palette_index >= palettes_count))
+ if (unlikely (palette_index >= palette_count))
return HB_OT_COLOR_PALETTE_FLAG_DEFAULT;
return (hb_ot_color_palette_flags_t) (uint32_t) (base+paletteFlagsZ)[palette_index];
}
inline unsigned int
- get_palette_name_id (const void *base, unsigned int palette_index,
- unsigned int palettes_count) const
+ get_palette_name_id (const void *base,
+ unsigned int palette_index,
+ unsigned int palette_count) const
{
- if (unlikely (palette_index >= palettes_count))
+ if (unlikely (palette_index >= palette_count))
return HB_NAME_ID_INVALID;
return (base+paletteLabelZ)[palette_index];
}
inline unsigned int
- get_palette_entry_name_id (const void *base, unsigned int palette_entry,
- unsigned int palettes_entries_count) const
+ get_color_name_id (const void *base,
+ unsigned int color_index,
+ unsigned int color_count) const
{
- if (unlikely (palette_entry >= palettes_entries_count))
+ if (unlikely (color_index >= color_count))
return HB_NAME_ID_INVALID;
- return (base+paletteEntryLabelZ)[palette_entry];
+ return (base+paletteEntryLabelZ)[color_index];
+ }
+
+ public:
+ inline bool sanitize (hb_sanitize_context_t *c, const void *base,
+ unsigned int palette_count, unsigned int color_count) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) &&
+ (base+paletteFlagsZ).sanitize (c, palette_count) &&
+ (base+paletteLabelZ).sanitize (c, palette_count) &&
+ (base+paletteEntryLabelZ).sanitize (c, color_count));
}
protected:
@@ -114,31 +117,11 @@ struct CPAL
inline bool has_data (void) const { return numPalettes; }
- inline bool sanitize (hb_sanitize_context_t *c) const
- {
- TRACE_SANITIZE (this);
- if (unlikely (!(c->check_struct (this) && /* it checks colorRecordIndices also
- * See #get_size */
- (this+colorRecordsZ).sanitize (c, numColorRecords))))
- return_trace (false);
-
- /* Check for indices sanity so no need for doing it runtime */
- for (unsigned int i = 0; i < numPalettes; ++i)
- if (unlikely (colorRecordIndicesZ[i] + numColors > numColorRecords))
- return_trace (false);
-
- /* If version is zero, we are done here; otherwise we need to check tail also */
- if (version == 0)
- return_trace (true);
-
- const CPALV1Tail &v1 = StructAfter<CPALV1Tail> (*this);
- return_trace (likely (v1.sanitize (c, this, numPalettes, numColors)));
- }
-
inline unsigned int get_size (void) const
- {
- return min_size + numPalettes * sizeof (HBUINT16);
- }
+ { return min_size + numPalettes * sizeof (colorRecordIndicesZ[0]); }
+
+ inline unsigned int get_palette_count () const { return numPalettes; }
+ inline unsigned int get_color_count () const { return numColors; }
inline hb_ot_color_palette_flags_t get_palette_flags (unsigned int palette_index) const
{
@@ -158,21 +141,15 @@ struct CPAL
return cpal1.get_palette_name_id (this, palette_index, numPalettes);
}
- inline unsigned int get_palette_entry_name_id (unsigned int palette_entry) const
+ inline unsigned int get_color_name_id (unsigned int color_index) const
{
if (unlikely (version == 0))
return HB_NAME_ID_INVALID;
const CPALV1Tail& cpal1 = StructAfter<CPALV1Tail> (*this);
- return cpal1.get_palette_entry_name_id (this, palette_entry, numColors);
+ return cpal1.get_color_name_id (this, color_index, numColors);
}
- inline unsigned int get_palette_count () const
- { return numPalettes; }
-
- inline unsigned int get_palette_entries_count () const
- { return numColors; }
-
bool
get_color_record_argb (unsigned int color_index, unsigned int palette_index, hb_color_t* color) const
{
@@ -186,6 +163,27 @@ struct CPAL
return true;
}
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ if (unlikely (!(c->check_struct (this) && /* it checks colorRecordIndices also
+ * See #get_size */
+ (this+colorRecordsZ).sanitize (c, numColorRecords))))
+ return_trace (false);
+
+ /* Check for indices sanity so no need for doing it runtime */
+ for (unsigned int i = 0; i < numPalettes; ++i)
+ if (unlikely (colorRecordIndicesZ[i] + numColors > numColorRecords))
+ return_trace (false);
+
+ /* If version is zero, we are done here; otherwise we need to check tail also */
+ if (version == 0)
+ return_trace (true);
+
+ const CPALV1Tail &v1 = StructAfter<CPALV1Tail> (*this);
+ return_trace (likely (v1.sanitize (c, this, numPalettes, numColors)));
+ }
+
protected:
HBUINT16 version; /* Table version number */
/* Version 0 */
diff --git a/src/hb-ot-color.cc b/src/hb-ot-color.cc
index e4052392..3ca8751a 100644
--- a/src/hb-ot-color.cc
+++ b/src/hb-ot-color.cc
@@ -145,7 +145,7 @@ hb_name_id_t
hb_ot_color_palette_color_get_name_id (hb_face_t *face,
unsigned int color_index)
{
- return _get_cpal (face).get_palette_entry_name_id (color_index);
+ return _get_cpal (face).get_color_name_id (color_index);
}
/**
@@ -208,7 +208,7 @@ hb_ot_color_palette_get_colors (hb_face_t *face,
{
unsigned int platte_count;
platte_count = MIN<unsigned int>(*colors_count,
- cpal.get_palette_entries_count () - start_offset);
+ cpal.get_color_count () - start_offset);
for (unsigned int i = 0; i < platte_count; i++)
{
if (cpal.get_color_record_argb(start_offset + i, palette_index, &colors[num_results]))
@@ -217,7 +217,7 @@ hb_ot_color_palette_get_colors (hb_face_t *face,
}
if (likely (colors_count)) *colors_count = num_results;
- return cpal.get_palette_entries_count ();
+ return cpal.get_color_count ();
}
commit 0befb06c468aa36f3337b5ef2235f6d69dda8397
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Oct 22 14:46:21 2018 -0700
[color] More CPAL rename
diff --git a/src/hb-ot-color-cpal-table.hh b/src/hb-ot-color-cpal-table.hh
index 6035650f..5d23ee8d 100644
--- a/src/hb-ot-color-cpal-table.hh
+++ b/src/hb-ot-color-cpal-table.hh
@@ -49,13 +49,13 @@ struct CPALV1Tail
inline bool
sanitize (hb_sanitize_context_t *c, const void *base,
- unsigned int palette_count, unsigned int paletteEntries) const
+ unsigned int palette_count, unsigned int color_count) const
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
(base+paletteFlagsZ).sanitize (c, palette_count) &&
(base+paletteLabelZ).sanitize (c, palette_count) &&
- (base+paletteEntryLabelZ).sanitize (c, paletteEntries));
+ (base+paletteEntryLabelZ).sanitize (c, color_count));
}
private:
@@ -124,7 +124,7 @@ struct CPAL
/* Check for indices sanity so no need for doing it runtime */
for (unsigned int i = 0; i < numPalettes; ++i)
- if (unlikely (colorRecordIndicesZ[i] + numPaletteEntries > numColorRecords))
+ if (unlikely (colorRecordIndicesZ[i] + numColors > numColorRecords))
return_trace (false);
/* If version is zero, we are done here; otherwise we need to check tail also */
@@ -132,7 +132,7 @@ struct CPAL
return_trace (true);
const CPALV1Tail &v1 = StructAfter<CPALV1Tail> (*this);
- return_trace (likely (v1.sanitize (c, this, numPalettes, numPaletteEntries)));
+ return_trace (likely (v1.sanitize (c, this, numPalettes, numColors)));
}
inline unsigned int get_size (void) const
@@ -164,19 +164,19 @@ struct CPAL
return HB_NAME_ID_INVALID;
const CPALV1Tail& cpal1 = StructAfter<CPALV1Tail> (*this);
- return cpal1.get_palette_entry_name_id (this, palette_entry, numPaletteEntries);
+ return cpal1.get_palette_entry_name_id (this, palette_entry, numColors);
}
inline unsigned int get_palette_count () const
{ return numPalettes; }
inline unsigned int get_palette_entries_count () const
- { return numPaletteEntries; }
+ { return numColors; }
bool
get_color_record_argb (unsigned int color_index, unsigned int palette_index, hb_color_t* color) const
{
- if (unlikely (color_index >= numPaletteEntries || palette_index >= numPalettes))
+ if (unlikely (color_index >= numColors || palette_index >= numPalettes))
return false;
/* No need for more range check as it is already done on #sanitize */
@@ -189,7 +189,7 @@ struct CPAL
protected:
HBUINT16 version; /* Table version number */
/* Version 0 */
- HBUINT16 numPaletteEntries; /* Number of palette entries in each palette. */
+ HBUINT16 numColors; /* Number of colors in each palette. */
HBUINT16 numPalettes; /* Number of palettes in the table. */
HBUINT16 numColorRecords; /* Total number of color records, combined for
* all palettes. */
commit 3600d206037ef23d6448c79a3f010c4f903a971c
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Mon Oct 22 14:43:12 2018 -0700
[color] Rename vars in CPAL
diff --git a/src/hb-ot-color-cpal-table.hh b/src/hb-ot-color-cpal-table.hh
index 94c5a3c3..6035650f 100644
--- a/src/hb-ot-color-cpal-table.hh
+++ b/src/hb-ot-color-cpal-table.hh
@@ -49,34 +49,34 @@ struct CPALV1Tail
inline bool
sanitize (hb_sanitize_context_t *c, const void *base,
- unsigned int palettes, unsigned int paletteEntries) const
+ unsigned int palette_count, unsigned int paletteEntries) const
{
TRACE_SANITIZE (this);
return_trace (c->check_struct (this) &&
- (base+paletteFlagsZ).sanitize (c, palettes) &&
- (base+paletteLabelZ).sanitize (c, palettes) &&
+ (base+paletteFlagsZ).sanitize (c, palette_count) &&
+ (base+paletteLabelZ).sanitize (c, palette_count) &&
(base+paletteEntryLabelZ).sanitize (c, paletteEntries));
}
private:
inline hb_ot_color_palette_flags_t
- get_palette_flags (const void *base, unsigned int palette,
+ get_palette_flags (const void *base, unsigned int palette_index,
unsigned int palettes_count) const
{
- if (unlikely (palette >= palettes_count))
+ if (unlikely (palette_index >= palettes_count))
return HB_OT_COLOR_PALETTE_FLAG_DEFAULT;
- return (hb_ot_color_palette_flags_t) (uint32_t) (base+paletteFlagsZ)[palette];
+ return (hb_ot_color_palette_flags_t) (uint32_t) (base+paletteFlagsZ)[palette_index];
}
inline unsigned int
- get_palette_name_id (const void *base, unsigned int palette,
+ get_palette_name_id (const void *base, unsigned int palette_index,
unsigned int palettes_count) const
{
- if (unlikely (palette >= palettes_count))
+ if (unlikely (palette_index >= palettes_count))
return HB_NAME_ID_INVALID;
- return (base+paletteLabelZ)[palette];
+ return (base+paletteLabelZ)[palette_index];
}
inline unsigned int
@@ -140,22 +140,22 @@ struct CPAL
return min_size + numPalettes * sizeof (HBUINT16);
}
- inline hb_ot_color_palette_flags_t get_palette_flags (unsigned int palette) const
+ inline hb_ot_color_palette_flags_t get_palette_flags (unsigned int palette_index) const
{
if (unlikely (version == 0))
return HB_OT_COLOR_PALETTE_FLAG_DEFAULT;
const CPALV1Tail& cpal1 = StructAfter<CPALV1Tail> (*this);
- return cpal1.get_palette_flags (this, palette, numPalettes);
+ return cpal1.get_palette_flags (this, palette_index, numPalettes);
}
- inline unsigned int get_palette_name_id (unsigned int palette) const
+ inline unsigned int get_palette_name_id (unsigned int palette_index) const
{
if (unlikely (version == 0))
return HB_NAME_ID_INVALID;
const CPALV1Tail& cpal1 = StructAfter<CPALV1Tail> (*this);
- return cpal1.get_palette_name_id (this, palette, numPalettes);
+ return cpal1.get_palette_name_id (this, palette_index, numPalettes);
}
inline unsigned int get_palette_entry_name_id (unsigned int palette_entry) const
@@ -174,15 +174,15 @@ struct CPAL
{ return numPaletteEntries; }
bool
- get_color_record_argb (unsigned int color_index, unsigned int palette, hb_color_t* color) const
+ get_color_record_argb (unsigned int color_index, unsigned int palette_index, hb_color_t* color) const
{
- if (unlikely (color_index >= numPaletteEntries || palette >= numPalettes))
+ if (unlikely (color_index >= numPaletteEntries || palette_index >= numPalettes))
return false;
/* No need for more range check as it is already done on #sanitize */
const UnsizedArrayOf<BGRAColor>& color_records = this+colorRecordsZ;
if (color)
- *color = color_records[colorRecordIndicesZ[palette] + color_index];
+ *color = color_records[colorRecordIndicesZ[palette_index] + color_index];
return true;
}
diff --git a/src/hb-ot-color.cc b/src/hb-ot-color.cc
index 13094579..e4052392 100644
--- a/src/hb-ot-color.cc
+++ b/src/hb-ot-color.cc
@@ -77,6 +77,7 @@ _get_svg (hb_face_t *face)
}
#endif
+
/*
* CPAL
*/
commit 0babf761c986855f9cdd1a2679380ee6a02390c8
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date: Tue Oct 23 01:33:45 2018 +0330
Adopt dump-emoji with latest unreleased APIs changes (#1297)
diff --git a/src/dump-emoji.cc b/src/dump-emoji.cc
index fdd0b097..2f79fc69 100644
--- a/src/dump-emoji.cc
+++ b/src/dump-emoji.cc
@@ -95,14 +95,13 @@ colr_cpal_rendering (hb_face_t *face, cairo_font_face_t *cairo_face)
unsigned glyph_count = hb_face_get_glyph_count (face);
for (hb_codepoint_t gid = 0; gid < glyph_count; ++gid)
{
- unsigned int num_layers = hb_ot_color_get_color_layers (face, gid, 0, nullptr, nullptr, nullptr);
+ unsigned int num_layers = hb_ot_color_glyph_get_layers (face, gid, 0, nullptr, nullptr);
if (!num_layers)
continue;
- hb_codepoint_t *layer_gids = (hb_codepoint_t*) calloc (num_layers, sizeof (hb_codepoint_t));
- unsigned int *color_indices = (unsigned int*) calloc (num_layers, sizeof (unsigned int));
+ hb_ot_color_layer_t *layers = (hb_ot_color_layer_t*) malloc (num_layers * sizeof (hb_ot_color_layer_t));
- hb_ot_color_get_color_layers (face, gid, 0, &num_layers, layer_gids, color_indices);
+ hb_ot_color_glyph_get_layers (face, gid, 0, &num_layers, layers);
if (num_layers)
{
// Measure
@@ -115,7 +114,7 @@ colr_cpal_rendering (hb_face_t *face, cairo_font_face_t *cairo_face)
cairo_glyph_t *glyphs = (cairo_glyph_t *) calloc (num_layers, sizeof (cairo_glyph_t));
for (unsigned int j = 0; j < num_layers; ++j)
- glyphs[j].index = layer_gids[j];
+ glyphs[j].index = layers[j].glyph;
cairo_glyph_extents (cr, glyphs, num_layers, &extents);
free (glyphs);
cairo_surface_destroy (surface);
@@ -129,16 +128,16 @@ colr_cpal_rendering (hb_face_t *face, cairo_font_face_t *cairo_face)
extents.y_bearing -= extents.height / 20;
// Render
- unsigned int palette_count = hb_ot_color_get_palette_count (face);
+ unsigned int palette_count = hb_ot_color_palette_get_count (face);
for (unsigned int palette = 0; palette < palette_count; palette++) {
char output_path[255];
- unsigned int num_colors = hb_ot_color_get_palette_colors (face, palette, 0, nullptr, nullptr);
+ unsigned int num_colors = hb_ot_color_palette_get_colors (face, palette, 0, nullptr, nullptr);
if (!num_colors)
continue;
hb_color_t *colors = (hb_color_t*) calloc (num_colors, sizeof (hb_color_t));
- hb_ot_color_get_palette_colors (face, palette, 0, &num_colors, colors);
+ hb_ot_color_palette_get_colors (face, palette, 0, &num_colors, colors);
if (num_colors)
{
// If we have more than one palette, use a simpler naming
@@ -155,8 +154,8 @@ colr_cpal_rendering (hb_face_t *face, cairo_font_face_t *cairo_face)
for (unsigned int layer = 0; layer < num_layers; ++layer)
{
hb_color_t color = 0x000000FF;
- if (color_indices[layer] != 0xFFFF)
- color = colors[color_indices[layer]];
+ if (layers[layer].color_index != 0xFFFF)
+ color = colors[layers[layer].color_index];
cairo_set_source_rgba (cr,
hb_color_get_red (color) / 255.,
hb_color_get_green (color) / 255.,
@@ -164,7 +163,7 @@ colr_cpal_rendering (hb_face_t *face, cairo_font_face_t *cairo_face)
hb_color_get_alpha (color) / 255.);
cairo_glyph_t glyph;
- glyph.index = layer_gids[layer];
+ glyph.index = layers[layer].glyph;
glyph.x = -extents.x_bearing;
glyph.y = -extents.y_bearing;
cairo_show_glyphs (cr, &glyph, 1);
@@ -177,8 +176,7 @@ colr_cpal_rendering (hb_face_t *face, cairo_font_face_t *cairo_face)
}
}
- free (layer_gids);
- free (color_indices);
+ free (layers);
}
}
More information about the HarfBuzz
mailing list