I'd like to at least know how many glyphs are affected. Do to that, I
figured I'd write some PostScript code to iterate through the glyphs
and test for self-intersecting outlines. I've done a lot of
PostScript programming over the years, but not so much with TrueType
fonts. Is there an easy way to embed this large TTF so that I can
iterate through it's characters?
Also, is there a straightforward way to check for self intersections
in the outline? As brute force, I could flatten the outline and test
each segment against each other segment, but I thought someone might
have a clever easier way, perhaps using insideness testing.
Thanks!
-pd
Problem 1; PostScript doesn't support TrueType fonts.
It does support type 42 fonts, and CIDFonts with type 42 outlines, but
not actual TrueType fonts. That said, many PostScript interpreters will
allow you to load a native disk-based TrueType font as some form of
PostScript font, usually a CIDFont with Type 42 outlines.
However, this is always implementation-dependent, because its not part
of the specification. So you may or may not get access to the entire
glyph range of the font. The actual glyph range available may depend on
some implementation-specific detail, and it may change depending how the
font has been mapped internally in the RIP.
Assuming the font is available as a Type 2 CIDFont (Type 42 outlines),
you could use the CIDCoutn and/or CIDMap. The internals of the font
dictionary should contain:
/CIDCount <integer>
/GDBytes <integer>
/CIDMap <string|array>
The font contains glyphs with CIDs from 0 to CIDCount-1 (warning not all
glyphs need be present!). So you could simply iterate the CIDs using
glyphshow.
You could instead read the CIDMap whish is either a string or array of
strings, CIDCountxGDBytes in size. Each 'GDBytes' in the string is the
Glyph ID of the TrueType glyph which is stored in the sfnts array. GID
is the TrueType .notdef, which you could skip if you like.
I would recommend you use the Microsoft Font Validator tool
(http://www.microsoft.com/typography/developers/validator/). This uses
the actual TrueType font, and the glyf table tests include (among other
things) a test for self-intersection. Here's an example from a run I
made on msmincho.ttc:
W1112 Not all extremes are marked with the on-curve control points Glyph
index 871
E1111 Intersecting contours Glyph index 871
A1111 Unable to perform test due to previously detected errors Glyph
index 871 Test: ValidateSimpContMisor
W1112 Not all extremes are marked with the on-curve control points
Glyph index 872
FWIW I counted 26 occurences in 17,727 glyphs in the report.
Ken
Thanks, Ken. I should have been more explicit. I was assuming I'd
have to convert the font into a CID-keyed font with a set of CIDfonts
containing the glyphs. I'm not aware of a good, free tool for doing
that though.
> I would recommend you use the Microsoft Font Validator tool
> (http://www.microsoft.com/typography/developers/validator/).
Thanks very much for this! It looks promising, that link doesn't get
me to the software. The referenced page says I have to apply to join
the MS Font Validator Community, but *that* link appears to be a dead
end: "The MSN Groups service has closed"
Thanks!
-pd
Sorry, I forgot they'd changed it....
Ken
No problem.
The validator, however, appears to do a very crude test for self
intersection. As far as I can tell, it merely rasterizes the glyphs
at various resolutions, and tests whether any of the pixels gets
written more than once. That's not terribly useful (unless you're
drawing the glyphs in XOR mode, I guess). It doesn't tell you whether
the actual outlines cross each other.
Thanks,
-pd