~efargaspro/+junk/codeblocks-16.01-release

« back to all changes in this revision

Viewing changes to src/plugins/contrib/source_exporter/wxPdfDocument/include/wx/pdffontdatatype1.h

  • Committer: damienlmoore at gmail
  • Date: 2016-02-02 02:43:22 UTC
  • Revision ID: damienlmoore@gmail.com-20160202024322-yql5qmtbwdyamdwd
Code::BlocksĀ 16.01

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
///////////////////////////////////////////////////////////////////////////////
 
2
// Name:        pdffontdatatype1.h
 
3
// Purpose:     Definition of font data for Type1 fonts
 
4
// Author:      Ulrich Telle
 
5
// Modified by:
 
6
// Created:     2009-05-15
 
7
// Copyright:   (c) Ulrich Telle
 
8
// Licence:     wxWindows licence
 
9
///////////////////////////////////////////////////////////////////////////////
 
10
 
 
11
/// \file pdffontdatatype1.h Definition of font data for Type1 fonts
 
12
 
 
13
#ifndef _PDF_FONT_DATA_TYPE1_H_
 
14
#define _PDF_FONT_DATA_TYPE1_H_
 
15
 
 
16
// wxWidgets headers
 
17
#include <wx/strconv.h>
 
18
#include <wx/stream.h>
 
19
#include <wx/string.h>
 
20
#include <wx/xml/xml.h>
 
21
 
 
22
// wxPdfDocument headers
 
23
#include "wx/pdfdocdef.h"
 
24
#include "wx/pdfarraytypes.h"
 
25
#include "wx/pdffontdata.h"
 
26
 
 
27
WX_DECLARE_STRING_HASH_MAP_WITH_DECL(wxUint16, wxPdfFontType1GlyphWidthMap, class WXDLLIMPEXP_PDFDOC);
 
28
 
 
29
/// Class representing Type 1 fonts. (For internal use only)
 
30
class WXDLLIMPEXP_PDFDOC wxPdfFontDataType1 : public wxPdfFontData
 
