wxMaxima
Loading...
Searching...
No Matches
pdffontparsertruetype.h
Go to the documentation of this file.
1
2// Name: pdffontparsertruetype.h
3// Purpose:
4// Author: Ulrich Telle
5// Created: 2009-03-04
6// Copyright: (c) Ulrich Telle
7// Licence: wxWindows licence
9
11
12#ifndef _PDF_FONT_PARSER_TRUETYPE_H_
13#define _PDF_FONT_PARSER_TRUETYPE_H_
14
15// wxWidgets headers
16#include <wx/hashmap.h>
17#include <wx/mstream.h>
18
19// wxPdfDocument headers
20#include "wx/pdfdocdef.h"
21#include "wx/pdffontdata.h"
23#include "wx/pdffontparser.h"
24
25#include "wx/pdffontmacosx.h"
26
27class WXDLLIMPEXP_FWD_PDFDOC wxPdfFontData;
28
31class WXDLLIMPEXP_PDFDOC wxPdfTableDirectoryEntry
32{
33public:
35 wxPdfTableDirectoryEntry() : m_checksum(0), m_offset(0), m_length(0) {}
39};
40
42WX_DECLARE_STRING_HASH_MAP_WITH_DECL(wxPdfTableDirectoryEntry*, wxPdfTableDirectory, class WXDLLIMPEXP_PDFDOC);
43
45class WXDLLIMPEXP_PDFDOC wxPdfCMapEntry
46{
47public:
49 wxPdfCMapEntry() : m_glyph(0), m_width(0) {}
50 int m_glyph;
51 int m_width;
52};
53
55WX_DECLARE_HASH_MAP_WITH_DECL(long, wxPdfCMapEntry*, wxIntegerHash, wxIntegerEqual, wxPdfCMap, class WXDLLIMPEXP_PDFDOC);
56
58class WXDLLIMPEXP_PDFDOC wxPdfFontParserTrueType : public wxPdfFontParser
59{
60public:
63
66
68
73 wxPdfFontData* IdentifyFont(const wxString& fontFileName, int fontIndex);
74
75#if defined(__WXMSW__) || defined(__WXMAC__)
77
81 wxPdfFontData* IdentifyFont(const wxFont& font);
82#endif
83
85
90 wxPdfFontData* IdentifyFont(const char* fontBuffer, size_t fontBufferSize);
91
93
99 bool LoadFontData(wxPdfFontData* fontData);
100
102
106 int GetCollectionFontCount(const wxString& fontFileName);
107
108#ifdef __WXMSW__
110
114 static wxMemoryInputStream* LoadTrueTypeFontStream(const wxFont& font);
115#endif
116
117protected:
119 void ClearTableDirectory();
120
122 void LockTable(const wxString& tableName);
123
125 void ReleaseTable();
126
128 int CalculateChecksum(const char* b, size_t length);
129
131 wxPdfFontData* IdentifyFont();
132
134 bool PrepareFontData(wxPdfFontData* fontData);
135
137 bool CheckTables();
138
140 void CheckCff();
141
143 void CheckRestrictions();
144
146
150 wxString GetBaseFont();
151
153
158 wxArrayString GetUniqueNames(int id);
159
161
170 wxArrayString GetNames(int id, bool namesOnly = true);
171
173
177 wxString GetEnglishName(int id);
178
180
184 bool ReadMaps();
185
187
194 bool ReadGlyphWidths(int numberOfHMetrics, int unitsPerEm);
195
197 void ReadKerning(int unitsPerEm);
198
200 bool ReadTableDirectory();
201
203 wxPdfCMap* ReadFormat0();
204
206 wxPdfCMap* ReadFormat4();
207
209 wxPdfCMap* ReadFormat6();
210
212 wxPdfCMap* ReadFormat12();
213
215 int GetGlyphWidth(unsigned int glyph);
216
218 wxPdfTableDirectory* m_tableDirectory;
219
221#if defined(__WXMAC__)
222#if wxPDFMACOSX_HAS_CORE_TEXT
223 CTFontRef m_fontRef;
224 wxCFRef<CFDataRef> m_tableRef;
225#endif
226#endif
227
228private:
229 bool m_cff;
230 size_t m_cffOffset;
231 size_t m_cffLength;
232
233 bool m_embedAllowed;
234 bool m_subsetAllowed;
235 bool m_isFixedPitch;
236
238
239 wxPdfArrayUint16 m_glyphWidths;
240 bool m_fontSpecific;
241 wxPdfCMap* m_cmap10;
242 wxPdfCMap* m_cmap31;
243 wxPdfCMap* m_cmapExt;
244 wxPdfKernPairMap* m_kp;
245
246 wxInputStream* m_savedStream;
247};
248
249#endif
Class representing a CMap table entry.
Definition: pdffontparsertruetype.h:46
int m_glyph
glyph number
Definition: pdffontparsertruetype.h:50
wxPdfCMapEntry()
Default constructor.
Definition: pdffontparsertruetype.h:49
int m_width
glyph width
Definition: pdffontparsertruetype.h:51
Base class for all fonts. (For internal use only)
Definition: pdffontdata.h:55
Class representing a font description.
Definition: pdffontdescription.h:24
Class representing a TrueType/OpenType font parser.
Definition: pdffontparsertruetype.h:59
bool m_isMacCoreText
Flag whether a Mac Core Text font is to be parsed.
Definition: pdffontparsertruetype.h:220
wxPdfTableDirectory * m_tableDirectory
table directory of the font
Definition: pdffontparsertruetype.h:218
size_t m_directoryOffset
offset of the table directory
Definition: pdffontparsertruetype.h:217
Class representing font parsers.
Definition: pdffontparser.h:25
Class representing a table directory entry for TrueType fonts (for internal use only)
Definition: pdffontparsertruetype.h:32
wxPdfTableDirectoryEntry()
Default constructor.
Definition: pdffontparsertruetype.h:35
int m_offset
Table offset.
Definition: pdffontparsertruetype.h:37
int m_checksum
Table checksum.
Definition: pdffontparsertruetype.h:36
int m_length
Table length.
Definition: pdffontparsertruetype.h:38
Compile time switches for the wxPdfDocument component.
Definition of font data.
Interface of the wxPdfFontDescription class.
Definition of Mac OS X specific font data handling.
Interface of the TrueType/OpenType font parsing support classes.
WX_DECLARE_STRING_HASH_MAP_WITH_DECL(wxPdfTableDirectoryEntry *, wxPdfTableDirectory, class WXDLLIMPEXP_PDFDOC)
Hash map class for used/embedded fonts.
WX_DECLARE_HASH_MAP_WITH_DECL(long, wxPdfCMapEntry *, wxIntegerHash, wxIntegerEqual, wxPdfCMap, class WXDLLIMPEXP_PDFDOC)
Hash map class for used/embedded fonts.