Incorrect glyph stretching and positioning when rendering at different x and y resolutions.
Migrated from: [SAVANNAH-58990]
Anonymous reported:
The attached program main.c is modified from https://www.freetype.org/freetype2/docs/tutorial/example1.c. Compile it with
gcc $(pkg-config --cflags --libs freetype2) main.c -o main
and run it with
./main /path/to/FreeSerif.ttf
where FreeSerif.ttf can be downloaded from http://ftp.gnu.org/gnu/freefont/freefont-ttf-20120503.zip (the specific release of FreeFont is important!).
The program loads two glyphs (codepoints 0x21d0 and 0x21d1, glyphs arrowdblleft and arrowdblup) and renders them at 200dpi horizontal resolution and 100dpi vertical resolution. The result (bad.txt) shows that while the horizontal arrow is correctly stretched by a factor of 2 in x, the vertical arrow is incorrectly stretched in y instead, and also badly centered in y.
Interestingly, additionally passing FT_LOAD_FORCE_AUTOHINT to the FT_Load_Char call fixes the problem (good.txt): now the vertical arrow is correctly stretched in x as well, and correctly centered in y. One may thus be led to believe that the font's native hinter perhaps(?) badly fails when hinting with different x and y resolutions. However, passing FT_LOAD_NO_HINTING instead of FT_LOAD_FORCE_AUTOHINT does not fix the problem, and yields results similar to bad.txt, so that suggests it's not the font's native hinter's fault.
This bug was originally reported at https://lists.nongnu.org/archive/html/freetype/2020-08/msg00004.html, in response it was suggested that this may also be related to https://savannah.nongnu.org/bugs/?55001.