31
{
 
32
public:
 
33
  ///< Default constructor
 
34
  wxPdfFontDataType1(wxMemoryInputStream* pfbStream = NULL);
 
35
 
 
36
  /// Default destructor
 
37
  virtual ~wxPdfFontDataType1();
 
38
 
 
39
  /// Get the width of a string
 
40
  /**
 
41
  * \param s the string for which the width should be calculated
 
42
  * \param encoding the character to glyph mapping
 
43
  * \param withKerning flag indicating whether kerning should be taken into account
 
44
  * \return the width of the string
 
45
  */
 
46
  virtual double GetStringWidth(const wxString& s, const wxPdfEncoding* encoding = NULL, bool withKerning = false) const;
 
47
 
 
48
  /// Check whether the font oan show all characters of a given string
 
49
  /**
 
50
  * \param s the string to be checked
 
51
  * \param encoding the character to glyph mapping
 
52
  * \return TRUE if the font can show all characters of the string, FALSE otherwise
 
53
  */
 
54
  virtual bool CanShow(const wxString& s, const wxPdfEncoding* encoding = NULL) const;
 
55
 
 
56
  /// Convert character codes to glyph numbers
 
57
  /**
 
58
  * \param s the string to be converted
 
59
  * \param encoding the character to glyph mapping
 
60
  * \param usedGlyphs the list of used glyphs
 
61
  * \param subsetGlyphs the mapping of glyphs to subset glyphs
 
62
  * \return the converted string
 
63
  */
 
64
  virtual wxString ConvertCID2GID(const wxString& s, const wxPdfEncoding* encoding, 
 
65
                                  wxPdfSortedArrayInt* usedGlyphs = NULL, 
 
66
                                  wxPdfChar2GlyphMap* subsetGlyphs = NULL) const;
 
67
 
 
68
  /// Load the font metrics XML file
 
69
  /**
 
70
  * \param root the root node of the XML font metric file
 
71
  * \return TRUE if the metric file could be processed successfully, FALSE otherwise
 
72
  */
 
73
  virtual bool LoadFontMetrics(wxXmlNode* root);
 
74
 
 
75
  /// Initialize font data
 
76
  /**
 
77
  * \return TRUE if the font data has been initialized successfully, FALSE otherwise
 
78
  */
 
79
  virtual bool Initialize();
 
80
 
 
81
  /// Get the character width array as string
 
82
  /**
 
83
  * \param subset flag whether subsetting is enabled
 
84
  * \param usedGlyphs the list of used glyphs
 
85
  * \param subsetGlyphs the mapping of glyphs to subset glyphs
 
86
  * \return the string representation of the character widths
 
87
  */
 
88
  virtual wxString GetWidthsAsString(bool subset = false, wxPdfSortedArrayInt* usedGlyphs = NULL, wxPdfChar2GlyphMap* subsetGlyphs = NULL) const;
 
89
 
 
90
#if wxUSE_UNICODE
 
91
  /// Get the character width array as string
 
92
  /**
 
93
  * \param glyphNames the list of glyph names available in the font
 
94
  * \param subset flag whether subsetting is enabled
 
95
  * \param usedGlyphs the list of used glyphs
 
96
  * \param subsetGlyphs the mapping of glyphs to subset glyphs
 
97
  * \return the string representation of the character widths
 
98
  */
 
99
  virtual wxString GetWidthsAsString(const wxArrayString& glyphNames, bool subset = false, wxPdfSortedArrayInt* usedGlyphs = NULL, wxPdfChar2GlyphMap* subsetGlyphs = NULL) const;
 
100
 
 
101
  /// Get a list of glyph names available in the font
 
102
  /**
 
103
  * \param[out] glyphNames the list of glyph names
 
104
  * \return TRUE if the glyph names are available, FALSE otherwise
 
105
  */
 
106
  virtual bool GetGlyphNames(wxArrayString& glyphNames) const;
 
107
#endif
 
108
 
 
109
  /// Write font data 
 
110
  /**
 
111
  * \param fontData the output stream
 
112
  * \param usedGlyphs the list of used glyphs
 
113
  * \param subsetGlyphs the mapping of glyphs to subset glyphs
 
114
  * \return the size of the written font data
 
115
  */
 
116
  virtual size_t WriteFontData(wxOutputStream* fontData, 
 
117
                               wxPdfSortedArrayInt* usedGlyphs = NULL, 
 
118
                               wxPdfChar2GlyphMap* subsetGlyphs = NULL);
 
119
 
 
120
  /// Write character/glyph to unicode mapping
 
121
  /**
 
122
  * \param mapData the output stream
 
123
  * \param encoding the character to glyph mapping
 
124
  * \param usedGlyphs the list of used glyphs
 
125
  * \param subsetGlyphs the mapping of glyphs to subset glyphs
 
126
  * \return the size of the written data
 
127
  */
 
128
  virtual size_t WriteUnicodeMap(wxOutputStream* mapData, 
 
129
                                 const wxPdfEncoding* encoding = NULL, 
 
130
                                 wxPdfSortedArrayInt* usedGlyphs = NULL, 
 
131
                                 wxPdfChar2GlyphMap* subsetGlyphs = NULL);
 
132
 
 
133
#if wxUSE_UNICODE
 
134
  /// Set the encoding type
 
135
  /**
 
136
  * \param encodingType the encoding type
 
137
  */
 
138
  void SetEncodingType(const wxString& encodingType) { m_encodingType = encodingType; }
 
139
 
 
140
  /// Get the encoding type
 
141
  /**
 
142
  * \return the encoding type
 
143
  */
 
144
  wxString GetEncodingType() const { return m_encodingType; }
 
145
 
 
146
  /// Set encoding map
 
147
  /**
 
148
  * \param encodingMap the encoding map
 
149
  */
 
150
  void SetEncodingMap(const wxArrayString& encodingMap) { m_encodingMap = encodingMap; }
 
151
 
 
152
  /// Get encoding map
 
153
  /**
 
154
  * \return the encoding map
 
155
  */
 
156
  wxArrayString GetEncodingMap() const { return m_encodingMap; }
 
157
 
 
158
  /// Set glyph width map
 
159
  /**
 
160
  * \param glyphWidthMap the map of glyph widths
 
161
  */
 
162
  void SetType1GlyphWidthMap(wxPdfFontType1GlyphWidthMap* glyphWidthMap) { m_glyphWidthMap = glyphWidthMap; }
 
163
 
 
164
  /// Get the associated encoding converter
 
165
  /**
 
166
  * \return the encoding converter associated with this font
 
167
  */
 
168
  virtual wxMBConv* GetEncodingConv() const { return m_conv; }
 
169
 
 
170
  /// Create the associated default encoding converter
 
171
  virtual void CreateDefaultEncodingConv();
 
172
#endif
 
173
 
 
174
protected:
 
175
  /// Compress the font data
 
176
  bool CompressFontData(wxOutputStream* fontData, wxInputStream* pfbFile);
 
177
 
 
178
#if wxUSE_UNICODE
 
179
  wxString      m_encodingType;                  ///< encoding type
 
180
  wxArrayString m_encodingMap;                   ///< encoding map
 
181
  wxArrayString m_glyphNames;                    ///< list of glyph names
 
182
  wxPdfFontType1GlyphWidthMap* m_glyphWidthMap;  ///< mapping of glyph widths
 
183
#endif
 
184
 
 
185
  wxMemoryInputStream* m_pfbStream; ///< Font stream in PFB format
 
186
  wxMBConv*            m_conv;      ///< Associated encoding converter
 
187
};
 
188
 
 
189
#endif