Bug 690629 - Cannot build pdf_unicode.c with FreeType <2.2
Summary: Cannot build pdf_unicode.c with FreeType <2.2
Status: RESOLVED FIXED
Alias: None
Product: MuPDF
Classification: Unclassified
Component: mupdf (show other bugs)
Version: unspecified
Hardware: All Linux
: P4 normal
Assignee: Tor Andersson
URL: http://code.google.com/p/sumatrapdf/i...
Keywords:
Depends on:
Blocks:
 
Reported: 2009-07-13 15:19 UTC by José Manuel Ferrer Ortiz
Modified: 2009-07-16 09:34 UTC (History)
0 users

See Also:
Customer:
Word Size: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description José Manuel Ferrer Ortiz 2009-07-13 15:19:29 UTC
I've resubmitted my report from sumatrapdf bug tracker
(http://code.google.com/p/sumatrapdf/issues/detail?id=577), since it seems it
belongs here (read kkowalczyk comment in that bug tracker).

"What steps will reproduce the problem?"
1. Make sure your FreeType version is lower than 2.2 (I used 2.1.10)
2. Run 'jam' on 'fitz' folder, to try to build fitz apps
3. Wait for the below error to come


"What is the expected output? What do you see instead?"

Expected output (pdf_unicode.c successfully compiled):

(...)
Cc build/pdf_unicode.o                          
Archive build/libmupdf.a
(...)

Error output (pdf_unicode.c doesn't compile well):

(...)
Cc build/pdf_unicode.o                    
mupdf/pdf_unicode.c:22:10: #include expects "FILENAME" or <FILENAME>
mupdf/pdf_unicode.c: In function `extracttext':                     
mupdf/pdf_unicode.c:269: warning: implicit declaration of function
`FT_Get_Advance'                                                          
                  

/usr/local/gp2xsdk/arm-gp2x-linux/bin/gcc -c -o build/pdf_unicode.o
-Wall -std=gnu99 -I/usr/local/gp2xsdk/include/freetype2
-I/usr/local/gp2xsdk/include -mcpu=arm920t -mtune=arm920t -O2
-fomit-frame-pointer -Imupdf -Ifitz -Imupdf -Iapps mupdf/pdf_unicode.c            
                                 

...failed Cc build/pdf_unicode.o ...
(...)


I see the problem is in the preprocessor code at the beginning of
pdf_unicode.c, that checks if FreeType version is lower than 2.3.8, since
that version and later include the function FT_Get_Advance.

Instead of checking a version lower than 2.3.8, what it really does is to
just check if it's in the range [2.2, 2.3.8[ (2.2 included, 2.3.8 excluded).

I made a patch to change the range [2, 2.3.8[ (2 included, 2.3.8 excluded
instead). Here you are the patch in unified format:

--- fitz-svn/mupdf/pdf_unicode.c        2009-07-13 17:11:16.000000000 +0200
+++ fitz/mupdf/pdf_unicode.c    2009-07-13 23:04:58.000000000 +0200
@@ -4,8 +4,8 @@
 #include <ft2build.h>
 #include FT_FREETYPE_H

-#if ((FREETYPE_MAJOR == 2) && (FREETYPE_MINOR == 2)) || \
-    ((FREETYPE_MAJOR == 2) && (FREETYPE_MINOR == 3) && (FREETYPE_PATCH < 8))
+#if ((FREETYPE_MAJOR == 2) && \
+    ((FREETYPE_MINOR < 3) || ((FREETYPE_MINOR == 3) && (FREETYPE_PATCH < 8))))

 int FT_Get_Advance(FT_Face face, int gid, int masks, FT_Fixed *out)
 {
Comment 1 José Manuel Ferrer Ortiz 2009-07-13 15:21:44 UTC
This bug applies to all platforms, I was cross compiling from AMD64 Gentoo Linux
to GP2X's ARM Linux.
Comment 2 Tor Andersson 2009-07-16 09:34:40 UTC
I wasn't aware that people were still using 2.1 :)

Your proposed patch will break once freetype 2.4 is released.
I've commited another fix that explicitly tests for 2.1. MuPDF
can't work with anything older than 2.1.7 anyway (too many bugs
with CFF and Type1 fonts in earlier releases).