1 //========================================================================
2 //
3 // SplashFontFile.h
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, 2010, 2018 Albert Astals Cid <aacid@kde.org>
16 //
17 // To see a description of the changes please see the Changelog file that
18 // came with your tarball or type make ChangeLog if you are building from git
19 //
20 //========================================================================
21 
22 #ifndef SPLASHFONTFILE_H
23 #define SPLASHFONTFILE_H
24 
25 #include "SplashTypes.h"
26 #include "poppler_private_export.h"
27 
28 class GooString;
29 class SplashFontEngine;
30 class SplashFont;
31 class SplashFontFileID;
32 
33 //------------------------------------------------------------------------
34 // SplashFontFile
35 //------------------------------------------------------------------------
36 
37 class POPPLER_PRIVATE_EXPORT SplashFontSrc
38 {
39 public:
40     SplashFontSrc();
41 
42     SplashFontSrc(const SplashFontSrc &) = delete;
43     SplashFontSrc &operator=(const SplashFontSrc &) = delete;
44 
45     void setFile(GooString *file, bool del);
46     void setFile(const char *file, bool del);
47     void setBuf(char *bufA, int buflenA, bool del);
48 
49     void ref();
50     void unref();
51 
52     bool isFile;
53     GooString *fileName;
54     char *buf;
55     int bufLen;
56 
57 private:
58     ~SplashFontSrc();
59     int refcnt;
60     bool deleteSrc;
61 };
62 
63 class SplashFontFile
64 {
65 public:
66     virtual ~SplashFontFile();
67 
68     SplashFontFile(const SplashFontFile &) = delete;
69     SplashFontFile &operator=(const SplashFontFile &) = delete;
70 
71     // Create a new SplashFont, i.e., a scaled instance of this font
72     // file.
73     virtual SplashFont *makeFont(SplashCoord *mat, const SplashCoord *textMat) = 0;
74 
75     // Get the font file ID.
getID()76     SplashFontFileID *getID() { return id; }
77 
78     // Increment the reference count.
79     void incRefCnt();
80 
81     // Decrement the reference count.  If the new value is zero, delete
82     // the SplashFontFile object.
83     void decRefCnt();
84 
85     bool doAdjustMatrix;
86 
87 protected:
88     SplashFontFile(SplashFontFileID *idA, SplashFontSrc *srcA);
89 
90     SplashFontFileID *id;
91     SplashFontSrc *src;
92     int refCnt;
93 
94     friend class SplashFontEngine;
95 };
96 
97 #endif
98