kreativekorp / bitsnpicas

Bits'N'Picas - Bitmap & Emoji Font Creation & Conversion Tools
339 stars 23 forks source link

Conversion to ttf sometimes produces self-intersecting glyphs #4

Closed Mikolaj closed 5 years ago

Mikolaj commented 5 years ago

First, let me thank you for this tool. It's totally unique and was very helpful to me.

Now, this is not critical, but it sometimes produces self-intersecting glyphs, e.g., on

https://github.com/LambdaHack/LambdaHack/blob/13d885253bc1f0bf844ecde7a3733ffddc165a2d/GameDefinition/fonts/16x16xw.bdf

This can be later fixed by hand, e.g., by stretching the font via Metric/Set Width [Edit: or it might have been via Style/Condense/Extend, I don't remember] in fontforge to a few pixels more than the default, and then handling the fallout. The result (with some other fuzz) is at

https://github.com/LambdaHack/LambdaHack/blob/13d885253bc1f0bf844ecde7a3733ffddc165a2d/GameDefinition/fonts/16x16xw.woff

RebeccaRGB commented 5 years ago

This is expected and intentional. When two pixels touch diagonally, the corresponding corner points of the resulting contours have the exact same coordinates and FontForge reports this as a self-intersection. Normally when designing a vector glyph a self-intersection is undesirable and indicates a potential issue; when designing a bitmap glyph, however, you want to adhere to a strict pixel grid. Whatever transformation you performed made some of the "pixels" ever-so-slightly non-uniform and therefore it's no longer a perfect bitmap font.

(Personally I think FontForge's default behavior here is wrong, and it should complain about self-intersections only if the intersecting area is nonzero, and not if points just touch.)

Mikolaj commented 5 years ago

Thank you very much for looking into this. I'm not so much upset that FontForge yells at me, but that browsers and other software supposedly may render such fonts incorrectly. If that's not your experience, I'm less worried. Oh, I see there's even a FontForge ticket about that and it sounds reassuring: https://github.com/fontforge/fontforge/issues/3456