[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Incorrect glyph stretching and positioning when rendering at different x

From: Antony Lee
Subject: Incorrect glyph stretching and positioning when rendering at different x and y resolutions.
Date: Sun, 16 Aug 2020 22:42:57 +0200

Hi all,

The attached program main.c is modified from  Compile it

    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 (the specific
release of FreeFont is important!).

The program loads two glyphs (codepoints 0x21d0 LEFTWARDS DOUBLE ARROW and
0x21d1 UPWARDS DOUBLE ARROW) 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.

I'm not really sure whether this behavior is a bug in FreeType or perhaps a
problem with the font...  Thanks in advance for your insights,

Antony Lee

Attachment: bad.txt
Description: Text document

Attachment: main.c
Description: Text Data

Attachment: good.txt
Description: Text document

reply via email to

[Prev in Thread] Current Thread [Next in Thread]