summaryrefslogtreecommitdiff
path: root/tree/font.c
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2004-11-11 07:52:33 +0100
committerTor Andersson <tor@ghostscript.com>2004-11-11 07:52:33 +0100
commit1be84ed1d4fbe44387222995a124a4f84ee55210 (patch)
tree4748ea9933e543fbde652857444b416cc16361d0 /tree/font.c
parent58de1fff510078e3d2d8cfce033c87299adf78f0 (diff)
downloadmupdf-1be84ed1d4fbe44387222995a124a4f84ee55210.tar.xz
fitz tree resource reference counting
Diffstat (limited to 'tree/font.c')
-rw-r--r--tree/font.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/tree/font.c b/tree/font.c
index 16626651..91ba7954 100644
--- a/tree/font.c
+++ b/tree/font.c
@@ -3,6 +3,7 @@
void
fz_initfont(fz_font *font, char *name)
{
+ font->nrefs = 1;
strlcpy(font->name, name, sizeof font->name);
font->wmode = 0;
@@ -30,6 +31,26 @@ fz_initfont(fz_font *font, char *name)
font->dvmtx.w = -1000;
}
+fz_font *
+fz_keepfont(fz_font *font)
+{
+ font->nrefs ++;
+ return font;
+}
+
+void
+fz_dropfont(fz_font *font)
+{
+ if (--font->nrefs == 0)
+ {
+ if (font->drop)
+ font->drop(font);
+ fz_free(font->hmtx);
+ fz_free(font->vmtx);
+ fz_free(font);
+ }
+}
+
void
fz_setfontwmode(fz_font *font, int wmode)
{
@@ -216,16 +237,6 @@ notfound:
}
void
-fz_dropfont(fz_font *font)
-{
- if (font->drop)
- font->drop(font);
- fz_free(font->hmtx);
- fz_free(font->vmtx);
- fz_free(font);
-}
-
-void
fz_debugfont(fz_font *font)
{
int i;