Commit e571dcbf authored by Albert Astals Cid's avatar Albert Astals Cid

Merge the xpdf 3.01 change that uses runtime detection of freetype version

parent 59fe2937
2005-09-16 Albert Astals Cid <aacid@kde.org>
* configure.ac
* splash/SplashFTFontEngine.[cc|h]
* poppler/CairoFontEngine.[cc|h]: Merge the xpdf 3.01 change that uses
runtime detection of freetype version
2005-09-15 Albert Astals Cid <aacid@kde.org>
* poppler/: Some minor merges from xpdf 3.01
......
......@@ -131,31 +131,23 @@ AH_TEMPLATE([ENABLE_LIBJPEG],
dnl Check for freetype headers
FREETYPE_LIBS=
FREETYPE_CFLAGS=
FREETYPE_MIN_VERSION=9.5.3
PKG_CHECK_MODULES(FREETYPE, freetype2 >= $FREETYPE_MIN_VERSION,
PKG_CHECK_MODULES(FREETYPE, freetype2,
[freetype_pkgconfig=yes], [freetype_pkgconfig=no])
if test "x$freetype_pkgconfig" = "xyes"; then
AC_DEFINE(HAVE_FREETYPE_H, 1, [Have FreeType2 include files])
AC_DEFINE_UNQUOTED(HAVE_FREETYPE_217_OR_OLDER, 0, [Defines if your system has the freetype library 2.1.7 or older])
else
AC_PATH_PROG(FREETYPE_CONFIG, freetype-config, no)
if test "x$FREETYPE_CONFIG" != "xno" ; then
FREETYPE_CFLAGS=`$FREETYPE_CONFIG --cflags`
FREETYPE_LIBS=`$FREETYPE_CONFIG --libs`
AC_DEFINE(HAVE_FREETYPE_H, 1, [Have FreeType2 include files])
vers=`$FREETYPE_CONFIG --version 2>/dev/null | sed -e 's/libfreetype //' | awk 'BEGIN { FS = "."; } { printf "%d", $1 * 10000 + $2 * 100 + $3;}'`
min_vers=`echo $FREETYPE_MIN_VERSION | awk 'BEGIN { FS = "."; } { printf "%d", $1 * 10000 + $2 * 100 + $3;}'`
if test -n "$vers" && test "$vers" -le $min_vers; then
AC_DEFINE_UNQUOTED(HAVE_FREETYPE_217_OR_OLDER, 1, [Defines if your system has the freetype library 2.1.7 or older])
else
AC_DEFINE_UNQUOTED(HAVE_FREETYPE_217_OR_OLDER, 0, [Defines if your system has the freetype library 2.1.7 or older])
fi
fi
fi
......
......@@ -37,7 +37,7 @@ static void cairo_font_face_destroy (void *data)
delete font;
}
CairoFont::CairoFont(GfxFont *gfxFont, XRef *xref, FT_Library lib) {
CairoFont::CairoFont(GfxFont *gfxFont, XRef *xref, FT_Library lib, GBool useCIDs) {
Ref embRef;
Object refObj, strObj;
GooString *tmpFileName, *fileName, *substName,*tmpFileName2;
......@@ -162,12 +162,13 @@ CairoFont::CairoFont(GfxFont *gfxFont, XRef *xref, FT_Library lib) {
codeToGID = NULL;
codeToGIDLen = 0;
#if HAVE_FREETYPE_217_OR_OLDER
if ((ff1c = FoFiType1C::load(fileName->getCString()))) {
codeToGID = ff1c->getCIDToGIDMap(&codeToGIDLen);
delete ff1c;
if (useCIDs)
{
if ((ff1c = FoFiType1C::load(fileName->getCString()))) {
codeToGID = ff1c->getCIDToGIDMap(&codeToGIDLen);
delete ff1c;
}
}
#endif
if (FT_New_Face(lib, fileName->getCString(), 0, &face)) {
gfree(codeToGID);
......@@ -250,6 +251,12 @@ CairoFontEngine::CairoFontEngine(FT_Library libA) {
for (i = 0; i < cairoFontCacheSize; ++i) {
fontCache[i] = NULL;
}
FT_Int major, minor, patch;
// as of FT 2.1.8, CID fonts are indexed by CID instead of GID
FT_Library_Version(lib, &major, &minor, &patch);
useCIDs = major > 2 ||
(major == 2 && (minor > 1 || (minor == 1 && patch > 7)));
}
CairoFontEngine::~CairoFontEngine() {
......@@ -287,7 +294,7 @@ CairoFontEngine::getFont(GfxFont *gfxFont, XRef *xref) {
}
}
font = new CairoFont (gfxFont, xref, lib);
font = new CairoFont (gfxFont, xref, lib, useCIDs);
if (fontCache[cairoFontCacheSize - 1]) {
delete fontCache[cairoFontCacheSize - 1];
}
......
......@@ -18,7 +18,7 @@
class CairoFont {
public:
CairoFont(GfxFont *gfxFont, XRef *xref, FT_Library lib);
CairoFont(GfxFont *gfxFont, XRef *xref, FT_Library lib, GBool useCIDs);
~CairoFont();
GBool matches(Ref &other);
......@@ -54,6 +54,7 @@ public:
private:
CairoFont *fontCache[cairoFontCacheSize];
FT_Library lib;
GBool useCIDs;
};
#endif
......@@ -41,8 +41,15 @@ static void fileWrite(void *stream, char *data, int len) {
//------------------------------------------------------------------------
SplashFTFontEngine::SplashFTFontEngine(GBool aaA, FT_Library libA) {
FT_Int major, minor, patch;
aa = aaA;
lib = libA;
// as of FT 2.1.8, CID fonts are indexed by CID instead of GID
FT_Library_Version(lib, &major, &minor, &patch);
useCIDs = major > 2 ||
(major == 2 && (minor > 1 || (minor == 1 && patch > 7)));
}
SplashFTFontEngine *SplashFTFontEngine::init(GBool aaA) {
......@@ -81,20 +88,16 @@ SplashFontFile *SplashFTFontEngine::loadCIDFont(SplashFontFileID *idA,
SplashFontFile *ret;
// check for a CFF font
#if HAVE_FREETYPE_217_OR_OLDER
if ((ff = FoFiType1C::load(fileName))) {
if (useCIDs) {
cidToGIDMap = NULL;
nCIDs = 0;
} else if ((ff = FoFiType1C::load(fileName))) {
cidToGIDMap = ff->getCIDToGIDMap(&nCIDs);
delete ff;
} else {
cidToGIDMap = NULL;
nCIDs = 0;
}
#else
// No need to check for CFF Font, freetype treats all CID fonts the same way
cidToGIDMap = NULL;
nCIDs = 0;
#endif
ret = SplashFTFontFile::loadCIDFont(this, idA, fileName, deleteFile,
cidToGIDMap, nCIDs);
if (!ret) {
......
......@@ -48,6 +48,7 @@ private:
GBool aa;
FT_Library lib;
GBool useCIDs;
friend class SplashFTFontFile;
friend class SplashFTFont;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment