aboutsummaryrefslogtreecommitdiff
path: root/splash/SplashFontFile.cc
diff options
context:
space:
mode:
authorCalvin Morrison <calvin@pobox.com>2023-04-05 14:13:39 -0400
committerCalvin Morrison <calvin@pobox.com>2023-04-05 14:13:39 -0400
commit835e373b3eeaabcd0621ed6798ab500f37982fae (patch)
treedfa16b0e2e1b4956b38f693220eac4e607802133 /splash/SplashFontFile.cc
xpdf-no-select-disableHEADmaster
Diffstat (limited to 'splash/SplashFontFile.cc')
-rw-r--r--splash/SplashFontFile.cc84
1 files changed, 84 insertions, 0 deletions
diff --git a/splash/SplashFontFile.cc b/splash/SplashFontFile.cc
new file mode 100644
index 0000000..2d260e3
--- /dev/null
+++ b/splash/SplashFontFile.cc
@@ -0,0 +1,84 @@
+//========================================================================
+//
+// SplashFontFile.cc
+//
+// Copyright 2003-2013 Glyph & Cog, LLC
+//
+//========================================================================
+
+#include <aconf.h>
+
+#ifdef USE_GCC_PRAGMAS
+#pragma implementation
+#endif
+
+#include <stdio.h>
+#ifndef _WIN32
+# include <unistd.h>
+#endif
+#include "gmempp.h"
+#include "GString.h"
+#include "SplashFontFile.h"
+#include "SplashFontFileID.h"
+
+#ifdef VMS
+#if (__VMS_VER < 70000000)
+extern "C" int unlink(char *filename);
+#endif
+#endif
+
+//------------------------------------------------------------------------
+// SplashFontFile
+//------------------------------------------------------------------------
+
+SplashFontFile::SplashFontFile(SplashFontFileID *idA,
+ SplashFontType fontTypeA,
+#if LOAD_FONTS_FROM_MEM
+ GString *fontBufA
+#else
+ char *fileNameA, GBool deleteFileA
+#endif
+ ) {
+ id = idA;
+ fontType = fontTypeA;
+#if LOAD_FONTS_FROM_MEM
+ fontBuf = fontBufA;
+#else
+ fileName = new GString(fileNameA);
+ deleteFile = deleteFileA;
+#endif
+ refCnt = 0;
+}
+
+SplashFontFile::~SplashFontFile() {
+#if LOAD_FONTS_FROM_MEM
+ delete fontBuf;
+#else
+ if (deleteFile) {
+ unlink(fileName->getCString());
+ }
+ delete fileName;
+#endif
+ delete id;
+}
+
+void SplashFontFile::incRefCnt() {
+#if MULTITHREADED
+ gAtomicIncrement(&refCnt);
+#else
+ ++refCnt;
+#endif
+}
+
+void SplashFontFile::decRefCnt() {
+ GBool done;
+
+#if MULTITHREADED
+ done = gAtomicDecrement(&refCnt) == 0;
+#else
+ done = --refCnt == 0;
+#endif
+ if (done) {
+ delete this;
+ }
+}