3
Copyright (c) 2006-2007, BBR Inc. All rights reserved.
5
Permission is hereby granted, free of charge, to any person obtaining
6
a copy of this software and associated documentation files (the
7
"Software"), to deal in the Software without restriction, including
8
without limitation the rights to use, copy, modify, merge, publish,
9
distribute, sublicense, and/or sell copies of the Software, and to
10
permit persons to whom the Software is furnished to do so, subject to
11
the following conditions:
13
The above copyright notice and this permission notice shall be included
14
in all copies or substantial portions of the Software.
16
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34
#include "P2PObject.h"
35
#include "P2PResources.h"
38
#include "PDFFTrueTypeFont.h"
43
class P2PFontFile : public P2PObject {
46
static P2PFontFile *getFontFile(GooString *fileNameA,
47
GfxFont *fontA, GfxFontType typeA, int faceIndexA);
48
GooString *getFileName() {
51
void output(P2POutputStream *str, XRef *xref);
52
void outputCIDToGID(GBool wmode, P2POutputStream *str, XRef *xref);
54
P2PCIDToGID *getCIDToGID(GBool wmode);
55
void refChar(CharCode cid) {
56
if (charRefTable == 0) return;
57
if (maxRefCID < cid) maxRefCID = cid;
58
/* mark reference bit */
59
charRefTable[cid / 8] |= (1 << (cid & (8-1)));
61
UGooString *getFontName() { return fontName; }
63
static char *getNextTag();
64
P2PFontFile(GooString *fileNameA, GfxFont *fontA,
65
GfxFontType typeA, int faceIndexA);
66
static P2PFontFile **fontFileList;
67
static int nFontFiles;
68
static int fontFileListSize;
69
static char nextTag[7];
75
P2PCIDToGID *CIDToGID;
76
P2PCIDToGID *CIDToGID_V;
77
unsigned char *charRefTable;
79
PDFFTrueTypeFont tfont;
81
P2PCMapCache cmapCache;
84
class P2PCIDToGID : public P2PObject {
86
P2PCIDToGID(P2PFontFile *fontFileA, GBool wmodeA);
88
void output(P2POutputStream *str, XRef *xref);
90
P2PFontFile *fontFile;
94
class P2PFontDescriptor : public P2PObject {
96
P2PFontDescriptor(Object *descriptorA, GfxFont *fontA,
97
GooString *fileName, GfxFontType type, int faceIndexA, XRef *xref,
100
void output(P2POutputStream *str, XRef *xref);
101
P2PFontFile *getFontFile() { return fontFile; }
102
GfxFontType getType() { return type; }
104
P2PFontFile *fontFile;
109
class P2PCIDFontDict : public P2PObject {
111
P2PCIDFontDict(Object *fontDictA, GfxFont *fontA, GfxFontType typeA,
112
GfxFontType embeddedTypeA,
113
P2PFontDescriptor *fontDescriptorA, int num = -1, int gen = -1);
115
void output(P2POutputStream *str, XRef *xref);
116
P2PFontDescriptor *getFontDescriptor() { return fontDescriptor; }
120
GfxFontType embeddedType;
121
P2PFontDescriptor *fontDescriptor;
125
class P2PDescendantFontsWrapper : public P2PObject {
127
P2PDescendantFontsWrapper(P2PObject *elementA);
128
~P2PDescendantFontsWrapper();
129
void output(P2POutputStream *str, XRef *xref);
134
class P2PFontDict : public P2PObject {
136
P2PFontDict(Object *fontDictA, XRef *xref, int num = -1, int gen = -1);
138
void output(P2POutputStream *str, XRef *xref);
139
P2PCIDFontDict *getCIDFontDict() { return cidFontDict; }
140
void showText(GooString *s);
141
UGooString *getEmbeddingFontName();
143
void doReadFontDescriptor(Object *dictObj, GfxFontType type,
144
const char *name, XRef *xref);
145
void read8bitFontDescriptor(GfxFontType type, const char *name,
147
void readCIDFontDescriptor(GfxFontType type, const char *name,
149
P2PFontDescriptor *fontDescriptor;
152
GfxFontType embeddedType;
153
P2PCIDFontDict *cidFontDict;
156
class P2PFontResource : public P2PObject {
158
void setup(P2PResources *resources, XRef *xref);
159
void setup(Dict *resources, XRef *xref);
160
P2PFontDict *lookup(const UGooString &key);
161
P2PFontDict *lookupExtGState(const UGooString &key);
164
void output(P2POutputStream *str, XRef *xref);
165
int getNDicts() { return nDicts; }
167
int getNExtGState() { return nExtGState; }
168
void doSetup(Dict *fontResource, XRef *xref);
169
void doSetupExtGState(Dict *extGState, XRef *xref);
172
P2PFontDict **fontDicts;
174
UGooString **extGStateKeys;
175
P2PFontDict **extGStateFonts;