[glyf] Allow empty, none-zero size table
Fixes https://github.com/khaledhosny/ots/issues/52
diff --git a/src/glyf.cc b/src/glyf.cc
index 15a362c..8f9f58a 100644
--- a/src/glyf.cc
+++ b/src/glyf.cc
@@ -270,6 +270,16 @@
}
loca->offsets = resulting_offsets;
+
+ if (this->iov.empty()) {
+ // As a special case when all glyph in the font are empty, add a zero byte
+ // to the table, so that we don’t reject it down the way, and to make the
+ // table work on Windows as well.
+ // See https://github.com/khaledhosny/ots/issues/52
+ static const uint8_t kZero = 0;
+ this->iov.push_back(std::make_pair(&kZero, 1));
+ }
+
return true;
}
diff --git a/tests/fonts/bad/7ee3cdda8571ff1e51aa081825f72cd0a545e052.ttf b/tests/fonts/bad/7ee3cdda8571ff1e51aa081825f72cd0a545e052.ttf
new file mode 100644
index 0000000..e526105
--- /dev/null
+++ b/tests/fonts/bad/7ee3cdda8571ff1e51aa081825f72cd0a545e052.ttf
Binary files differ
diff --git a/tests/fonts/good/b3590210e2baa7fb6c58af1ce98d383d8bf47683.ttf b/tests/fonts/good/b3590210e2baa7fb6c58af1ce98d383d8bf47683.ttf
new file mode 100644
index 0000000..e78f52a
--- /dev/null
+++ b/tests/fonts/good/b3590210e2baa7fb6c58af1ce98d383d8bf47683.ttf
Binary files differ
diff --git a/tests/fonts/good/b98ec6ce1630f86eb34d18666002676498618717.ttf b/tests/fonts/good/b98ec6ce1630f86eb34d18666002676498618717.ttf
new file mode 100644
index 0000000..0ef34b9
--- /dev/null
+++ b/tests/fonts/good/b98ec6ce1630f86eb34d18666002676498618717.ttf
Binary files differ
diff --git a/tests/fonts/good/d391cf982a114ea43871890da047df4a7b5a087b.ttf b/tests/fonts/good/d391cf982a114ea43871890da047df4a7b5a087b.ttf
new file mode 100644
index 0000000..7492547
--- /dev/null
+++ b/tests/fonts/good/d391cf982a114ea43871890da047df4a7b5a087b.ttf
Binary files differ