Closed yisibl closed 3 years ago
AFAIK term "wrong" is not precise:
Questions:
Chrome and Firefox use OpenType Sanitizer to detect fonts, the code is here: https://github.com/khaledhosny/ots/blob/ff09cd0b6b0dd210a4c1bafd61fcbbba21738751/src/head.cc#L66-L73
if (this->xmin > this->xmax) {
return Error("Bad x dimension in the font bounding box (%d, %d)",
this->xmin, this->xmax);
}
if (this->ymin > this->ymax) {
return Error("Bad y dimension in the font bounding box (%d, %d)",
this->ymin, this->ymax);
}
Glyf table also has related checks: https://github.com/khaledhosny/ots/blob/f2c7b32198080b6cce338a72beef8f0ebbc2db96/src/glyf.cc#L282-L293
// workaround for fonts in http://www.princexml.com/fonts/
if ((xmin == 32767) &&
(xmax == -32767) &&
(ymin == 32767) &&
(ymax == -32767)) {
Warning("bad xmin/xmax/ymin/ymax values");
xmin = xmax = ymin = ymax = 0;
}
if (xmin > xmax || ymin > ymax) {
return Error("Bad bounding box values bl=(%d, %d), tr=(%d, %d) in glyph %d", xmin, ymin, xmax, ymax, i);
}
At first glance, those checks are not actual for svg2ttf. I mean, load errors happened due different checks. Or, probably i miss something.
I mean, condition xmin > xmax
can not happen.
In the txt dump above xmin is 0 and xmax is negative, so xmin is greater than xmax.
Hm... strange, i will check. Thanks for clarification.
Yes, it is precisely because the font generated by svg2ttf has xMin> xMax
that it will trigger OpenType Sanitizer to report an error.
<xMin value="0"/>
<xMax value="-3072"/>
The very first instruction in the svg path is M62464
, which is exactly what xMax is calculated to be.
The field type allocated to it is: signed int16. We write 62464 there, which is the same as -3072 (62464+3072=65536).
So we have two issues here:
What do you expect svg2ttf to do here? Would an error (if glyph boundaries fall outside of ±32767) be enough?
Fixed, now this font should output an error.
Looks good, thanks!
Published 6.0.2
Here is a simple example to help us improve the bounding box of the generated font.
SVG file:
OpenType Sanitizer error prompt:
Font Table