FreeType backend enhancement for Rasterization tests #5
Comments
Implementing the whole 60 errors and dozen warnings from the closed source MS renderer seems daunting; so I looked into what is achievable/possible. Last summer I collected the test results of the 2003 binary against the fonts in win 8.1. The errors and warnings shown is actually a very restricted set: warnings: errors: "Instruction is only valid on the Apple platform" was determined to be bogus in previous private discussion with Werner. Out of this small list, "RP1 and RP2 have the same position on the projection vector" seems the obvious one to look at, as it is much more frequent by far, 90% of errors by instances, and also by other metrices (fonts involved, etc). grep'ing for 'rp1' in freetype sources show that back in Feb 2013, a very localized change in Freetype was made to make it cope with such brokenness in fonts to match the MS renderer's exact behavior. So here is a plan: at exactly the same condition, a diagnostic enhanced Freetype should abort and return an error detail, instead of silently carrying on and working around brokenness in fonts. This goes towards implementing a test on already fairly well-behaved fonts, to make them even better - there are much more serious brokenness, I am sure, but it is a beginning to start something. |
Turned out that the code which silently works around the "Projection and freedom vectors at or near perpendicular" condition was in freetype 2 at the initial commit, so it was in Freetype 1 for nearly 20 years. It is this section in Compute_Funcs:
but the MS Rasterer seems to only warn when this condition happens inside Direct_Move, which is narrower. |
Out of the 7:
the rest:
So out of the 7, 1 is bogus, 5 freetype already detects and silently copes (2 have an "XXX undocumented), 1 I haven't figure out how to do. |
To detect whether the current glyph is composite is just "exc->is_composite", and calling from pre-program is "exc->curRange == tt_coderange_font" . So I seem to be able to add all 6 diagnostics. |
Fonts on fedora 24 at Size 10, show these 18 codes, and took just over 7 hours to run:
|
It took just over 7 hours. So a standard run, all sizes from size 4 to 72 plus a few higher ones, would take about 3-4 weeks on my computer. And only about 2/3 passes cleanly at this level (testing for more sizes would lower it slightly). |
Nice! |
The possible rasterization errors shown by Mac OS X 10.9.5 shipped fonts at size 10 are:
The number of font files which pass the rasterization test at size 10 is 360/695, or a little over half of them. It took just under 3 hours to analyse all of apple shipped fonts at size 10. The actual proportion of number of fonts which pass is lower - many of them cause the 2003 binary to crash, and therefore not generating a report (i.e. outside the 695). |
I have always suspected my private stash of (largely CJK) fonts are rather buggy, so after nearly 12 hours, testing just for size 10, I get a few more exotic errors:
12 hours at size 10 is about 5-6 weeks for a standard run. The combined list of apple shipped + fedora shipped + my private stash are:
|
So I have 33 error status (the 32 above, plus 'Not called from pre-program'). The 44 which I don't have a test file are:
|
Besides those, I seem to have 23 from fedora, 4 from apple and 90 from my private collection, that is 117 font files in total , which can crash the the rasterization test part of the older Font Val without it writing a report behind. |
"Storage index out of range" (one of the errors without a test file) is the bound check in Write Store. Number 34. |
""Zone not 0 nor 1" is the bound check in Shift Zone. Number 35. |
"E6050 | Value invalid should be 0 or 1" and "E6051 | Value invalid should be 0 or 2" both correspond to the 2nd pedantic check in INSTCTRL. The description for "E6052 | Value out of range" in the documentation is a bit vague, but judging from the proximty, it has to be either the same place (i.e. <0 or >3) or the first pedantic check in the same routine in freetype. So that's number 38, and the first time a silent check in FreeType catches 3 different errors that Font Val catches... |
"W6012 | Function no longer needed because of dropped support of AA" is the "/* instruction not supported anymore */" comment in the code. Number 39. "E6030 | Attempt to access stack element out of range" is the bedantic check in MINDEX and CINDEX. Number 40. "E6034 | Jump before beginning of program or function" and "E6012 | ENDF found without FDEF or IDEF" is Freetype's ENDF_In_Exec_Stream error. Number 43. "E6014 | FDEF found within FDEF - ENDF pair" W6003 | DEBUG found which should not be found in production code |
Argh, E6013 is easy. Number 50. Missed it in the new release. E6018/E6023 - Number 52. |
The 26 outside b51 are
3 have test files:
7 looks well-defined and possibly implementable (though may not be easy):
5 already happens in/outside the font engine or not need "implementing":
That leaves 11 which are lacking test files as well as descriptions, and contexts of where and how they happen:
Some of these might be do'able:
So it might go up from 51 to 3 + 7 + 3 = 64, and there are 5 not needing attention & 8 not likely. |
The 117 missing is partly due to name collision. The problem of collision get worse with bulk test sizes. for 691 files, 4 collided; 1753 files, 22; and 2041 files, 32. That accounts for 58 of the 117, or just half of those. Another 59 is due to something else. |
B54 tagged "FontVal 2.0" includes W6000, E6010, E6011 in addition to the b51 details above. @anthrotype @davelab6 @aaronbell Am closing this issue now. This is getting too long, and the rest can become new individual issues. |
Sounds good man :)
|
fval.xsl: fix xsl for Firefox, fix JS for checkboxes. The fixes here look good as far as I can tell.
The code for the MS font renderer was removed and not opened. In any case, it (at least the 2003 version) chokes on about 10% of Mac OS X shipped fonts, so the situation is begging for an update and replacement.
Basic interaction is already established with a FreeType backend for HDMX/LTSH/VDMX tests. The MS font renderer is capable of detecting about 60 errors and 14 warnings for glyph byte-code instructions.
FreeType is currently only capable of detecting only a subset of these, and also only under debug conditions. There is further work to make FreeType detecting a bigger proportion of these, and also some API change/addition to obtain that information in a normal release build.
See also the notes on the hybrid branch.
The text was updated successfully, but these errors were encountered: