Closed Wildhoney closed 4 years ago
There is already the check to see if the endChar is a printable characters, see https://github.com/Pomax/Font.js/blob/master/Font.js#L412, and from the looks of https://github.com/Pomax/Font.js/blob/master/Font.js#L402 it seems that list is simply missing 0x81 and 0x82 (which are control codes, not actually printable characters) so extending that list with the two codes that are missing should help towards fixing the problem you're experiencing.
https://github.com/Pomax/Font.js/commit/3c8658627c0709e297cc32702fdf01db04a41307 should have fixed this, can you verify this is no longer a problem?
Nope – that didn't fix it. It's now using an endChar
of 144
.
Could you check the font please to ensure it's not doing something odd?
Works when you add 0x0090
to the list:
return [0x0009,0x000A,0x000B,0x000C,0x000D,0x0020,0x0081,0x0082,
0x0085,0x0090,0x00A0,0x1680,0x180E,0x2000,0x2001,0x2002,
0x2003,0x2004,0x2005,0x2006,0x2007,0x2008,0x2009,0x200A,
0x2028,0x2029,0x202F,0x205F,0x3000].indexOf(chr) === -1; }
Although I'm not sure if that's recommended. With 0x0090
added, the endChar
is 255
and everything proceeds just fine.
it looks like there's a fair number of control codes missing. https://github.com/Pomax/Font.js/commit/710ea5c7287c41c9cc994c813ecf782110d175f2 adds all reasonable control codes, so with that, things should be fine.
:+1: Could you add a bower.json
when you release next, please?
I'm not a fan of bower, but I can throw it up on npm quite easily (and if you have bower, you have npm already)
Don't worry. I'll keep installing it via Bower without the bower.json
file.
Got similar issue, chr = 29. Just added condition chr > 32
to printable
Except that is a plain wrong condition, as just being "abover the space" in no way guarantees a character is printable. Have you tried the latest Font.js from this repo?
obsolete with the 2019 rewrite
It seems that the
printChar
it uses for testing the font is an empty string (""
).On line 425:
Where
endChar
is129
for the following Optima TTF font.I assume the fix in this instance is to detect if the yielded
printChar
is empty, and if so, to revert to theprintChar
default ofA
.