[subset] add one empty byte to glyf table

if it's going to end up empty after subsetting
This will make OTS happy and match what fontTools is doing now.
This commit is contained in:
Qunxin Liu 2020-02-18 13:09:08 -08:00 committed by Ebrahim Byagowi
parent a7dec0cb51
commit 493e40ff78
5 changed files with 12 additions and 0 deletions

View File

@ -149,7 +149,19 @@ struct glyf
const hb_subset_plan_t *plan)
{
TRACE_SERIALIZE (this);
unsigned init_len = c->length ();
for (const auto &_ : it) _.serialize (c, plan);
/* As a special case when all glyph in the font are empty, add a zero byte
* to the table, so that OTS doesnt reject it, and to make the table work
* on Windows as well.
* See https://github.com/khaledhosny/ots/issues/52 */
if (init_len == c->length ())
{
HBUINT8 empty_byte;
empty_byte = 0;
c->copy (empty_byte);
}
return_trace (true);
}