[HarfBuzz] harfbuzz: Branch 'master' - 23 commits
Behdad Esfahbod
behdad at kemper.freedesktop.org
Sun Mar 11 15:47:14 UTC 2018
.circleci/config.yml | 7
src/Makefile.sources | 2
src/dev-run.sh | 2
src/hb-ot-color-sbix-table.hh | 128 ++++++++++
src/hb-ot-color-svg-table.hh | 111 ++++++++
src/hb-ot-hmtx-table.hh | 2
src/hb-ot-layout.cc | 2
src/hb-ot-post-table.hh | 22 +
src/hb-subset.cc | 59 +++-
test/api/Makefile.am | 4
test/api/fonts/Mplus1p-Regular.660E,6975,73E0,5EA6,8F38,6E05.ttf |binary
test/api/fonts/Mplus1p-Regular.660E.ttf |binary
test/api/test-subset-post.c | 61 ++++
test/api/test-subset-vmtx.c | 99 +++++++
test/subset/data/Makefile.am | 1
test/subset/data/Makefile.sources | 1
test/subset/data/expected/japanese/Mplus1p-Regular.default.3042,3044,3046,3048,304A,304B.ttf |binary
test/subset/data/expected/japanese/Mplus1p-Regular.default.3042,3044,3046,73E0,5EA6,8F38.ttf |binary
test/subset/data/expected/japanese/Mplus1p-Regular.default.61,63,65,6B.ttf |binary
test/subset/data/expected/japanese/Mplus1p-Regular.default.660E,6975,73E0,5EA6,8F38,6E05.ttf |binary
test/subset/data/expected/japanese/Mplus1p-Regular.default.660E.ttf |binary
test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.3042,3044,3046,3048,304A,304B.ttf |binary
test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.3042,3044,3046,73E0,5EA6,8F38.ttf |binary
test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.61,63,65,6B.ttf |binary
test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.660E,6975,73E0,5EA6,8F38,6E05.ttf |binary
test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.660E.ttf |binary
test/subset/data/fonts/Mplus1p-Regular.ttf |binary
test/subset/data/tests/japanese.tests | 16 +
test/subset/run-tests.py | 12
29 files changed, 504 insertions(+), 25 deletions(-)
New commits:
commit 218fa7166e9626f2036d08882854a86d753e4192
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date: Sat Mar 10 11:13:52 2018 +0330
[ot-color] SVG table implementation (#874)
diff --git a/src/Makefile.sources b/src/Makefile.sources
index 302bd02f..cfd2b61a 100644
--- a/src/Makefile.sources
+++ b/src/Makefile.sources
@@ -18,7 +18,6 @@ HB_BASE_sources = \
hb-open-file-private.hh \
hb-open-type-private.hh \
hb-ot-color-cbdt-table.hh \
- hb-ot-color-sbix-table.hh \
hb-ot-cmap-table.hh \
hb-ot-glyf-table.hh \
hb-ot-hdmx-table.hh \
@@ -100,6 +99,8 @@ HB_OT_sources = \
hb-ot-color.cc \
hb-ot-color-colr-table.hh \
hb-ot-color-cpal-table.hh \
+ hb-ot-color-sbix-table.hh \
+ hb-ot-color-svg-table.hh \
hb-ot-map.cc \
hb-ot-map-private.hh \
hb-ot-math.cc \
diff --git a/src/hb-ot-color-svg-table.hh b/src/hb-ot-color-svg-table.hh
new file mode 100644
index 00000000..7e5161c9
--- /dev/null
+++ b/src/hb-ot-color-svg-table.hh
@@ -0,0 +1,111 @@
+/*
+ * Copyright © 2018 Ebrahim Byagowi
+ *
+ * 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.
+ */
+
+#ifndef HB_OT_COLOR_SVG_TABLE_HH
+#define HB_OT_COLOR_SVG_TABLE_HH
+
+#include "hb-open-type-private.hh"
+
+/*
+ * The SVG (Scalable Vector Graphics) table
+ * https://docs.microsoft.com/en-us/typography/opentype/spec/svg
+ */
+
+#define HB_OT_TAG_SVG HB_TAG('S','V','G',' ')
+
+namespace OT {
+
+
+struct SVGDocumentIndexEntry
+{
+ // friend struct SVGDocumentIndex;
+
+ inline bool sanitize (hb_sanitize_context_t *c, const void* base) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) &&
+ c->check_range (&svgDoc (base), svgDocLength));
+ }
+
+ protected:
+ HBUINT16 startGlyphID;
+ HBUINT16 endGlyphID;
+ LOffsetTo<const uint8_t *> svgDoc;
+ HBUINT32 svgDocLength;
+ public:
+ DEFINE_SIZE_STATIC (12);
+};
+
+struct SVGDocumentIndex
+{
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ // dump ();
+ return_trace (c->check_struct (this) &&
+ entries.sanitize (c, this));
+ }
+
+ // inline void dump () const
+ // {
+ // for (unsigned int i = 0; i < entries.len; ++i)
+ // {
+ // char outName[255];
+ // sprintf (outName, "out/%d.svg", i);
+ // const SVGDocumentIndexEntry &entry = entries[i];
+ // FILE *f = fopen (outName, "wb");
+ // fwrite (&entry.svgDoc (this), 1, entry.svgDocLength, f);
+ // fclose (f);
+ // }
+ // }
+
+ protected:
+ ArrayOf<SVGDocumentIndexEntry> entries;
+ public:
+ DEFINE_SIZE_ARRAY (2, entries);
+};
+
+struct SVG
+{
+ static const hb_tag_t tableTag = HB_OT_TAG_SVG;
+
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) &&
+ svgDocIndex(this).sanitize (c));
+ }
+
+ protected:
+ HBUINT16 version;
+ LOffsetTo<SVGDocumentIndex> svgDocIndex;
+ HBUINT32 reserved;
+ public:
+ DEFINE_SIZE_STATIC (10);
+};
+
+} /* namespace OT */
+
+
+#endif /* HB_OT_COLOR_SVG_TABLE_HH */
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index d13acbe3..9e6f858c 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -40,6 +40,7 @@
#include "hb-ot-color-colr-table.hh"
#include "hb-ot-color-cpal-table.hh"
#include "hb-ot-color-sbix-table.hh" // Just so we compile it; unused otherwise.
+#include "hb-ot-color-svg-table.hh" // Just so we compile it; unused otherwise.
#include "hb-ot-map-private.hh"
commit 4c63c82383cba11f2c44c00cbc953863346e627c
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date: Sat Mar 10 11:07:56 2018 +0330
[ot-color] sbix table implementation (#870)
diff --git a/src/Makefile.sources b/src/Makefile.sources
index 787c3c4b..302bd02f 100644
--- a/src/Makefile.sources
+++ b/src/Makefile.sources
@@ -18,6 +18,7 @@ HB_BASE_sources = \
hb-open-file-private.hh \
hb-open-type-private.hh \
hb-ot-color-cbdt-table.hh \
+ hb-ot-color-sbix-table.hh \
hb-ot-cmap-table.hh \
hb-ot-glyf-table.hh \
hb-ot-hdmx-table.hh \
diff --git a/src/hb-ot-color-sbix-table.hh b/src/hb-ot-color-sbix-table.hh
new file mode 100644
index 00000000..5f6a0ecb
--- /dev/null
+++ b/src/hb-ot-color-sbix-table.hh
@@ -0,0 +1,128 @@
+/*
+ * Copyright © 2018 Ebrahim Byagowi
+ *
+ * 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.
+ */
+
+#ifndef HB_OT_COLOR_SBIX_TABLE_HH
+#define HB_OT_COLOR_SBIX_TABLE_HH
+
+#include "hb-open-type-private.hh"
+
+#define HB_OT_TAG_SBIX HB_TAG('s','b','i','x')
+
+namespace OT {
+
+
+struct SBIXGlyph
+{
+ friend struct sbix;
+
+ protected:
+ HBINT16 originOffsetX;
+ HBINT16 originOffsetY;
+ unsigned char tag[4];
+ HBUINT8 data[VAR];
+ public:
+ DEFINE_SIZE_STATIC (9);
+};
+
+struct ImageTable
+{
+ friend struct sbix;
+
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ return_trace (c->check_struct (this) &&
+ c->check_array (imageOffsetsZ, sizeof (HBUINT32), c->num_glyphs) &&
+ c->check_range (this, imageOffsetsZ[c->num_glyphs]));
+ }
+
+ protected:
+ HBUINT16 ppem;
+ HBUINT16 resolution;
+ LOffsetTo<SBIXGlyph> imageOffsetsZ[VAR]; // VAR=maxp.numGlyphs + 1
+ public:
+ DEFINE_SIZE_STATIC (8);
+};
+
+/*
+ * sbix -- Standard Bitmap Graphics Table
+ */
+// It should be called with something like this so it can have
+// access to num_glyph while sanitizing.
+//
+// static inline const OT::sbix*
+// _get_sbix (hb_face_t *face)
+// {
+// OT::Sanitizer<OT::sbix> sanitizer;
+// sanitizer.set_num_glyphs (face->get_num_glyphs ());
+// hb_blob_t *sbix_blob = sanitizer.sanitize (face->reference_table (HB_OT_TAG_SBIX));
+// return OT::Sanitizer<OT::sbix>::lock_instance (sbix_blob);
+// }
+//
+struct sbix
+{
+ static const hb_tag_t tableTag = HB_OT_TAG_SBIX;
+
+ inline bool sanitize (hb_sanitize_context_t *c) const
+ {
+ TRACE_SANITIZE (this);
+ if (!(c->check_struct (this) && imageTables.sanitize (c, this)))
+ return_trace (false);
+
+ for (unsigned int i = 0; i < imageTables.len; ++i)
+ if (!(imageTables[i].sanitize (c, this)))
+ return_trace (false);
+
+ // dump (c->num_glyphs, 8);
+
+ return_trace (true);
+ }
+
+ // inline void dump (unsigned int num_glyphs, unsigned int group) const
+ // {
+ // const ImageTable &imageTable = imageTables[group](this);
+ // for (unsigned int i = 0; i < num_glyphs; ++i)
+ // if (imageTable.imageOffsetsZ[i + 1] - imageTable.imageOffsetsZ[i] > 0)
+ // {
+ // const SBIXGlyph &sbixGlyph = imageTable.imageOffsetsZ[i]((const void *) &imageTable);
+ // char outName[255];
+ // sprintf (outName, "out/%d-%d.png", group, i);
+ // FILE *f = fopen (outName, "wb");
+ // fwrite (sbixGlyph.data, 1,
+ // imageTable.imageOffsetsZ[i + 1] - imageTable.imageOffsetsZ[i] - 8, f);
+ // fclose (f);
+ // }
+ // }
+
+ protected:
+ HBUINT16 version;
+ HBUINT16 flags;
+ ArrayOf<LOffsetTo<ImageTable>, HBUINT32> imageTables;
+ public:
+ DEFINE_SIZE_ARRAY (8, imageTables);
+};
+
+} /* namespace OT */
+
+#endif /* HB_OT_COLOR_SBIX_TABLE_HH */
diff --git a/src/hb-ot-layout.cc b/src/hb-ot-layout.cc
index 1c9e950b..d13acbe3 100644
--- a/src/hb-ot-layout.cc
+++ b/src/hb-ot-layout.cc
@@ -39,6 +39,7 @@
#include "hb-ot-name-table.hh" // Just so we compile it; unused otherwise.
#include "hb-ot-color-colr-table.hh"
#include "hb-ot-color-cpal-table.hh"
+#include "hb-ot-color-sbix-table.hh" // Just so we compile it; unused otherwise.
#include "hb-ot-map-private.hh"
commit 62b3d8fb7034c53e0804689d58e2eb7330e04430
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date: Sat Mar 10 00:44:36 2018 +0330
[dev-run] minor
diff --git a/src/dev-run.sh b/src/dev-run.sh
index e3d5bccc..e7d0973b 100755
--- a/src/dev-run.sh
+++ b/src/dev-run.sh
@@ -43,7 +43,7 @@ tmp=tmp.png
# or "fswatch -0 . -e build/ -e .git"
find src/ | entr printf '\0' | while read -d ""; do
clear
- echo '===================================================='
+ yes = | head -n`tput cols` | tr -d '\n'
if [[ $CMAKENINJA ]]; then
ninja -Cbuild hb-shape hb-view && {
build/hb-shape $@
commit 743ef317619a57ebf5a75935db0eecccade5d5b7
Merge: 9206762b 39b2f69f
Author: Garret Rieger <grieger at google.com>
Date: Fri Mar 9 12:06:52 2018 -0700
Merge pull request #872 from googlefonts/drop-tables
[subset] Drop the same tables by default as fontTools does.
commit 9206762bbd4033e97d6d35ef1cce1b7940fbc935
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date: Fri Mar 9 15:43:03 2018 +0330
Make subset test runner compatible with py3
Fixes #873
diff --git a/test/subset/run-tests.py b/test/subset/run-tests.py
index 4c77de09..6d28b24d 100755
--- a/test/subset/run-tests.py
+++ b/test/subset/run-tests.py
@@ -87,9 +87,9 @@ def run_ttx(file):
def strip_check_sum (ttx_string):
return re.sub ('checkSumAdjustment value=["]0x([0-9a-fA-F])+["]',
'checkSumAdjustment value="0x00000000"',
- ttx_string, count=1)
+ ttx_string.decode (), count=1)
-def has_ots():
+def has_ots ():
_, returncode = cmd(["which", "ots-sanitize"])
if returncode:
print("OTS is not present, skipping all ots checks.")
commit dbadb871d1ca62eff10768564fc0a17b9aaa4d63
Author: Ebrahim Byagowi <ebrahim at gnu.org>
Date: Fri Mar 9 15:25:59 2018 +0330
[ci] Enable subset tests on ArchLinux to test
This makes ArchLinux bots fail, a starting point to #873
diff --git a/.circleci/config.yml b/.circleci/config.yml
index d804afce..8ef10586 100644
--- a/.circleci/config.yml
+++ b/.circleci/config.yml
@@ -26,12 +26,13 @@ jobs:
- run: make
- run: make check || .ci/fail.sh
- archlinux-debug-O0:
+ archlinux-debug-O0-py3:
docker:
- image: base/devel
steps:
- checkout
- - run: pacman --noconfirm -Syu freetype2 cairo icu gettext gobject-introspection gcc gcc-libs glib2 graphite pkg-config ragel python
+ - run: pacman --noconfirm -Syu freetype2 cairo icu gettext gobject-introspection gcc gcc-libs glib2 graphite pkg-config ragel python python-pip
+ - run: pip install fonttools
# C??FLAGS are not needed for a regular build
- run: CFLAGS="-O0" CXXFLAGS="-O0" CPPFLAGS="-DHB_DEBUG" ./autogen.sh --with-freetype --with-glib --with-gobject --with-cairo --with-icu --with-graphite2
- run: make
@@ -167,7 +168,7 @@ workflows:
# autotools based builds
- alpine-O3
- - archlinux-debug-O0
+ - archlinux-debug-O0-py3
- clang-O3-O0
- fedora-outoftreebuild
commit 39b2f69fab3b8aec1296dcda111d358559d39f0b
Author: Garret Rieger <grieger at google.com>
Date: Thu Mar 8 16:30:36 2018 -0800
[subset] Drop the same tables by default as fontTools does.
diff --git a/src/hb-subset.cc b/src/hb-subset.cc
index 77f60db1..30cba3fc 100644
--- a/src/hb-subset.cc
+++ b/src/hb-subset.cc
@@ -290,21 +290,40 @@ _subset_table (hb_subset_plan_t *plan,
static bool
_should_drop_table(hb_subset_plan_t *plan, hb_tag_t tag)
{
- switch (tag) {
- case HB_TAG ('c', 'v', 'a', 'r'): /* hint table, fallthrough */
- case HB_TAG ('c', 'v', 't', ' '): /* hint table, fallthrough */
- case HB_TAG ('f', 'p', 'g', 'm'): /* hint table, fallthrough */
- case HB_TAG ('p', 'r', 'e', 'p'): /* hint table, fallthrough */
- case HB_TAG ('h', 'd', 'm', 'x'): /* hint table, fallthrough */
- case HB_TAG ('V', 'D', 'M', 'X'): /* hint table, fallthrough */
- return plan->drop_hints;
- case HB_TAG ('G', 'D', 'E', 'F'): /* temporary */
- case HB_TAG ('G', 'P', 'O', 'S'): /* temporary */
- case HB_TAG ('G', 'S', 'U', 'B'): /* temporary */
- case HB_TAG ('D', 'S', 'I', 'G'):
- return true;
- default:
- return false;
+ switch (tag) {
+ case HB_TAG ('c', 'v', 'a', 'r'): /* hint table, fallthrough */
+ case HB_TAG ('c', 'v', 't', ' '): /* hint table, fallthrough */
+ case HB_TAG ('f', 'p', 'g', 'm'): /* hint table, fallthrough */
+ case HB_TAG ('p', 'r', 'e', 'p'): /* hint table, fallthrough */
+ case HB_TAG ('h', 'd', 'm', 'x'): /* hint table, fallthrough */
+ case HB_TAG ('V', 'D', 'M', 'X'): /* hint table, fallthrough */
+ return plan->drop_hints;
+ // Drop Layout Tables until subsetting is supported.
+ case HB_TAG ('G', 'D', 'E', 'F'): /* temporary */
+ case HB_TAG ('G', 'P', 'O', 'S'): /* temporary */
+ case HB_TAG ('G', 'S', 'U', 'B'): /* temporary */
+ // Drop these tables below by default, list pulled
+ // from fontTools:
+ case HB_TAG ('B', 'A', 'S', 'E'):
+ case HB_TAG ('J', 'S', 'T', 'F'):
+ case HB_TAG ('D', 'S', 'I', 'G'):
+ case HB_TAG ('E', 'B', 'D', 'T'):
+ case HB_TAG ('E', 'B', 'L', 'C'):
+ case HB_TAG ('E', 'B', 'S', 'C'):
+ case HB_TAG ('S', 'V', 'G', ' '):
+ case HB_TAG ('P', 'C', 'L', 'T'):
+ case HB_TAG ('L', 'T', 'S', 'H'):
+ // Graphite tables:
+ case HB_TAG ('F', 'e', 'a', 't'):
+ case HB_TAG ('G', 'l', 'a', 't'):
+ case HB_TAG ('G', 'l', 'o', 'c'):
+ case HB_TAG ('S', 'i', 'l', 'f'):
+ case HB_TAG ('S', 'i', 'l', 'l'):
+ // Colour
+ case HB_TAG ('s', 'b', 'i', 'x'):
+ return true;
+ default:
+ return false;
}
}
commit dbe552770fa7cec91bba750e0e81aaeae96b3caf
Merge: 2ebf4c69 8548fa15
Author: Garret Rieger <grieger at google.com>
Date: Thu Mar 8 15:50:25 2018 -0700
Merge pull request #871 from googlefonts/mplus
[subset] Add a Japanese font to the subset integration tests.
commit 8548fa152241d6c5b020146f97aac15934ba0065
Author: Garret Rieger <grieger at google.com>
Date: Wed Mar 7 12:37:03 2018 -0800
[subset] Drop cmap 12, platform 0 tables from Mplus1p expected files.
diff --git a/test/subset/data/expected/japanese/Mplus1p-Regular.default.3042,3044,3046,3048,304A,304B.ttf b/test/subset/data/expected/japanese/Mplus1p-Regular.default.3042,3044,3046,3048,304A,304B.ttf
index d3b45e29..db7daa88 100644
Binary files a/test/subset/data/expected/japanese/Mplus1p-Regular.default.3042,3044,3046,3048,304A,304B.ttf and b/test/subset/data/expected/japanese/Mplus1p-Regular.default.3042,3044,3046,3048,304A,304B.ttf differ
diff --git a/test/subset/data/expected/japanese/Mplus1p-Regular.default.3042,3044,3046,73E0,5EA6,8F38.ttf b/test/subset/data/expected/japanese/Mplus1p-Regular.default.3042,3044,3046,73E0,5EA6,8F38.ttf
index c7fc0f6c..d05b5eec 100644
Binary files a/test/subset/data/expected/japanese/Mplus1p-Regular.default.3042,3044,3046,73E0,5EA6,8F38.ttf and b/test/subset/data/expected/japanese/Mplus1p-Regular.default.3042,3044,3046,73E0,5EA6,8F38.ttf differ
diff --git a/test/subset/data/expected/japanese/Mplus1p-Regular.default.61,63,65,6B.ttf b/test/subset/data/expected/japanese/Mplus1p-Regular.default.61,63,65,6B.ttf
index f940e632..cef6a42c 100644
Binary files a/test/subset/data/expected/japanese/Mplus1p-Regular.default.61,63,65,6B.ttf and b/test/subset/data/expected/japanese/Mplus1p-Regular.default.61,63,65,6B.ttf differ
diff --git a/test/subset/data/expected/japanese/Mplus1p-Regular.default.660E,6975,73E0,5EA6,8F38,6E05.ttf b/test/subset/data/expected/japanese/Mplus1p-Regular.default.660E,6975,73E0,5EA6,8F38,6E05.ttf
index 89c7a1ac..d7852d8a 100644
Binary files a/test/subset/data/expected/japanese/Mplus1p-Regular.default.660E,6975,73E0,5EA6,8F38,6E05.ttf and b/test/subset/data/expected/japanese/Mplus1p-Regular.default.660E,6975,73E0,5EA6,8F38,6E05.ttf differ
diff --git a/test/subset/data/expected/japanese/Mplus1p-Regular.default.660E.ttf b/test/subset/data/expected/japanese/Mplus1p-Regular.default.660E.ttf
index 3e32c891..be607c29 100644
Binary files a/test/subset/data/expected/japanese/Mplus1p-Regular.default.660E.ttf and b/test/subset/data/expected/japanese/Mplus1p-Regular.default.660E.ttf differ
diff --git a/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.3042,3044,3046,3048,304A,304B.ttf b/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.3042,3044,3046,3048,304A,304B.ttf
index a245afe7..1e5a7c7f 100644
Binary files a/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.3042,3044,3046,3048,304A,304B.ttf and b/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.3042,3044,3046,3048,304A,304B.ttf differ
diff --git a/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.3042,3044,3046,73E0,5EA6,8F38.ttf b/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.3042,3044,3046,73E0,5EA6,8F38.ttf
index 58543d13..3845822d 100644
Binary files a/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.3042,3044,3046,73E0,5EA6,8F38.ttf and b/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.3042,3044,3046,73E0,5EA6,8F38.ttf differ
diff --git a/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.61,63,65,6B.ttf b/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.61,63,65,6B.ttf
index 7024fc78..fce81232 100644
Binary files a/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.61,63,65,6B.ttf and b/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.61,63,65,6B.ttf differ
diff --git a/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.660E,6975,73E0,5EA6,8F38,6E05.ttf b/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.660E,6975,73E0,5EA6,8F38,6E05.ttf
index 8468460c..b72eaf9c 100644
Binary files a/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.660E,6975,73E0,5EA6,8F38,6E05.ttf and b/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.660E,6975,73E0,5EA6,8F38,6E05.ttf differ
diff --git a/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.660E.ttf b/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.660E.ttf
index 6b2f5e60..ee7baba6 100644
Binary files a/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.660E.ttf and b/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.660E.ttf differ
commit 9b00b9a10d5fdfd2d9deb1b0e847695797b7e09b
Author: Garret Rieger <grieger at google.com>
Date: Tue Mar 6 17:47:40 2018 -0800
[subset] Fix deadlock waiting for process output in subset test runner.
diff --git a/test/subset/run-tests.py b/test/subset/run-tests.py
index 072a49d5..4c77de09 100755
--- a/test/subset/run-tests.py
+++ b/test/subset/run-tests.py
@@ -19,9 +19,9 @@ from subset_test_suite import SubsetTestSuite
def cmd(command):
p = subprocess.Popen (
command, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- p.wait ()
- print (p.stderr.read (), end="") # file=sys.stderr
- return p.stdout.read (), p.returncode
+ (stdoutdata, stderrdata) = p.communicate()
+ print (stderrdata, end="") # file=sys.stderr
+ return stdoutdata, p.returncode
def read_binary(file_path):
with open(file_path, 'rb') as f:
commit bfec28a7db0631f42dd420a8c04638624e4602af
Author: Garret Rieger <grieger at google.com>
Date: Tue Mar 6 15:43:08 2018 -0800
[subset] add some extra logging to subset run-tests.py.
diff --git a/test/subset/run-tests.py b/test/subset/run-tests.py
index 56cd7b4c..072a49d5 100755
--- a/test/subset/run-tests.py
+++ b/test/subset/run-tests.py
@@ -60,6 +60,7 @@ def run_test(test, should_check_ots):
if return_code:
return fail_test(test, cli_args, "ttx (actual) returned %d" % (return_code))
+ print ("stripping checksums.")
expected_ttx = strip_check_sum (expected_ttx)
actual_ttx = strip_check_sum (actual_ttx)
@@ -77,6 +78,7 @@ def run_test(test, should_check_ots):
return 0
def run_ttx(file):
+ print ("ttx %s" % file)
cli_args = ["ttx",
"-o-",
file]
commit c7d814eaa8e9af6c447124ceeaa896eb5e17abd7
Author: Garret Rieger <grieger at google.com>
Date: Thu Mar 1 18:20:00 2018 -0800
[subset] Add japanese font file to subset integration tests.
diff --git a/test/subset/data/Makefile.am b/test/subset/data/Makefile.am
index 0b001343..0d1b2f03 100644
--- a/test/subset/data/Makefile.am
+++ b/test/subset/data/Makefile.am
@@ -9,6 +9,7 @@ EXTRA_DIST = \
$(TESTS) \
expected/basics \
expected/full-font \
+ expected/japanese \
fonts \
profiles \
$(NULL)
diff --git a/test/subset/data/Makefile.sources b/test/subset/data/Makefile.sources
index bc813937..dd1bcfe7 100644
--- a/test/subset/data/Makefile.sources
+++ b/test/subset/data/Makefile.sources
@@ -1,6 +1,7 @@
TESTS = \
tests/basics.tests \
tests/full-font.tests \
+ tests/japanese.tests \
$(NULL)
XFAIL_TESTS = \
diff --git a/test/subset/data/expected/japanese/Mplus1p-Regular.default.3042,3044,3046,3048,304A,304B.ttf b/test/subset/data/expected/japanese/Mplus1p-Regular.default.3042,3044,3046,3048,304A,304B.ttf
new file mode 100644
index 00000000..d3b45e29
Binary files /dev/null and b/test/subset/data/expected/japanese/Mplus1p-Regular.default.3042,3044,3046,3048,304A,304B.ttf differ
diff --git a/test/subset/data/expected/japanese/Mplus1p-Regular.default.3042,3044,3046,73E0,5EA6,8F38.ttf b/test/subset/data/expected/japanese/Mplus1p-Regular.default.3042,3044,3046,73E0,5EA6,8F38.ttf
new file mode 100644
index 00000000..c7fc0f6c
Binary files /dev/null and b/test/subset/data/expected/japanese/Mplus1p-Regular.default.3042,3044,3046,73E0,5EA6,8F38.ttf differ
diff --git a/test/subset/data/expected/japanese/Mplus1p-Regular.default.61,63,65,6B.ttf b/test/subset/data/expected/japanese/Mplus1p-Regular.default.61,63,65,6B.ttf
new file mode 100644
index 00000000..f940e632
Binary files /dev/null and b/test/subset/data/expected/japanese/Mplus1p-Regular.default.61,63,65,6B.ttf differ
diff --git a/test/subset/data/expected/japanese/Mplus1p-Regular.default.660E,6975,73E0,5EA6,8F38,6E05.ttf b/test/subset/data/expected/japanese/Mplus1p-Regular.default.660E,6975,73E0,5EA6,8F38,6E05.ttf
new file mode 100644
index 00000000..89c7a1ac
Binary files /dev/null and b/test/subset/data/expected/japanese/Mplus1p-Regular.default.660E,6975,73E0,5EA6,8F38,6E05.ttf differ
diff --git a/test/subset/data/expected/japanese/Mplus1p-Regular.default.660E.ttf b/test/subset/data/expected/japanese/Mplus1p-Regular.default.660E.ttf
new file mode 100644
index 00000000..3e32c891
Binary files /dev/null and b/test/subset/data/expected/japanese/Mplus1p-Regular.default.660E.ttf differ
diff --git a/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.3042,3044,3046,3048,304A,304B.ttf b/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.3042,3044,3046,3048,304A,304B.ttf
new file mode 100644
index 00000000..a245afe7
Binary files /dev/null and b/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.3042,3044,3046,3048,304A,304B.ttf differ
diff --git a/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.3042,3044,3046,73E0,5EA6,8F38.ttf b/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.3042,3044,3046,73E0,5EA6,8F38.ttf
new file mode 100644
index 00000000..58543d13
Binary files /dev/null and b/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.3042,3044,3046,73E0,5EA6,8F38.ttf differ
diff --git a/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.61,63,65,6B.ttf b/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.61,63,65,6B.ttf
new file mode 100644
index 00000000..7024fc78
Binary files /dev/null and b/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.61,63,65,6B.ttf differ
diff --git a/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.660E,6975,73E0,5EA6,8F38,6E05.ttf b/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.660E,6975,73E0,5EA6,8F38,6E05.ttf
new file mode 100644
index 00000000..8468460c
Binary files /dev/null and b/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.660E,6975,73E0,5EA6,8F38,6E05.ttf differ
diff --git a/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.660E.ttf b/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.660E.ttf
new file mode 100644
index 00000000..6b2f5e60
Binary files /dev/null and b/test/subset/data/expected/japanese/Mplus1p-Regular.drop-hints.660E.ttf differ
diff --git a/test/subset/data/fonts/Mplus1p-Regular.ttf b/test/subset/data/fonts/Mplus1p-Regular.ttf
new file mode 100644
index 00000000..2a5205ef
Binary files /dev/null and b/test/subset/data/fonts/Mplus1p-Regular.ttf differ
diff --git a/test/subset/data/tests/japanese.tests b/test/subset/data/tests/japanese.tests
new file mode 100644
index 00000000..5a043801
--- /dev/null
+++ b/test/subset/data/tests/japanese.tests
@@ -0,0 +1,16 @@
+FONTS:
+Mplus1p-Regular.ttf
+
+PROFILES:
+default.txt
+drop-hints.txt
+
+SUBSETS:
+明
+acek
+明極珠度輸清
+あいうえおか
+あいう珠度輸
+
+
+
commit 2ebf4c69b18452caa0c871aebec9785e80348166
Merge: 1ab51480 869ccac5
Author: Garret Rieger <grieger at google.com>
Date: Thu Mar 8 14:41:59 2018 -0700
Merge pull request #868 from googlefonts/post
[subset] Drop glyph names from post when subsetting.
commit 869ccac5ab69060f2db2893014b5538539fd4f45
Author: Garret Rieger <grieger at google.com>
Date: Thu Mar 8 11:06:49 2018 -0800
[subset] use create_sub_blob instead of manually copying the post table.
diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh
index cb1e4eb4..c5ad6654 100644
--- a/src/hb-ot-post-table.hh
+++ b/src/hb-ot-post-table.hh
@@ -84,26 +84,20 @@ struct post
inline bool subset (hb_subset_plan_t *plan) const
{
+ unsigned int post_prime_length;
hb_blob_t *post_blob = OT::Sanitizer<post>().sanitize (hb_face_reference_table (plan->source, HB_OT_TAG_post));
- post *post_table = (post *) hb_blob_get_data (post_blob, nullptr);
+ hb_blob_t *post_prime_blob = hb_blob_create_sub_blob (post_blob, 0, post::static_size);
+ post *post_prime = (post *) hb_blob_get_data_writable (post_prime_blob, &post_prime_length);
+ hb_blob_destroy (post_blob);
- post *post_prime = (post *) malloc (post::static_size);
- if (unlikely (!post_prime))
+ if (unlikely (!post_prime || post_prime_length != post::static_size))
{
- hb_blob_destroy (post_blob);
- DEBUG_MSG(SUBSET, nullptr, "Unable to alloc %lu for post subset output.", (unsigned long) post::static_size);
+ hb_blob_destroy (post_prime_blob);
+ DEBUG_MSG(SUBSET, nullptr, "Invalid source post table with length %d.", post_prime_length);
return false;
}
- memcpy (post_prime, post_table, post::static_size);
- hb_blob_destroy (post_blob);
-
post_prime->version.major.set (3); // Version 3 does not have any glyph names.
- hb_blob_t *post_prime_blob = hb_blob_create ((const char *) post_prime,
- post::static_size,
- HB_MEMORY_MODE_READONLY,
- post_prime,
- free);
bool result = hb_subset_plan_add_table (plan, HB_OT_TAG_post, post_prime_blob);
hb_blob_destroy (post_prime_blob);
commit ec47cd95ba6c550314a1cbcc46fafd7946e52ece
Author: Garret Rieger <grieger at google.com>
Date: Wed Mar 7 10:33:02 2018 -0800
[subset] Unit test to check that post subsetting drops glyph names.
diff --git a/test/api/Makefile.am b/test/api/Makefile.am
index 3c5a5ccf..54e367fa 100644
--- a/test/api/Makefile.am
+++ b/test/api/Makefile.am
@@ -36,6 +36,7 @@ TEST_PROGS = \
test-subset-hdmx \
test-subset-hmtx \
test-subset-os2 \
+ test-subset-post \
test-subset-vmtx \
test-unicode \
test-version \
@@ -47,6 +48,7 @@ test_subset_glyf_LDADD = $(LDADD) $(top_builddir)/src/libharfbuzz-subset.la
test_subset_hdmx_LDADD = $(LDADD) $(top_builddir)/src/libharfbuzz-subset.la
test_subset_hmtx_LDADD = $(LDADD) $(top_builddir)/src/libharfbuzz-subset.la
test_subset_os2_LDADD = $(LDADD) $(top_builddir)/src/libharfbuzz-subset.la
+test_subset_post_LDADD = $(LDADD) $(top_builddir)/src/libharfbuzz-subset.la
test_subset_vmtx_LDADD = $(LDADD) $(top_builddir)/src/libharfbuzz-subset.la
test_unicode_CPPFLAGS = \
diff --git a/test/api/fonts/Mplus1p-Regular.660E,6975,73E0,5EA6,8F38,6E05.ttf b/test/api/fonts/Mplus1p-Regular.660E,6975,73E0,5EA6,8F38,6E05.ttf
index 89c7a1ac..2a978fbd 100644
Binary files a/test/api/fonts/Mplus1p-Regular.660E,6975,73E0,5EA6,8F38,6E05.ttf and b/test/api/fonts/Mplus1p-Regular.660E,6975,73E0,5EA6,8F38,6E05.ttf differ
diff --git a/test/api/test-subset-post.c b/test/api/test-subset-post.c
new file mode 100644
index 00000000..b34e2b7d
--- /dev/null
+++ b/test/api/test-subset-post.c
@@ -0,0 +1,61 @@
+/*
+ * 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): Garret Rieger
+ */
+
+#include <stdbool.h>
+
+#include "hb-test.h"
+#include "hb-subset-test.h"
+
+/* Unit tests for hmtx subsetting */
+
+static void
+test_post_drops_glyph_names (void)
+{
+ hb_face_t *face_full = hb_subset_test_open_font ("fonts/Mplus1p-Regular.660E,6975,73E0,5EA6,8F38,6E05.ttf");
+ hb_face_t *face_subset = hb_subset_test_open_font ("fonts/Mplus1p-Regular.660E.ttf");
+
+ hb_set_t *codepoints = hb_set_create ();
+ hb_set_add (codepoints, 0x660E);
+
+ hb_face_t *face_full_subset = hb_subset_test_create_subset (face_full, hb_subset_test_create_input (codepoints));
+ hb_set_destroy (codepoints);
+
+ hb_subset_test_check (face_subset, face_full_subset, HB_TAG ('p','o','s','t'));
+
+ hb_face_destroy (face_full_subset);
+ hb_face_destroy (face_full);
+ hb_face_destroy (face_subset);
+}
+
+int
+main (int argc, char **argv)
+{
+ hb_test_init (&argc, &argv);
+
+ hb_test_add (test_post_drops_glyph_names);
+
+ return hb_test_run();
+}
commit dd107699938740e261948e4b525fa0ad501beb03
Author: Garret Rieger <grieger at google.com>
Date: Tue Mar 6 18:33:39 2018 -0800
[subset] drop all glyph names from the post table.
diff --git a/src/hb-ot-post-table.hh b/src/hb-ot-post-table.hh
index 9e479211..cb1e4eb4 100644
--- a/src/hb-ot-post-table.hh
+++ b/src/hb-ot-post-table.hh
@@ -82,6 +82,34 @@ struct post
return_trace (true);
}
+ inline bool subset (hb_subset_plan_t *plan) const
+ {
+ hb_blob_t *post_blob = OT::Sanitizer<post>().sanitize (hb_face_reference_table (plan->source, HB_OT_TAG_post));
+ post *post_table = (post *) hb_blob_get_data (post_blob, nullptr);
+
+ post *post_prime = (post *) malloc (post::static_size);
+ if (unlikely (!post_prime))
+ {
+ hb_blob_destroy (post_blob);
+ DEBUG_MSG(SUBSET, nullptr, "Unable to alloc %lu for post subset output.", (unsigned long) post::static_size);
+ return false;
+ }
+
+ memcpy (post_prime, post_table, post::static_size);
+ hb_blob_destroy (post_blob);
+
+ post_prime->version.major.set (3); // Version 3 does not have any glyph names.
+ hb_blob_t *post_prime_blob = hb_blob_create ((const char *) post_prime,
+ post::static_size,
+ HB_MEMORY_MODE_READONLY,
+ post_prime,
+ free);
+ bool result = hb_subset_plan_add_table (plan, HB_OT_TAG_post, post_prime_blob);
+ hb_blob_destroy (post_prime_blob);
+
+ return result;
+ }
+
struct accelerator_t
{
inline void init (hb_face_t *face)
diff --git a/src/hb-subset.cc b/src/hb-subset.cc
index 541987bf..77f60db1 100644
--- a/src/hb-subset.cc
+++ b/src/hb-subset.cc
@@ -41,6 +41,7 @@
#include "hb-ot-hmtx-table.hh"
#include "hb-ot-maxp-table.hh"
#include "hb-ot-os2-table.hh"
+#include "hb-ot-post-table.hh"
#ifndef HB_NO_VISIBILITY
@@ -270,6 +271,9 @@ _subset_table (hb_subset_plan_t *plan,
case HB_OT_TAG_os2:
result = _subset<const OT::os2> (plan);
break;
+ case HB_OT_TAG_post:
+ result = _subset<const OT::post> (plan);
+ break;
default:
hb_blob_t *source_table = hb_face_reference_table(plan->source, tag);
if (likely (source_table))
commit 1ab514805ced190efdabc2103e4800d40b248300
Merge: 70ad69f2 362f2824
Author: Garret Rieger <grieger at google.com>
Date: Wed Mar 7 12:36:00 2018 -0700
Merge pull request #867 from googlefonts/vmtx
[subset] Add vmtx subsetting.
commit 362f28240683fde395ff52f4fc1216fbc7131452
Author: Garret Rieger <grieger at google.com>
Date: Wed Mar 7 11:08:55 2018 -0800
[subset] fix author.
diff --git a/test/api/test-subset-vmtx.c b/test/api/test-subset-vmtx.c
index 79d41df6..ce2b02dc 100644
--- a/test/api/test-subset-vmtx.c
+++ b/test/api/test-subset-vmtx.c
@@ -21,7 +21,7 @@
* ON AN "AS IS" BASIS, AND THE COPYRIGHT HOLDER HAS NO OBLIGATION TO
* PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
*
- * Google Author(s): Roderick Sheeter
+ * Google Author(s): Garret Rieger
*/
#include <stdbool.h>
commit 89465cb1c7b8ab61c0ef4887f51572ba91039f3e
Author: Garret Rieger <grieger at google.com>
Date: Wed Mar 7 10:29:15 2018 -0800
[subset] s/hmetrics/vmetrics.
diff --git a/test/api/test-subset-vmtx.c b/test/api/test-subset-vmtx.c
index f1d94f3a..79d41df6 100644
--- a/test/api/test-subset-vmtx.c
+++ b/test/api/test-subset-vmtx.c
@@ -38,8 +38,8 @@ static void check_num_vmetrics(hb_face_t *face, uint16_t expected_num_vmetrics)
unsigned int vhea_len;
uint8_t *raw_vhea = (uint8_t *) hb_blob_get_data(vhea_blob, &vhea_len);
- uint16_t num_hmetrics = (raw_vhea[vhea_len - 2] << 8) + raw_vhea[vhea_len - 1];
- g_assert_cmpuint(expected_num_hmetrics, ==, num_hmetrics);
+ uint16_t num_vmetrics = (raw_vhea[vhea_len - 2] << 8) + raw_vhea[vhea_len - 1];
+ g_assert_cmpuint(expected_num_vmetrics, ==, num_vmetrics);
hb_blob_destroy (vhea_blob);
hb_blob_destroy (vmtx_blob);
commit 91867cda6ae5ae063482b28b0a52ebc30718cb40
Author: Garret Rieger <grieger at google.com>
Date: Wed Mar 7 10:17:06 2018 -0800
[subset] cleanup.
diff --git a/src/hb-subset.cc b/src/hb-subset.cc
index 0f464854..541987bf 100644
--- a/src/hb-subset.cc
+++ b/src/hb-subset.cc
@@ -253,7 +253,7 @@ _subset_table (hb_subset_plan_t *plan,
result = _subset<const OT::hmtx> (plan);
break;
case HB_OT_TAG_vhea:
- DEBUG_MSG(SUBSET, nullptr, "skip vhea handled by hmtx");
+ DEBUG_MSG(SUBSET, nullptr, "skip vhea handled by vmtx");
return true;
case HB_OT_TAG_vmtx:
result = _subset<const OT::vmtx> (plan);
diff --git a/test/api/test-subset-vmtx.c b/test/api/test-subset-vmtx.c
index 0abab8ca..f1d94f3a 100644
--- a/test/api/test-subset-vmtx.c
+++ b/test/api/test-subset-vmtx.c
@@ -31,12 +31,11 @@
/* Unit tests for hmtx subsetting */
-static void check_num_vmetrics(hb_face_t *face, uint16_t expected_num_hmetrics)
+static void check_num_vmetrics(hb_face_t *face, uint16_t expected_num_vmetrics)
{
hb_blob_t *vhea_blob = hb_face_reference_table (face, HB_TAG ('v','h','e','a'));
hb_blob_t *vmtx_blob = hb_face_reference_table (face, HB_TAG ('v','m','t','x'));
- // TODO I sure wish I could just use the hmtx table struct!
unsigned int vhea_len;
uint8_t *raw_vhea = (uint8_t *) hb_blob_get_data(vhea_blob, &vhea_len);
uint16_t num_hmetrics = (raw_vhea[vhea_len - 2] << 8) + raw_vhea[vhea_len - 1];
commit d9263f0230693d108249be0904bc5a3280560cb3
Author: Garret Rieger <grieger at google.com>
Date: Tue Mar 6 15:40:35 2018 -0800
[subset] add unit tests for vmtx subsetting.
diff --git a/test/api/Makefile.am b/test/api/Makefile.am
index a6ebc57a..3c5a5ccf 100644
--- a/test/api/Makefile.am
+++ b/test/api/Makefile.am
@@ -36,6 +36,7 @@ TEST_PROGS = \
test-subset-hdmx \
test-subset-hmtx \
test-subset-os2 \
+ test-subset-vmtx \
test-unicode \
test-version \
$(NULL)
@@ -46,6 +47,7 @@ test_subset_glyf_LDADD = $(LDADD) $(top_builddir)/src/libharfbuzz-subset.la
test_subset_hdmx_LDADD = $(LDADD) $(top_builddir)/src/libharfbuzz-subset.la
test_subset_hmtx_LDADD = $(LDADD) $(top_builddir)/src/libharfbuzz-subset.la
test_subset_os2_LDADD = $(LDADD) $(top_builddir)/src/libharfbuzz-subset.la
+test_subset_vmtx_LDADD = $(LDADD) $(top_builddir)/src/libharfbuzz-subset.la
test_unicode_CPPFLAGS = \
$(AM_CPPFLAGS) \
diff --git a/test/api/fonts/Mplus1p-Regular.660E,6975,73E0,5EA6,8F38,6E05.ttf b/test/api/fonts/Mplus1p-Regular.660E,6975,73E0,5EA6,8F38,6E05.ttf
new file mode 100644
index 00000000..89c7a1ac
Binary files /dev/null and b/test/api/fonts/Mplus1p-Regular.660E,6975,73E0,5EA6,8F38,6E05.ttf differ
diff --git a/test/api/fonts/Mplus1p-Regular.660E.ttf b/test/api/fonts/Mplus1p-Regular.660E.ttf
new file mode 100644
index 00000000..3e32c891
Binary files /dev/null and b/test/api/fonts/Mplus1p-Regular.660E.ttf differ
diff --git a/test/api/test-subset-vmtx.c b/test/api/test-subset-vmtx.c
new file mode 100644
index 00000000..0abab8ca
--- /dev/null
+++ b/test/api/test-subset-vmtx.c
@@ -0,0 +1,100 @@
+/*
+ * 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): Roderick Sheeter
+ */
+
+#include <stdbool.h>
+
+#include "hb-test.h"
+#include "hb-subset-test.h"
+
+/* Unit tests for hmtx subsetting */
+
+static void check_num_vmetrics(hb_face_t *face, uint16_t expected_num_hmetrics)
+{
+ hb_blob_t *vhea_blob = hb_face_reference_table (face, HB_TAG ('v','h','e','a'));
+ hb_blob_t *vmtx_blob = hb_face_reference_table (face, HB_TAG ('v','m','t','x'));
+
+ // TODO I sure wish I could just use the hmtx table struct!
+ unsigned int vhea_len;
+ uint8_t *raw_vhea = (uint8_t *) hb_blob_get_data(vhea_blob, &vhea_len);
+ uint16_t num_hmetrics = (raw_vhea[vhea_len - 2] << 8) + raw_vhea[vhea_len - 1];
+ g_assert_cmpuint(expected_num_hmetrics, ==, num_hmetrics);
+
+ hb_blob_destroy (vhea_blob);
+ hb_blob_destroy (vmtx_blob);
+}
+
+static void
+test_subset_vmtx_simple_subset (void)
+{
+ hb_face_t *face_full = hb_subset_test_open_font ("fonts/Mplus1p-Regular.660E,6975,73E0,5EA6,8F38,6E05.ttf");
+ hb_face_t *face_subset = hb_subset_test_open_font ("fonts/Mplus1p-Regular.660E.ttf");
+
+ hb_set_t *codepoints = hb_set_create ();
+ hb_set_add (codepoints, 0x660E);
+
+ hb_face_t *face_full_subset = hb_subset_test_create_subset (face_full, hb_subset_test_create_input (codepoints));
+ hb_set_destroy (codepoints);
+
+ check_num_vmetrics(face_full_subset, 1); /* nothing has same width */
+ hb_subset_test_check (face_subset, face_full_subset, HB_TAG ('v','m','t','x'));
+
+ hb_face_destroy (face_full_subset);
+ hb_face_destroy (face_full);
+ hb_face_destroy (face_subset);
+}
+
+static void
+test_subset_vmtx_noop (void)
+{
+ hb_face_t *face_full = hb_subset_test_open_font ("fonts/Mplus1p-Regular.660E,6975,73E0,5EA6,8F38,6E05.ttf");
+
+ hb_set_t *codepoints = hb_set_create();
+ hb_set_add (codepoints, 0x660E);
+ hb_set_add (codepoints, 0x6975);
+ hb_set_add (codepoints, 0x73E0);
+ hb_set_add (codepoints, 0x5EA6);
+ hb_set_add (codepoints, 0x8F38);
+ hb_set_add (codepoints, 0x6E05);
+ hb_face_t *face_full_subset = hb_subset_test_create_subset (face_full, hb_subset_test_create_input (codepoints));
+ hb_set_destroy (codepoints);
+
+ check_num_vmetrics(face_full_subset, 1); /* all have the same width */
+ hb_subset_test_check (face_full, face_full_subset, HB_TAG ('v','m','t','x'));
+
+ hb_face_destroy (face_full_subset);
+ hb_face_destroy (face_full);
+}
+
+int
+main (int argc, char **argv)
+{
+ hb_test_init (&argc, &argv);
+
+ hb_test_add (test_subset_vmtx_simple_subset);
+ hb_test_add (test_subset_vmtx_noop);
+
+ return hb_test_run();
+}
commit 0e8f9430c83c076993a0c7a320713bb484051343
Author: Garret Rieger <grieger at google.com>
Date: Tue Mar 6 13:08:20 2018 -0800
[subset] Skip subsetting vhea.
diff --git a/src/hb-subset.cc b/src/hb-subset.cc
index e2d9a89d..0f464854 100644
--- a/src/hb-subset.cc
+++ b/src/hb-subset.cc
@@ -252,6 +252,9 @@ _subset_table (hb_subset_plan_t *plan,
case HB_OT_TAG_hmtx:
result = _subset<const OT::hmtx> (plan);
break;
+ case HB_OT_TAG_vhea:
+ DEBUG_MSG(SUBSET, nullptr, "skip vhea handled by hmtx");
+ return true;
case HB_OT_TAG_vmtx:
result = _subset<const OT::vmtx> (plan);
break;
commit 64cf53d6197a0e6c56aef744ceff2f8a0ff85654
Author: Garret Rieger <grieger at google.com>
Date: Fri Mar 2 17:33:49 2018 -0800
[subset] Subset vmtx if present.
diff --git a/src/hb-ot-hmtx-table.hh b/src/hb-ot-hmtx-table.hh
index 3cd48a62..bff792a6 100644
--- a/src/hb-ot-hmtx-table.hh
+++ b/src/hb-ot-hmtx-table.hh
@@ -264,7 +264,7 @@ struct hmtxvmtx
{
advance += (font->num_coords ? var_table->get_advance_var (glyph, font->coords, font->num_coords) : 0); // TODO Optimize?!
}
- return advance;
+ return advance;
}
public:
diff --git a/src/hb-subset.cc b/src/hb-subset.cc
index 9ebe5d31..e2d9a89d 100644
--- a/src/hb-subset.cc
+++ b/src/hb-subset.cc
@@ -252,6 +252,9 @@ _subset_table (hb_subset_plan_t *plan,
case HB_OT_TAG_hmtx:
result = _subset<const OT::hmtx> (plan);
break;
+ case HB_OT_TAG_vmtx:
+ result = _subset<const OT::vmtx> (plan);
+ break;
case HB_OT_TAG_maxp:
result = _subset<const OT::maxp> (plan);
break;
More information about the HarfBuzz
mailing list