[HarfBuzz] harfbuzz: Branch 'master' - 6 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Mon Dec 5 03:55:42 UTC 2016
src/hb-ot-cbdt-table.hh | 81 +++++++---
src/hb-ot-font.cc | 56 +++---
test/shaping/Makefile.am | 1
test/shaping/fonts/sha1sum/ee39587d13b2afa5499cc79e45780aa79293bbd4.ttf |binary
test/shaping/tests/color-fonts.tests | 1
5 files changed, 88 insertions(+), 51 deletions(-)
New commits:
commit 9f6144cdb9dd2bc8cd147306e678d76ae82663d8
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sun Dec 4 19:55:17 2016 -0800
[CBDT] Add test for fetching glyph extents
diff --git a/test/shaping/Makefile.am b/test/shaping/Makefile.am
index c5efe62..57369fd 100644
--- a/test/shaping/Makefile.am
+++ b/test/shaping/Makefile.am
@@ -44,6 +44,7 @@ TESTS = \
tests/arabic-fallback-shaping.tests \
tests/arabic-feature-order.tests \
tests/cluster.tests \
+ tests/color-fonts.tests \
tests/context-matching.tests \
tests/cursive-positioning.tests \
tests/default-ignorables.tests \
diff --git a/test/shaping/fonts/sha1sum/ee39587d13b2afa5499cc79e45780aa79293bbd4.ttf b/test/shaping/fonts/sha1sum/ee39587d13b2afa5499cc79e45780aa79293bbd4.ttf
new file mode 100644
index 0000000..fa2d0e1
Binary files /dev/null and b/test/shaping/fonts/sha1sum/ee39587d13b2afa5499cc79e45780aa79293bbd4.ttf differ
diff --git a/test/shaping/tests/color-fonts.tests b/test/shaping/tests/color-fonts.tests
new file mode 100644
index 0000000..397796a
--- /dev/null
+++ b/test/shaping/tests/color-fonts.tests
@@ -0,0 +1 @@
+fonts/sha1sum/ee39587d13b2afa5499cc79e45780aa79293bbd4.ttf:--font-funcs=ot --show-extents:U+1F42F:[gid1=0+2963<0,2178,2963,-2788>]
commit e4bfccfb2a0f425ff69b0a50ca8a4731c4001069
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sun Dec 4 19:43:33 2016 -0800
[CBDT] Minor
diff --git a/src/hb-ot-cbdt-table.hh b/src/hb-ot-cbdt-table.hh
index 7269688..52897ab 100644
--- a/src/hb-ot-cbdt-table.hh
+++ b/src/hb-ot-cbdt-table.hh
@@ -56,6 +56,15 @@ struct SmallGlyphMetrics
DEFINE_SIZE_STATIC(5);
};
+struct BigGlyphMetrics : SmallGlyphMetrics
+{
+ CHAR vertBearingX;
+ CHAR vertBearingY;
+ BYTE vertAdvance;
+
+ DEFINE_SIZE_STATIC(8);
+};
+
struct SBitLineMetrics
{
inline bool sanitize (hb_sanitize_context_t *c) const
@@ -171,6 +180,7 @@ struct IndexSubtable
IndexSubtableHeader header;
IndexSubtableFormat1 format1;
IndexSubtableFormat3 format3;
+ /* TODO: Format 2, 4, 5. */
} u;
public:
DEFINE_SIZE_UNION (8, header);
@@ -321,7 +331,6 @@ struct CBLC
{
/* TODO: Make it possible to select strike. */
- const BitmapSizeTable *sizeTable = &Null(BitmapSizeTable);
unsigned int count = sizeTables.len;
for (uint32_t i = 0; i < count; ++i)
{
@@ -329,15 +338,13 @@ struct CBLC
unsigned int endGlyphIndex = sizeTables.array[i].endGlyphIndex;
if (startGlyphIndex <= glyph && glyph <= endGlyphIndex)
{
- sizeTable = &sizeTables[i];
- break;
+ *x_ppem = sizeTables[i].ppemX;
+ *y_ppem = sizeTables[i].ppemY;
+ return sizeTables[i].find_table (glyph, this);
}
}
- *x_ppem = sizeTable->ppemX;
- *y_ppem = sizeTable->ppemY;
-
- return sizeTable->find_table (glyph, this);
+ return NULL;
}
protected:
diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc
index 1b6cea4..df01bc9 100644
--- a/src/hb-ot-font.cc
+++ b/src/hb-ot-font.cc
@@ -246,14 +246,12 @@ struct hb_ot_face_cbdt_accelerator_t
{
unsigned int x_ppem = upem, y_ppem = upem; /* TODO Use font ppem if available. */
- if (cblc == NULL) {
+ if (cblc == NULL)
return false; // Not a color bitmap font.
- }
const OT::IndexSubtableRecord *subtable_record = this->cblc->find_table(glyph, &x_ppem, &y_ppem);
- if (subtable_record == NULL) {
+ if (subtable_record == NULL)
return false;
- }
if (subtable_record->get_extents (extents))
return true;
@@ -262,23 +260,27 @@ struct hb_ot_face_cbdt_accelerator_t
if (!subtable_record->get_image_data (glyph, &image_offset, &image_length, &image_format))
return false;
- if (unlikely (image_offset > cbdt_len || cbdt_len - image_offset < image_length))
- return false;
-
- switch (image_format)
{
- case 17: {
- if (unlikely (image_length < OT::GlyphBitmapDataFormat17::min_size))
- return false;
+ /* TODO Move the following into CBDT struct when adding more formats. */
- const OT::GlyphBitmapDataFormat17& glyphFormat17 =
- OT::StructAtOffset<OT::GlyphBitmapDataFormat17> (this->cbdt, image_offset);
- glyphFormat17.glyphMetrics.get_extents (extents);
- }
- break;
- default:
- // TODO: Support other image formats.
+ if (unlikely (image_offset > cbdt_len || cbdt_len - image_offset < image_length))
return false;
+
+ switch (image_format)
+ {
+ case 17: {
+ if (unlikely (image_length < OT::GlyphBitmapDataFormat17::min_size))
+ return false;
+
+ const OT::GlyphBitmapDataFormat17& glyphFormat17 =
+ OT::StructAtOffset<OT::GlyphBitmapDataFormat17> (this->cbdt, image_offset);
+ glyphFormat17.glyphMetrics.get_extents (extents);
+ }
+ break;
+ default:
+ // TODO: Support other image formats.
+ return false;
+ }
}
/* Convert to the font units. */
commit b7068af423dba30fd831041aabf4b805d26fe349
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sun Dec 4 19:36:30 2016 -0800
[CBDT] Fix thinko!
diff --git a/src/hb-ot-cbdt-table.hh b/src/hb-ot-cbdt-table.hh
index 3bf5794..7269688 100644
--- a/src/hb-ot-cbdt-table.hh
+++ b/src/hb-ot-cbdt-table.hh
@@ -216,7 +216,7 @@ struct IndexSubtableArray
inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const
{
TRACE_SANITIZE (this);
- if (unlikely (!c->check_array (&indexSubtablesZ, indexSubtablesZ[0].static_size, sizeof (count))))
+ if (unlikely (!c->check_array (&indexSubtablesZ, indexSubtablesZ[0].static_size, count)))
return_trace (false);
for (unsigned int i = 0; i < count; i++)
if (unlikely (!indexSubtablesZ[i].sanitize (c, this)))
commit a141d1da9bb0f91521a9a7749f9533c75cfe6a2f
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sun Dec 4 19:26:54 2016 -0800
[CBDT] Implement IndexSubtableFormat3
diff --git a/src/hb-ot-cbdt-table.hh b/src/hb-ot-cbdt-table.hh
index 4770cf3..3bf5794 100644
--- a/src/hb-ot-cbdt-table.hh
+++ b/src/hb-ot-cbdt-table.hh
@@ -100,7 +100,8 @@ struct IndexSubtableHeader
DEFINE_SIZE_STATIC(8);
};
-struct IndexSubtableFormat1
+template <typename OffsetType>
+struct IndexSubtableFormat1Or3
{
inline bool sanitize (hb_sanitize_context_t *c, unsigned int glyph_count) const
{
@@ -122,11 +123,14 @@ struct IndexSubtableFormat1
}
IndexSubtableHeader header;
- Offset<ULONG> offsetArrayZ[VAR];
+ Offset<OffsetType> offsetArrayZ[VAR];
DEFINE_SIZE_ARRAY(8, offsetArrayZ);
};
+struct IndexSubtableFormat1 : IndexSubtableFormat1Or3<ULONG> {};
+struct IndexSubtableFormat3 : IndexSubtableFormat1Or3<USHORT> {};
+
struct IndexSubtable
{
inline bool sanitize (hb_sanitize_context_t *c, unsigned int glyph_count) const
@@ -135,6 +139,7 @@ struct IndexSubtable
if (!u.header.sanitize (c)) return_trace (false);
switch (u.header.indexFormat) {
case 1: return_trace (u.format1.sanitize (c, glyph_count));
+ case 3: return_trace (u.format3.sanitize (c, glyph_count));
default:return_trace (true);
}
}
@@ -156,6 +161,7 @@ struct IndexSubtable
*format = u.header.imageFormat;
switch (u.header.indexFormat) {
case 1: return u.format1.get_image_data (idx, offset, length);
+ case 3: return u.format3.get_image_data (idx, offset, length);
default: return false;
}
}
@@ -164,6 +170,7 @@ struct IndexSubtable
union {
IndexSubtableHeader header;
IndexSubtableFormat1 format1;
+ IndexSubtableFormat3 format3;
} u;
public:
DEFINE_SIZE_UNION (8, header);
commit 9eda74c92c9024ffb8ec6e9344c99d51dd763f0c
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sun Dec 4 19:12:52 2016 -0800
[cbdt] Move some more code around
diff --git a/src/hb-ot-cbdt-table.hh b/src/hb-ot-cbdt-table.hh
index 2043a25..4770cf3 100644
--- a/src/hb-ot-cbdt-table.hh
+++ b/src/hb-ot-cbdt-table.hh
@@ -80,9 +80,11 @@ struct SBitLineMetrics
DEFINE_SIZE_STATIC(12);
};
+
/*
* Index Subtables.
*/
+
struct IndexSubtableHeader
{
inline bool sanitize (hb_sanitize_context_t *c) const
@@ -202,19 +204,6 @@ struct IndexSubtableRecord
DEFINE_SIZE_STATIC(8);
};
-/*
- * Glyph Bitmap Data Formats.
- */
-
-struct GlyphBitmapDataFormat17
-{
- SmallGlyphMetrics glyphMetrics;
- ULONG dataLen;
- BYTE dataZ[VAR];
-
- DEFINE_SIZE_ARRAY(9, dataZ);
-};
-
struct IndexSubtableArray
{
inline bool sanitize (hb_sanitize_context_t *c, unsigned int count) const
@@ -251,6 +240,8 @@ struct IndexSubtableArray
struct BitmapSizeTable
{
+ friend struct CBLC;
+
inline bool sanitize (hb_sanitize_context_t *c, const void *base) const
{
TRACE_SANITIZE (this);
@@ -261,6 +252,12 @@ struct BitmapSizeTable
vertical.sanitize (c));
}
+ const IndexSubtableRecord *find_table (hb_codepoint_t glyph, const void *base) const
+ {
+ return (base+indexSubtableArrayOffset).find_table (glyph, numberOfIndexSubtables);
+ }
+
+ protected:
OffsetTo<IndexSubtableArray, ULONG> indexSubtableArrayOffset;
ULONG indexTablesSize;
ULONG numberOfIndexSubtables;
@@ -274,9 +271,25 @@ struct BitmapSizeTable
BYTE bitDepth;
CHAR flags;
+public:
DEFINE_SIZE_STATIC(48);
};
+
+/*
+ * Glyph Bitmap Data Formats.
+ */
+
+struct GlyphBitmapDataFormat17
+{
+ SmallGlyphMetrics glyphMetrics;
+ ULONG dataLen;
+ BYTE dataZ[VAR];
+
+ DEFINE_SIZE_ARRAY(9, dataZ);
+};
+
+
/*
* CBLC -- Color Bitmap Location Table
*/
@@ -296,18 +309,28 @@ struct CBLC
}
public:
- const BitmapSizeTable* find_table (hb_codepoint_t glyph) const
+ const IndexSubtableRecord *find_table (hb_codepoint_t glyph,
+ unsigned int *x_ppem, unsigned int *y_ppem) const
{
- // TODO: Make it possible to select strike.
+ /* TODO: Make it possible to select strike. */
+
+ const BitmapSizeTable *sizeTable = &Null(BitmapSizeTable);
unsigned int count = sizeTables.len;
- for (uint32_t i = 0; i < count; ++i) {
+ for (uint32_t i = 0; i < count; ++i)
+ {
unsigned int startGlyphIndex = sizeTables.array[i].startGlyphIndex;
unsigned int endGlyphIndex = sizeTables.array[i].endGlyphIndex;
- if (startGlyphIndex <= glyph && glyph <= endGlyphIndex) {
- return &sizeTables[i];
+ if (startGlyphIndex <= glyph && glyph <= endGlyphIndex)
+ {
+ sizeTable = &sizeTables[i];
+ break;
}
}
- return NULL;
+
+ *x_ppem = sizeTable->ppemX;
+ *y_ppem = sizeTable->ppemY;
+
+ return sizeTable->find_table (glyph, this);
}
protected:
diff --git a/src/hb-ot-font.cc b/src/hb-ot-font.cc
index 1a2d382..1b6cea4 100644
--- a/src/hb-ot-font.cc
+++ b/src/hb-ot-font.cc
@@ -244,17 +244,13 @@ struct hb_ot_face_cbdt_accelerator_t
inline bool get_extents (hb_codepoint_t glyph, hb_glyph_extents_t *extents) const
{
+ unsigned int x_ppem = upem, y_ppem = upem; /* TODO Use font ppem if available. */
+
if (cblc == NULL) {
return false; // Not a color bitmap font.
}
- const OT::BitmapSizeTable* sizeTable = this->cblc->find_table(glyph);
- if (sizeTable == NULL) {
- return false;
- }
-
- const OT::IndexSubtableArray& subtables = this->cblc + sizeTable->indexSubtableArrayOffset;
- const OT::IndexSubtableRecord *subtable_record = subtables.find_table (glyph, sizeTable->numberOfIndexSubtables);
+ const OT::IndexSubtableRecord *subtable_record = this->cblc->find_table(glyph, &x_ppem, &y_ppem);
if (subtable_record == NULL) {
return false;
}
@@ -286,10 +282,10 @@ struct hb_ot_face_cbdt_accelerator_t
}
/* Convert to the font units. */
- extents->x_bearing *= upem / (float)(sizeTable->ppemX);
- extents->y_bearing *= upem / (float)(sizeTable->ppemY);
- extents->width *= upem / (float)(sizeTable->ppemX);
- extents->height *= upem / (float)(sizeTable->ppemY);
+ extents->x_bearing *= upem / (float) x_ppem;
+ extents->y_bearing *= upem / (float) y_ppem;
+ extents->width *= upem / (float) x_ppem;
+ extents->height *= upem / (float) y_ppem;
return true;
}
commit 654f9ab0d8d5ee032b5da763e34e7b1f454416b9
Author: Behdad Esfahbod <behdad at behdad.org>
Date: Sun Dec 4 18:56:24 2016 -0800
[cbdt] Fix sign bug
Was introduced in d495fc5e38038f4cfb20425b1109324fa70bf2f9
diff --git a/src/hb-ot-cbdt-table.hh b/src/hb-ot-cbdt-table.hh
index 4319067..2043a25 100644
--- a/src/hb-ot-cbdt-table.hh
+++ b/src/hb-ot-cbdt-table.hh
@@ -44,7 +44,7 @@ struct SmallGlyphMetrics
extents->x_bearing = bearingX;
extents->y_bearing = bearingY;
extents->width = width;
- extents->height = height;
+ extents->height = -height;
}
BYTE height;
More information about the HarfBuzz
mailing list