Differences in glyph advances with new/old T1 engine
I have encountered an issue with FreeType 2.10.4 relating to the new T1 engine.
In the MuPDF project we recently used FreeType 2.10.2 and had a downstream workaround for issue 57519 (from your old bug tracker). We used to set T1_CONFIG_OPTION_OLD_ENGINE
while waiting for 57519 to be fixed.
I attempted to upgrade our FreeType usage to 2.10.4 and while doing so reverted our workaround since 2.10.4 includes the fix for 57519. While doing so I discovered rendering differences in several PDFs.
The attached font is from one of the PDFs. The attached test program exhibits one difference between having the workaround (setting T1_CONFIG_OPTION_OLD_ENGINE
) and not having it (using your new T1 engine). I'm hoping that this is the underlying problem causing the rendering difference in all the PDFs.
First I compile two variants of FreeType at git tag VER-2-10-4 like so:
cd freetype-old-engine
CFLAGS=-DT1_CONFIG_OPTION_OLD_ENGINE ./autogen.sh
CFLAGS=-DT1_CONFIG_OPTION_OLD_ENGINE ./configure --prefix=$PWD/installed
make install
cd..
cd freetype-new-engine
./autogen.sh
./configure --prefix=$PWD/installed
make install
cd..
Then I compile my test program like this:
gcc -O0 -g -o testing -Ifreetype-old-engine/installed/include/freetype2/ -I/usr/include/libpng16 testing.c -Lfreetype-old-engine/installed/lib/ -lfreetype
Finally I run the test program with the supplied font like so (I pipe through head to not be overwhelmed with output):
diff -u <(LD_LIBRARY_PATH=freetype-old-engine/installed/lib/ ./testing font.pfb | head) <(LD_LIBRARY_PATH=freetype-new-engine/installed/lib/ ./testing font.pfb | head)
and get the following relevant output:
@@ -1,10 +1,10 @@
-glyph 0: advance = 188 name = .notdef
-glyph 1: advance = 197 name = exclam
-glyph 2: advance = 258 name = quotedbl
-glyph 3: advance = 590 name = numbersign
-glyph 4: advance = 509 name = dollar
-glyph 5: advance = 574 name = percent
-glyph 6: advance = 599 name = ampersand
-glyph 7: advance = 131 name = quoteright
-glyph 8: advance = 314 name = parenleft
-glyph 9: advance = 314 name = parenright
+glyph 0: advance = 0 name = .notdef
+glyph 1: advance = 0 name = exclam
+glyph 2: advance = 0 name = quotedbl
+glyph 3: advance = 0 name = numbersign
+glyph 4: advance = 0 name = dollar
+glyph 5: advance = 0 name = percent
+glyph 6: advance = 0 name = ampersand
+glyph 7: advance = 0 name = quoteright
+glyph 8: advance = 0 name = parenleft
+glyph 9: advance = 0 name = parenright
From this it is appears that depending on whether T1_CONFIG_OPTION_OLD_ENGINE
is set FT_Get_Advance()
returns different advances.