1 | //======================================================================== |
2 | // |
3 | // SplashFontFile.cc |
4 | // |
5 | //======================================================================== |
6 | |
7 | //======================================================================== |
8 | // |
9 | // Modified under the Poppler project - http://poppler.freedesktop.org |
10 | // |
11 | // All changes made under the Poppler project to this file are licensed |
12 | // under GPL version 2 or later |
13 | // |
14 | // Copyright (C) 2006 Takashi Iwai <tiwai@suse.de> |
15 | // Copyright (C) 2008, 2022 Albert Astals Cid <aacid@kde.org> |
16 | // Copyright (C) 2019 Christian Persch <chpe@src.gnome.org> |
17 | // Copyright (C) 2022 Oliver Sander <oliver.sander@tu-dresden.de> |
18 | // |
19 | // To see a description of the changes please see the Changelog file that |
20 | // came with your tarball or type make ChangeLog if you are building from git |
21 | // |
22 | //======================================================================== |
23 | |
24 | #include <config.h> |
25 | |
26 | #include <cstdio> |
27 | #ifdef HAVE_UNISTD_H |
28 | # include <unistd.h> |
29 | #endif |
30 | #include "goo/gmem.h" |
31 | #include "goo/GooString.h" |
32 | #include "SplashFontFile.h" |
33 | #include "SplashFontFileID.h" |
34 | |
35 | //------------------------------------------------------------------------ |
36 | // SplashFontFile |
37 | //------------------------------------------------------------------------ |
38 | |
39 | SplashFontFile::SplashFontFile(SplashFontFileID *idA, SplashFontSrc *srcA) |
40 | { |
41 | id = idA; |
42 | src = srcA; |
43 | src->ref(); |
44 | refCnt = 0; |
45 | doAdjustMatrix = false; |
46 | } |
47 | |
48 | SplashFontFile::~SplashFontFile() |
49 | { |
50 | src->unref(); |
51 | delete id; |
52 | } |
53 | |
54 | void SplashFontFile::incRefCnt() |
55 | { |
56 | ++refCnt; |
57 | } |
58 | |
59 | void SplashFontFile::decRefCnt() |
60 | { |
61 | if (!--refCnt) { |
62 | delete this; |
63 | } |
64 | } |
65 | |
66 | // |
67 | |
68 | SplashFontSrc::SplashFontSrc() |
69 | { |
70 | isFile = false; |
71 | refcnt = 1; |
72 | } |
73 | |
74 | SplashFontSrc::~SplashFontSrc() = default; |
75 | |
76 | void SplashFontSrc::ref() |
77 | { |
78 | refcnt++; |
79 | } |
80 | |
81 | void SplashFontSrc::unref() |
82 | { |
83 | if (!--refcnt) { |
84 | delete this; |
85 | } |
86 | } |
87 | |
88 | void SplashFontSrc::setFile(const std::string &file) |
89 | { |
90 | isFile = true; |
91 | fileName = file; |
92 | } |
93 | |
94 | void SplashFontSrc::setBuf(std::vector<unsigned char> &&bufA) |
95 | { |
96 | isFile = false; |
97 | buf = std::move(bufA); |
98 | } |
99 | |