glyb icon indicating copy to clipboard operation
glyb copied to clipboard

MSDF rendered glyphs have incorrect vertical and horizontal registration

Open michaeljclark opened this issue 4 years ago • 0 comments

There appears to be a rounding bug in msdfgen which causes glyphs to have incorrect vertical and horizontal registration. Look at the position of the u relative to the m in the attached image. FreeType on the left versus MSDF on the right.

image

MSDF has been disabled by default in glfont da5d92014a34977806ed19aeb694fc00965c1a4b primarily to log the issue in the commit history. MSDF is currently enabled in most of the examples. The metrics used to calculate the glyph bounds are the same. It is likely that msdfgen has a slightly different scaling of the contours than FreeType so the fix possibly requires making changes to msdfgen.

The FreeType metrics:

https://github.com/michaeljclark/glyb/blob/da5d92014a34977806ed19aeb694fc00965c1a4b/src/glyph.cc#L575-L580

The MSDF metrics:

https://github.com/michaeljclark/glyb/blob/da5d92014a34977806ed19aeb694fc00965c1a4b/src/msdf.cc#L147-L153

michaeljclark avatar Jun 15 '21 22:06 michaeljclark