[PATCH] Restore the cairo Type3 font image prescaling funtionality
Adrian Johnson
ajohnson at redneon.com
Sat Nov 1 04:57:48 PDT 2008
---
poppler/CairoFontEngine.cc | 49 ++++++++++++++++++++++++++------------------
poppler/CairoFontEngine.h | 20 ++++++++++-------
poppler/CairoOutputDev.cc | 2 +-
poppler/CairoOutputDev.h | 2 +-
4 files changed, 43 insertions(+), 30 deletions(-)
diff --git a/poppler/CairoFontEngine.cc b/poppler/CairoFontEngine.cc
index 07be458..b58e99b 100644
--- a/poppler/CairoFontEngine.cc
+++ b/poppler/CairoFontEngine.cc
@@ -63,11 +63,13 @@ CairoFont::CairoFont(Ref ref,
cairo_font_face_t *cairo_font_face,
Gushort *codeToGID,
int codeToGIDLen,
- GBool substitute) : ref(ref),
- cairo_font_face(cairo_font_face),
- codeToGID(codeToGID),
- codeToGIDLen(codeToGIDLen),
- substitute(substitute) { }
+ GBool substitute,
+ GBool printing) : ref(ref),
+ cairo_font_face(cairo_font_face),
+ codeToGID(codeToGID),
+ codeToGIDLen(codeToGIDLen),
+ substitute(substitute),
+ printing(printing) { }
CairoFont::~CairoFont() {
cairo_font_face_destroy (cairo_font_face);
@@ -75,8 +77,8 @@ CairoFont::~CairoFont() {
}
GBool
-CairoFont::matches(Ref &other) {
- return (other.num == ref.num && other.gen == ref.gen);
+CairoFont::matches(Ref &other, GBool printingA) {
+ return (other.num == ref.num && other.gen == ref.gen && printing == printingA);
}
cairo_font_face_t *
@@ -337,7 +339,8 @@ CairoFreeTypeFont::CairoFreeTypeFont(Ref ref,
cairo_font_face,
codeToGID,
codeToGIDLen,
- substitute),
+ substitute,
+ gTrue),
face(face) { }
CairoFreeTypeFont::~CairoFreeTypeFont() { }
@@ -546,6 +549,7 @@ typedef struct _type3_font_info {
XRef *xref;
Catalog *catalog;
CairoFontEngine *fontEngine;
+ GBool printing;
} type3_font_info_t;
static void
@@ -601,6 +605,7 @@ _render_type3_glyph (cairo_scaled_font_t *scaled_font,
output_dev = new CairoOutputDev();
output_dev->setCairo(cr);
+ output_dev->setPrinting(info->printing);
mat = font->getFontBBox();
box.x1 = mat[0];
@@ -637,7 +642,8 @@ _render_type3_glyph (cairo_scaled_font_t *scaled_font,
CairoType3Font *CairoType3Font::create(GfxFont *gfxFont, XRef *xref,
- Catalog *catalog, CairoFontEngine *fontEngine) {
+ Catalog *catalog, CairoFontEngine *fontEngine,
+ GBool printing) {
Object refObj, strObj;
type3_font_info_t *info;
cairo_font_face_t *font_face;
@@ -659,6 +665,7 @@ CairoType3Font *CairoType3Font::create(GfxFont *gfxFont, XRef *xref,
info->xref = xref;
info->catalog = catalog;
info->fontEngine = fontEngine;
+ info->printing = printing;
cairo_font_face_set_user_data (font_face, &type3_font_key, (void *) info, _free_type3_font_info);
@@ -676,7 +683,7 @@ CairoType3Font *CairoType3Font::create(GfxFont *gfxFont, XRef *xref,
}
}
- return new CairoType3Font(ref, xref, catalog, font_face, codeToGID, codeToGIDLen);
+ return new CairoType3Font(ref, xref, catalog, font_face, codeToGID, codeToGIDLen, printing);
}
CairoType3Font::CairoType3Font(Ref ref,
@@ -684,13 +691,15 @@ CairoType3Font::CairoType3Font(Ref ref,
Catalog *cat,
cairo_font_face_t *cairo_font_face,
Gushort *codeToGID,
- int codeToGIDLen) : CairoFont(ref,
- cairo_font_face,
- codeToGID,
- codeToGIDLen,
- gFalse),
- xref(xref),
- catalog(catalog) { }
+ int codeToGIDLen,
+ GBool printing) : CairoFont(ref,
+ cairo_font_face,
+ codeToGID,
+ codeToGIDLen,
+ gFalse,
+ printing),
+ xref(xref),
+ catalog(catalog) { }
CairoType3Font::~CairoType3Font() { }
@@ -724,7 +733,7 @@ CairoFontEngine::~CairoFontEngine() {
}
CairoFont *
-CairoFontEngine::getFont(GfxFont *gfxFont, XRef *xref, Catalog *catalog) {
+CairoFontEngine::getFont(GfxFont *gfxFont, XRef *xref, Catalog *catalog, GBool printing) {
int i, j;
Ref ref;
CairoFont *font;
@@ -734,7 +743,7 @@ CairoFontEngine::getFont(GfxFont *gfxFont, XRef *xref, Catalog *catalog) {
for (i = 0; i < cairoFontCacheSize; ++i) {
font = fontCache[i];
- if (font && font->matches(ref)) {
+ if (font && font->matches(ref, printing)) {
for (j = i; j > 0; --j) {
fontCache[j] = fontCache[j-1];
}
@@ -745,7 +754,7 @@ CairoFontEngine::getFont(GfxFont *gfxFont, XRef *xref, Catalog *catalog) {
fontType = gfxFont->getType();
if (fontType == fontType3)
- font = CairoType3Font::create (gfxFont, xref, catalog, this);
+ font = CairoType3Font::create (gfxFont, xref, catalog, this, printing);
else
font = CairoFreeTypeFont::create (gfxFont, xref, lib, useCIDs);
diff --git a/poppler/CairoFontEngine.h b/poppler/CairoFontEngine.h
index 2474dc6..c672078 100644
--- a/poppler/CairoFontEngine.h
+++ b/poppler/CairoFontEngine.h
@@ -42,13 +42,14 @@ class CairoFontEngine;
class CairoFont {
public:
CairoFont(Ref ref,
- cairo_font_face_t *face,
- Gushort *codeToGID,
- int codeToGIDLen,
- GBool substitute);
+ cairo_font_face_t *face,
+ Gushort *codeToGID,
+ int codeToGIDLen,
+ GBool substitute,
+ GBool printing);
virtual ~CairoFont();
- GBool matches(Ref &other);
+ GBool matches(Ref &other, GBool printing);
cairo_font_face_t *getFontFace(void);
unsigned long getGlyph(CharCode code, Unicode *u, int uLen);
double getSubstitutionCorrection(GfxFont *gfxFont);
@@ -62,6 +63,7 @@ protected:
int codeToGIDLen;
GBool substitute;
+ GBool printing;
};
//------------------------------------------------------------------------
@@ -82,13 +84,15 @@ private:
class CairoType3Font : public CairoFont {
public:
static CairoType3Font *create(GfxFont *gfxFont, XRef *xref,
- Catalog *catalog, CairoFontEngine *fontEngine);
+ Catalog *catalog, CairoFontEngine *fontEngine,
+ GBool printing);
virtual ~CairoType3Font();
private:
CairoType3Font(Ref ref, XRef *xref, Catalog *catalog,
cairo_font_face_t *cairo_font_face,
- Gushort *codeToGID, int codeToGIDLen);
+ Gushort *codeToGID, int codeToGIDLen,
+ GBool printing);
XRef *xref;
Catalog *catalog;
};
@@ -108,7 +112,7 @@ public:
CairoFontEngine(FT_Library libA);
~CairoFontEngine();
- CairoFont *getFont(GfxFont *gfxFont, XRef *xref, Catalog *catalog);
+ CairoFont *getFont(GfxFont *gfxFont, XRef *xref, Catalog *catalog, GBool printing);
private:
CairoFont *fontCache[cairoFontCacheSize];
diff --git a/poppler/CairoOutputDev.cc b/poppler/CairoOutputDev.cc
index a1a2379..26b8010 100644
--- a/poppler/CairoOutputDev.cc
+++ b/poppler/CairoOutputDev.cc
@@ -416,7 +416,7 @@ void CairoOutputDev::updateFont(GfxState *state) {
needFontUpdate = gFalse;
- currentFont = fontEngine->getFont (state->getFont(), xref, catalog);
+ currentFont = fontEngine->getFont (state->getFont(), xref, catalog, printing);
if (!currentFont)
return;
diff --git a/poppler/CairoOutputDev.h b/poppler/CairoOutputDev.h
index 878d3e3..46be9dc 100644
--- a/poppler/CairoOutputDev.h
+++ b/poppler/CairoOutputDev.h
@@ -212,7 +212,7 @@ public:
GBool isReverseVideo() { return gFalse; }
void setCairo (cairo_t *cr);
- void setPrinting (GBool printing) { this->printing = printing; }
+ void setPrinting (GBool printing) { this->printing = printing; needFontUpdate = gTrue; }
void setInType3Char(GBool inType3Char) { this->inType3Char = inType3Char; }
void getType3GlyphWidth (double *wx, double *wy) { *wx = t3_glyph_wx; *wy = t3_glyph_wy; }
--
1.5.6.3
--------------030001040407080907060508--
More information about the poppler
mailing list