Commit 5c89902c authored by Kristian Høgsberg's avatar Kristian Høgsberg

Thu Apr 21 02:25:20 2005 Kristian Høgsberg <krh@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).
parent 71c1563b
Thu Apr 21 00:15:30 2005 Kristian Høgsberg <krh@redhat.com>
Thu Apr 21 02:25:20 2005 Kristian Høgsberg <krh@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
......
Next Release
Release 0.3.0
TODO:
- Use zlib for flate streams by default
- Performance fixes for glib+cairo
DONE:
- First simple cut at qt wrapper, including getText() for
- First cut at qt wrapper, including a getText() method for
getting text from a page.
- More glib functionality: meta data, set page orientation,
print to PS
- Performance fixes for glib+cairo
- Bug fixes
Release 0.2.0 (Tue Apr 5 12:32:10 EDT 2005)
......
......@@ -77,6 +77,7 @@ CairoFont::CairoFont(GfxFont *gfxFont, XRef *xref, FT_Library lib) {
codeToGIDLen = 0;
substIdx = -1;
cairo_font = NULL;
instance_list = NULL;
ref = *gfxFont->getID();
fontType = gfxFont->getType();
......@@ -238,10 +239,20 @@ CairoFont::CairoFont(GfxFont *gfxFont, XRef *xref, FT_Library lib) {
}
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 @@ CairoFont::matches(Ref &other) {
}
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
......
......@@ -22,7 +22,7 @@ public:
~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 @@ private:
Gushort *codeToGID;
int codeToGIDLen;
struct Instance {
cairo_font_t *font;
double a, b, c, d;
Instance *next;
};
Instance *instance_list;
};
//------------------------------------------------------------------------
......
......@@ -217,16 +217,9 @@ void CairoOutputDev::updateFont(GfxState *state) {
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,
......
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