wxMaxima
Loading...
Searching...
No Matches
pdffontsubsetcff.h
Go to the documentation of this file.
1
2// Name: pdffontsubsetcfft.h
3// Purpose:
4// Author: Ulrich Telle
5// Created: 2008-06-24
6// Copyright: (c) Ulrich Telle
7// Licence: wxWindows licence
9
11
12#ifndef _PDF_FONT_SUBSET_CFF_H_
13#define _PDF_FONT_SUBSET_CFF_H_
14
15// wxWidgets headers
16#include <wx/dynarray.h>
17#include <wx/mstream.h>
18#include <wx/string.h>
19#include <wx/wfstream.h>
20
21// wxPdfDocument headers
22#include "wx/pdfdocdef.h"
23#include "wx/pdffontdata.h"
24
25class WXDLLIMPEXP_FWD_PDFDOC wxPdfCffDecoder;
26
29class wxPdfCffIndexArray;
30
31WX_DECLARE_HASH_MAP(long, wxPdfCffDictElement*, wxIntegerHash, wxIntegerEqual, wxPdfCffDictionary);
32
35class WXDLLIMPEXP_PDFDOC wxPdfFontSubsetCff
36{
37public:
39 wxPdfFontSubsetCff(const wxString& fileName);
40
42 virtual ~wxPdfFontSubsetCff();
43
45
48 void DestructDictionary(wxPdfCffDictionary* dict);
49
51
57 wxMemoryOutputStream* CreateSubset(wxInputStream* inFont,
58 wxPdfChar2GlyphMap* glyphsUsed,
59 bool includeCmap = false);
60
61protected:
63 bool ReadCffFont();
64
66 bool ReadHeader();
67
69 bool ReadFontName();
70
72 bool ReadTopDict();
73
75 bool ReadStrings();
76
78 bool ReadGlobalSubroutines();
79
81 bool ReadFontIndex(wxPdfCffIndexArray* index);
82
84 bool ReadFontDict(wxPdfCffDictionary* dict, int dictOffset, int dictSize);
85
87 bool ReadFdSelect();
88
90 bool ReadCidFontDict();
91
93 bool ReadPrivateDict(wxPdfCffDictionary* privateDict, wxPdfCffIndexArray* localSubIndex, int offset, int size);
94
96 wxPdfCffDictElement* FindDictElement(wxPdfCffDictionary* dict, int key);
97
99 void SetDictElementArgument(wxPdfCffDictionary* dict, int key, wxMemoryOutputStream& buffer);
100
102 void RemoveDictElement(wxPdfCffDictionary* dict, int key);
103
105 int DecodeInteger();
106
108 void EncodeIntegerMax(int value, wxMemoryOutputStream& buffer);
109
111 void EncodeInteger(int value, wxMemoryOutputStream& buffer);
112
114 void SeekI(int offset);
115
117 int TellI();
118
120 int GetSizeI();
121
123 unsigned char ReadByte();
124
126 short ReadShort();
127
129 int ReadInt();
130
132 int ReadOffset(int offSize);
133
135 int ReadOperandLength();
136
138 int ReadOperator();
139
141 wxString ReadString(int length);
142
144 void GenerateFontSubset();
145
147 void SetRosStrings();
148
150 void SubsetCharstrings();
151
153 void SubsetFontDict();
154
156 void CreateCidFontDict();
157
159 void SubsetStrings();
160
162 void SubsetDictString(wxPdfCffDictionary* dict, int op);
163
165 void SubsetDictStrings(wxPdfCffDictionary* dict);
166
168 void SeekO(int offset);
169
171 int TellO();
172
174 void WriteFontSubset();
175
177 void WriteHeader();
178
180 void WriteName();
181
183 void WriteTopDict();
184
186 void WriteDict(wxPdfCffDictionary* dict);
187
189 void WriteDictOperator(wxPdfCffDictElement* op);
190
192 void SetTopDictOperatorToCurrentPosition(int op);
193
195 int GetLocation(wxPdfCffDictionary* dict, int op);
196
198 void WriteStrings();
199
201 void WriteGlobalSubrs();
202
204 void WriteCharset();
205
207 void WriteFdSelect();
208
210 void WriteCharStrings();
211
213 void WriteCidFontDict();
214
216 void WriteCidPrivateDictAndLocalSub();
217
219 void WritePrivateDict(int dictNum, wxPdfCffDictionary* parentDict, wxPdfCffDictionary* privateDict);
220
222 void WriteLocalSub(int dictNum, wxPdfCffDictionary* privateDict, wxPdfCffIndexArray* localSubIndex);
223
225 void WriteIndex(wxPdfCffIndexArray* index);
226
228 void WriteInteger(int value, int size, wxMemoryOutputStream* buffer);
229
231 void FindLocalAndGlobalSubrsUsed();
232
234 void SubsetSubrs(wxPdfCffIndexArray& subrIndex, wxPdfSortedArrayInt& subrsUsed);
235
237 void FindSubrsUsed(int fd, wxPdfCffIndexArray& localSubIndex,
238 wxPdfSortedArrayInt& hSubrsUsed, wxArrayInt& lSubrsUsed);
239
241 void FindGlobalSubrsUsed();
242
243private:
244 wxString m_fileName;
245 wxInputStream* m_inFont;
246 wxMemoryOutputStream* m_outFont;
247
248 wxPdfCffDecoder* m_decoder;
249
250 int m_numGlyphsUsed;
251 wxArrayInt m_usedGlyphs;
252 bool m_includeCmap;
253
254 wxString m_fontName;
255 wxPdfCffDictionary* m_topDict;
256 wxPdfCffDictionary* m_privateDict;
257
258 wxPdfCffIndexArray* m_stringsIndex;
259 wxPdfCffIndexArray* m_charstringsIndex;
260 wxPdfCffIndexArray* m_globalSubrIndex;
261 wxPdfCffIndexArray* m_localSubrIndex;
262
263 wxPdfCffIndexArray* m_stringsSubsetIndex;
264 wxPdfCffIndexArray* m_charstringsSubsetIndex;
265
266 wxArrayInt m_fdSelect;
267
268 int m_hdrSize;
269 bool m_isCid;
270 int m_numGlyphs;
271 int m_numFontDicts;
272
273 wxArrayPtrVoid m_fdDict;
274 wxArrayPtrVoid m_fdPrivateDict;
275 wxArrayPtrVoid m_fdLocalSubrIndex;
276
277 wxArrayInt m_fdSelectSubset;
278 int m_numSubsetFontDicts;
279 wxArrayInt m_fdSubsetMap;
280 wxArrayInt m_privateDictOffset;
281
282 int m_globalBias;
283
284 wxPdfSortedArrayInt* m_hGlobalSubrsUsed;
285 wxArrayInt m_lGlobalSubrsUsed;
286 wxPdfSortedArrayInt* m_hLocalSubrsUsed;
287 wxArrayInt m_lLocalSubrsUsed;
288};
289
290#endif
const wxChar * key
The name in the config file.
Definition: ToolBarSections.cpp:37
Class representing CFF decoder for charstrings of type 1 and 2. (For internal use only)
Definition: pdfcffdecoder.h:35
Definition: pdffontsubsetcff.cpp:80
Definition: pdfcffdecoder.cpp:197
Class representing OpenType Font Subsets. (For internal use only)
Definition: pdffontsubsetcff.h:36
Compile time switches for the wxPdfDocument component.
Definition of font data.