diff --git a/splash/SplashFTFont.cc b/splash/SplashFTFont.cc index f18b58b..2baac34 100644 --- a/splash/SplashFTFont.cc +++ b/splash/SplashFTFont.cc @@ -80,6 +80,10 @@ SplashFTFont::SplashFTFont(SplashFTFontFile *fontFileA, SplashCoord *matA, if (FT_Set_Pixel_Sizes(face, 0, size)) { return; } + + ascender = face->ascender; + descender = face->descender; + // if the textMat values are too small, FreeType's fixed point // arithmetic doesn't work so well textScale = splashDist(0, 0, textMat[2], textMat[3]) / size; @@ -388,6 +392,12 @@ struct SplashFTFontPath { GBool needClose; }; +int SplashFTFont::getNumChars() +{ + SplashFTFontFile* ff = (SplashFTFontFile *)fontFile; + return ff->face->num_glyphs; +} + SplashPath *SplashFTFont::getGlyphPath(int c) { static FT_Outline_Funcs outlineFuncs = { #if FREETYPE_MINOR <= 1 @@ -409,6 +419,8 @@ SplashPath *SplashFTFont::getGlyphPath(int c) { FT_UInt gid; FT_Glyph glyph; + last_advance = -1; + ff = (SplashFTFontFile *)fontFile; ff->face->size = sizeObj; FT_Set_Transform(ff->face, &textMatrix, NULL); @@ -428,6 +440,8 @@ SplashPath *SplashFTFont::getGlyphPath(int c) { if (FT_Get_Glyph(slot, &glyph)) { return NULL; } + last_advance = glyph->advance.x/65536.0; + path.path = new SplashPath(); path.textScale = textScale; path.needClose = gFalse; diff --git a/splash/SplashFTFont.h b/splash/SplashFTFont.h index f49d7b1..19d151e 100644 --- a/splash/SplashFTFont.h +++ b/splash/SplashFTFont.h @@ -58,6 +58,9 @@ public: virtual GBool makeGlyph(int c, int xFrac, int yFrac, SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes); + // return the number of characters in this font + virtual int getNumChars(); + // Return the path for a glyph. virtual SplashPath *getGlyphPath(int c); diff --git a/splash/SplashFont.cc b/splash/SplashFont.cc index 2bfcdc8..56b869c 100644 --- a/splash/SplashFont.cc +++ b/splash/SplashFont.cc @@ -62,6 +62,10 @@ SplashFont::SplashFont(SplashFontFile *fontFileA, SplashCoord *matA, cacheTags = NULL; xMin = yMin = xMax = yMax = 0; + + last_advance = -1; + ascender = -1; + descender = -1; } void SplashFont::initCache() { diff --git a/splash/SplashFont.h b/splash/SplashFont.h index 78b00d2..2a0e77d 100644 --- a/splash/SplashFont.h +++ b/splash/SplashFont.h @@ -86,6 +86,9 @@ public: virtual GBool makeGlyph(int c, int xFrac, int yFrac, SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes) = 0; + // return the number of characters in this font + virtual int getNumChars() = 0; + // Return the path for a glyph. virtual SplashPath *getGlyphPath(int c) = 0; @@ -100,6 +103,14 @@ public: void getBBox(int *xMinA, int *yMinA, int *xMaxA, int *yMaxA) { *xMinA = xMin; *yMinA = yMin; *xMaxA = xMax; *yMaxA = yMax; } + double getAscender() { return ascender; } + double getDescender() { return descender; } + double getLastAdvance() { return last_advance; } + + void setAscender(double v) { ascender = v; } + void setDescender(double v) { descender = v; } + void setLastAdvance(double v) { last_advance = v; } + protected: SplashFontFile *fontFile; @@ -116,6 +127,9 @@ protected: int glyphSize; // size of glyph bitmaps, in bytes int cacheSets; // number of sets in cache int cacheAssoc; // cache associativity (glyphs per set) + double ascender; + double descender; + double last_advance; }; #endif diff --git a/splash/SplashT1Font.cc b/splash/SplashT1Font.cc index 0fdfaaf..de20c91 100644 --- a/splash/SplashT1Font.cc +++ b/splash/SplashT1Font.cc @@ -306,4 +306,10 @@ SplashPath *SplashT1Font::getGlyphPath(int c) { return path; } +int SplashT1Font::getNumChars() +{ + SplashT1FontFile* ff = (SplashT1FontFile *)fontFile; + return ff->face->num_glyphs; +} + #endif // HAVE_T1LIB_H diff --git a/splash/SplashT1Font.h b/splash/SplashT1Font.h index 1dbe66c..41f42b1 100644 --- a/splash/SplashT1Font.h +++ b/splash/SplashT1Font.h @@ -52,6 +52,9 @@ public: virtual GBool makeGlyph(int c, int xFrac, int yFrac, SplashGlyphBitmap *bitmap, int x0, int y0, SplashClip *clip, SplashClipResult *clipRes); + // return the number of characters in this font + virtual int getNumChars(); + // Return the path for a glyph. virtual SplashPath *getGlyphPath(int c);