[poppler] poppler/poppler: CairoFontEngine.cc, 1.4,
1.5 CairoFontEngine.h, 1.1.1.1, 1.2 CairoOutputDev.cc, 1.5, 1.6
Kristian Hogsberg
krh at freedesktop.org
Wed Apr 20 23:35:35 PDT 2005
Update of /cvs/poppler/poppler/poppler
In directory gabe:/tmp/cvs-serv24630/poppler
Modified Files:
CairoFontEngine.cc CairoFontEngine.h CairoOutputDev.cc
Log Message:
Thu Apr 21 02:25:20 2005 Kristian Høgsberg <krh at redhat.com>
* poppler/CairoFontEngine.cc (CairoFont::getFont): Cache
cairo_font_t's for a given CairoFont. With this patch cairo will
recognize glyphs coming from the same font as such and the glyph
cache will actually work.
* glib/poppler-document.cc (poppler_document_new_from_file): Add
output device (cairo or splash) to PopplerDocument and initialize
it in the constructor.
* glib/poppler-page.cc (splash_render_to_pixbuf,
cairo_render_to_pixbuf): Use output device from associated poppler
document instead of creating a new one.
* poppler-glib.pc.in (Requires): Add Requires: field.
* poppler/Page.cc (loadThumb): Remove unecessary and buggy call to
Stream::addFilters(), reported by Ryan Lortie (#3046).
Index: CairoFontEngine.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/CairoFontEngine.cc,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- CairoFontEngine.cc 21 Apr 2005 05:20:25 -0000 1.4
+++ CairoFontEngine.cc 21 Apr 2005 06:35:33 -0000 1.5
@@ -77,6 +77,7 @@
codeToGIDLen = 0;
substIdx = -1;
cairo_font = NULL;
+ instance_list = NULL;
ref = *gfxFont->getID();
fontType = gfxFont->getType();
@@ -238,10 +239,20 @@
}
CairoFont::~CairoFont() {
- /* TODO: Free the face!
- * How do we know when we can do this?
- * It might be referenced by a cairo cache
- */
+ Instance *i, *next;
+
+ for (i = instance_list; i != NULL; i = next) {
+ next = i->next;
+ cairo_font_destroy (i->font);
+ delete i;
+ }
+
+ /* cairo_font_t's created from an FT_Face are never cached so we can
+ * free the font here. There might be glyphs in the cairo glyph
+ * cache referencing this font, but since we're throwing this font
+ * away, they won't be used and will slowly fall out of the
+ * cache. */
+ FT_Done_Face (face);
}
GBool
@@ -251,8 +262,30 @@
}
cairo_font_t *
-CairoFont::getFont(cairo_matrix_t *font_scale) {
- return cairo_ft_font_create_for_ft_face (face, FT_LOAD_NO_HINTING, font_scale);
+CairoFont::getFont(double a, double b, double c, double d) {
+ Instance *i;
+ cairo_matrix_t *matrix;
+
+ for (i = instance_list; i != NULL; i = i->next) {
+ if (i->a == a && i->b == b && i->c == c && i->d == d)
+ return i->font;
+ }
+
+ i = new Instance;
+ i->a = a;
+ i->b = b;
+ i->c = c;
+ i->d = d;
+
+ matrix = cairo_matrix_create ();
+ cairo_matrix_set_affine (matrix, a, b, c, d, 0, 0);
+ i->font = cairo_ft_font_create_for_ft_face (face, FT_LOAD_NO_HINTING,
+ matrix);
+ cairo_matrix_destroy (matrix);
+ i->next = instance_list;
+ instance_list = i;
+
+ return i->font;
}
unsigned long
Index: CairoFontEngine.h
===================================================================
RCS file: /cvs/poppler/poppler/poppler/CairoFontEngine.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- CairoFontEngine.h 3 Mar 2005 19:46:00 -0000 1.1.1.1
+++ CairoFontEngine.h 21 Apr 2005 06:35:33 -0000 1.2
@@ -22,7 +22,7 @@
~CairoFont();
GBool matches(Ref &other);
- cairo_font_t *getFont(cairo_matrix_t *font_scale);
+ cairo_font_t *getFont(double a, double b, double c, double d);
unsigned long getGlyph(CharCode code,
Unicode *u, int uLen);
double getSubstitutionCorrection(GfxFont *gfxFont);
@@ -34,6 +34,13 @@
Gushort *codeToGID;
int codeToGIDLen;
+
+ struct Instance {
+ cairo_font_t *font;
+ double a, b, c, d;
+ Instance *next;
+ };
+ Instance *instance_list;
};
//------------------------------------------------------------------------
Index: CairoOutputDev.cc
===================================================================
RCS file: /cvs/poppler/poppler/poppler/CairoOutputDev.cc,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- CairoOutputDev.cc 11 Mar 2005 22:43:29 -0000 1.5
+++ CairoOutputDev.cc 21 Apr 2005 06:35:33 -0000 1.6
@@ -217,16 +217,9 @@
w = currentFont->getSubstitutionCorrection(state->getFont());
- cairo_matrix_t *matrix = cairo_matrix_create ();
- cairo_matrix_set_affine (matrix,
- m11, m21,
- -m12*w, -m22*w,
- 0, 0);
-
- font = currentFont->getFont(matrix);
+ font = currentFont->getFont(m11, m21, -m12 * w, -m22 * w);
if (font)
cairo_set_font (cairo, font);
- cairo_matrix_destroy (matrix);
}
void CairoOutputDev::doPath(GfxState *state, GfxPath *path,
More information about the poppler
mailing list