summaryrefslogtreecommitdiff
path: root/draw/glyphcache.c
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2010-05-10 16:38:42 +0200
committerTor Andersson <tor@ghostscript.com>2010-05-10 16:38:42 +0200
commite6c5356491b0fccbd7e485cbff039fce62ddc336 (patch)
treeb46b3b0545d17b7ca4d8423cae65f45ef0f0978e /draw/glyphcache.c
parentbc29aa90e5b0d1bf813f9eacb8bce53f5174bec6 (diff)
downloadmupdf-e6c5356491b0fccbd7e485cbff039fce62ddc336.tar.xz
Reference count font pointers in the glyph cache keys.
Diffstat (limited to 'draw/glyphcache.c')
-rw-r--r--draw/glyphcache.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/draw/glyphcache.c b/draw/glyphcache.c
index 9828aa2a..173d7979 100644
--- a/draw/glyphcache.c
+++ b/draw/glyphcache.c
@@ -13,7 +13,7 @@ struct fz_glyphcache_s
struct fz_glyphkey_s
{
- void *font;
+ fz_font *font;
int a, b;
int c, d;
unsigned short cid;
@@ -35,11 +35,15 @@ fz_newglyphcache(void)
void
fz_evictglyphcache(fz_glyphcache *cache)
{
+ fz_glyphkey *key;
fz_pixmap *pixmap;
int i;
for (i = 0; i < fz_hashlen(cache->hash); i++)
{
+ key = fz_hashgetkey(cache->hash, i);
+ if (key->font)
+ fz_dropfont(key->font);
pixmap = fz_hashgetval(cache->hash, i);
if (pixmap)
fz_droppixmap(pixmap);
@@ -100,6 +104,7 @@ fz_renderglyph(fz_glyphcache *cache, fz_font *font, int cid, fz_matrix ctm)
{
if (cache->total + val->w * val->h > MAXCACHESIZE)
fz_evictglyphcache(cache);
+ fz_keepfont(key.font);
fz_hashinsert(cache->hash, &key, val);
cache->total += val->w * val->h;
return fz_keeppixmap(val);