ADi-FontEngine  1.0
PDF Optimized FontEngine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PostScriptCMapData.h
Go to the documentation of this file.
1 // PostScriptEngine/PostScriptCMapData.h
2 //
3 // Copyright 2012 - Andreas Dippe
4 //
5 // This file is part of ADi-FontEngine, 2012
6 //-----------------------------------------------------------------------------
7 
8 #ifndef _POSTSCRIPTCMAPDATA_H_
9 #define _POSTSCRIPTCMAPDATA_H_
10 
12 
14 
15 #include <string>
16 #include <vector>
17 #include <map>
18 #include <set>
19 
20 namespace PostScript
21 {
26  typedef std::multiset< TCCodeRange > TCodeRangeSet;
27  //-----------------------------------------------------------------------------
28  /*! CMap files are defined by Adobe as PostScript files to contain encoding informations.
29  open source cmap files from <br><http://sourceforge.net/projects/cmap.adobe/files/>
30  \brief TCIDData is the cmap data template struct, used to keep cmap data bank class, the data are always simple key/value pairs
31  \param K the key type
32  \param V the value type
33  */
34  template< typename K, typename V >
35  struct TCIDData
36  {
37  typedef K key_type;
38  typedef V value_type;
39  //-----------------------------------------------------------------------------
40  //! enum to define the comparison selectors
41  enum ESelector
42  {
45  };
46  //-----------------------------------------------------------------------------
47  /*! \brief default ctor
48  */
50  {}
51  //-----------------------------------------------------------------------------
52  explicit TCIDData( const key_type & cr) // special if key_type equal to value_type
53  : _key( cr)
54  , _value( cr)
55  {}
56  //-----------------------------------------------------------------------------
57  /*! \brief ctor
58  \param cr a key
59  \param cc a value
60  */
61  TCIDData( const key_type & cr, const value_type & cc)
62  : _key( cr)
63  , _value( cc)
64  {}
65  //-----------------------------------------------------------------------------
66  /*! \brief to compare two objects of struct TCIDData
67  \param cidd instance to compare
68  \return true if this is equal to cidd
69  */
70  bool operator==( const TCIDData & cidd) const
71  {
72  return (_key == cidd._key) && (_value == cidd._value);
73  }
74  //-----------------------------------------------------------------------------
75  /*! \brief callback comparison function to sort TCIDData items into the data bank class, see struct TDBComp
76  \param d1 the first TCIDData item
77  \param d2 the second TCIDData item
78  \param sel the comparison selector, see ESelector
79  \return true if v1 < v2, depends from sel
80  */
81  bool operator()( const TCIDData & d1, const TCIDData & d2, ESelector sel) const
82  {
83  switch( sel) {
84  case eKey: return d1._key < d2._key;
85  case eValue: return d1._value < d2._value;
86  default: PostScript_Assert( false); break;
87  }
88  return false;
89  }
90  //-----------------------------------------------------------------------------
91  /*! \brief callback function called by data bank class before insert an TCIDData item, see struct TDBComp.
92  \param d2 the data bank TCIDData item to insert
93  \param sel the comparison selector, see ESelector
94  \return one of the EDBCompActionRes values to set insert action
95  */
97  {
98  (void)d2; // to avoid compiler warnings
99  switch( sel) {
102  default: PostScript_Assert( false); break;
103  }
105  }
106  //-----------------------------------------------------------------------------
107  key_type _key; //!< a key
108  value_type _value; //!< a value
109  };
110  //-----------------------------------------------------------------------------
111  //! the CMap data bank type definitions
112  typedef unsigned int TPSNameObjID;
123  //-----------------------------------------------------------------------------
124  //! the CMap storage struct keep all possible CMap data
126  {
127  TCodeRangeSet _codespacerangeset; //!< the "Code Space Range" data; key: char code; value: char code; used in Encoding and ToUnicode CMap's
128  TCCodeUNiBank _bfcharbank; //!< the "BF Char"; key: char code; value: unicode; data with unicode as value; used in ToUnicode CMap's
129  TRangeCCodeBank _bfrangebank; //!< the "BF Range"; key: char code range; value: unicode code range; used in ToUnicode CMap's
130  TCCodeNameBank _bfcharnamebank; //!< the "BF Char"; key: char code; value: PostScript glyph name; used in ToUnicode CMap's
131  TCCodeCIDBank _cidcharbank; //!< the "CID code" data; key: char code; value: cid; used in Encoding CMap's
132  TRangeCIDBank _cidrangebank; //!< the "CID code Range" data; key: char code range; value: cid range; used in Encoding CMap's
133  TCCodeCIDBank _notdefcharbank; //!< the ".notdef Char" data; key: char code; value: cid; used in Encoding CMap's
134  TRangeCIDBank _notdefrangebank; //!< the ".notdef Range" data; key: char code range; value: cid range; used in Encoding CMap's
135  };
136  //-----------------------------------------------------------------------------
137  typedef std::vector<int> TXUID;
138  //-----------------------------------------------------------------------------
139  //! CMap dict information
140  struct TCMapDict
141  {
142  //! the valid flags for all member to see what info is present in CMap file
143  enum EValid
144  {
145  ecmd_systeminfo //!< /CIDSystemInfo is present
146  , ecmd_si_registry //!< /CIDSystemInfo /Registry is present
147  , ecmd_si_ordering //!< /CIDSystemInfo /Ordering is present
148  , ecmd_si_supplement //!< /CIDSystemInfo /Registry is present
149  , ecmd_usecmap //!< /usecmap is present
150  , ecmd_cmapName //!< /CMapName is present
151  , ecmd_cmapVersion //!< /CMapVersion is present
152  , ecmd_cmapType //!< /CMapType is present
153  , ecmd_uidOffset //!< /UIDOffset is present
154  , ecmd_xuid //!< /XUID is present
155  , ecmd_wmode //!< /WMode is present
156  };
157  typedef std::bitset< ecmd_wmode + 1> TValidBSet;
158  //-----------------------------------------------------------------------------
159  /*! \brief default ctor
160  */
162  : _si_supplement( 0)
163  , _cmapVersion( 0)
164  , _cmapType( 0)
165  , _uidOffset( 0)
166  , _wmode( 0)
167  {}
168  //-----------------------------------------------------------------------------
169  TValidBSet _valid; //!< the valid bitset
170  std::string _si_registry; //!< /CIDSystemInfo /Registry text
171  std::string _si_ordering; //!< /CIDSystemInfo /Ordering text
172  int _si_supplement; //!< /CIDSystemInfo /Registry integer
173  std::string _usecmap; //!< /usecmap text another included CMap
174  std::string _cmapName; //!< /CMapName text name of the CMap
175  float _cmapVersion; //!< /CMapVersion version number
176  int _cmapType; //!< /CMapType 1 == Encoding CMap; 2 == ToUnicode CMap
177  int _uidOffset; //!< /UIDOffset integer
178  TXUID _xuid; //!< /XUID integer vector
179  int _wmode; //!< /WMode integer
180  };
181 
182 } // PostScript namespace
183 
184 #endif // _POSTSCRIPTCMAPDATA_H_
185 //-----------------------------------------------------------------------------
186 /*!\history
187 ** ADi-2012-12-14: creation
188 ** ADi-2013-01-25: add _piecesVec to doc
189 ** ADi-2013-06-27: Solaris compiler dont like underscore in front of an template parameter
190 ** ADi-2013-11-18: correct doxygen comments
191 */
std::bitset< ecmd_wmode+1 > TValidBSet
Definition: PostScriptCMapData.h:157
/CIDSystemInfo is present
Definition: PostScriptCMapData.h:145
TCIDData(const key_type &cr, const value_type &cc)
ctor
Definition: PostScriptCMapData.h:61
void PostScript_Assert(bool expr)
function to check program process no excption raise
Definition: PostScriptEngineError.h:103
/XUID is present
Definition: PostScriptCMapData.h:154
EDBCompActionRes operator()(const TCIDData &d2, ESelector sel) const
callback function called by data bank class before insert an TCIDData item, see struct TDBComp...
Definition: PostScriptCMapData.h:96
int _uidOffset
/UIDOffset integer
Definition: PostScriptCMapData.h:177
Definition: PostScriptCMapData.h:44
TCIDData()
default ctor
Definition: PostScriptCMapData.h:49
std::string _usecmap
/usecmap text another included CMap
Definition: PostScriptCMapData.h:173
int _wmode
/WMode integer
Definition: PostScriptCMapData.h:179
overwrite an existing item avoid duplicates
Definition: FontEngineDBank.h:28
EDBCompActionRes
The insert action enum, to set data bank behavior if a item will be inserted, modified or imported...
Definition: FontEngineDBank.h:25
TCMapDict()
default ctor
Definition: PostScriptCMapData.h:161
ESelector
enum to define the comparison selectors
Definition: PostScriptCMapData.h:41
/UIDOffset is present
Definition: PostScriptCMapData.h:153
TCIDData< TCCodeRange, TCIDRange > TRangeCID
Definition: PostScriptCMapData.h:121
/CIDSystemInfo /Registry is present
Definition: PostScriptCMapData.h:148
FontEngine::TRange< TCCode > TCCodeRange
Definition: PostScriptCMapData.h:23
/CMapName is present
Definition: PostScriptCMapData.h:150
TRangeCCodeBank _bfrangebank
the &quot;BF Range&quot;; key: char code range; value: unicode code range; used in ToUnicode CMap&#39;s ...
Definition: PostScriptCMapData.h:129
std::string _cmapName
/CMapName text name of the CMap
Definition: PostScriptCMapData.h:174
TCodeRangeSet _codespacerangeset
the &quot;Code Space Range&quot; data; key: char code; value: char code; used in Encoding and ToUnicode CMap&#39;...
Definition: PostScriptCMapData.h:127
FontEngine::TRange< unsigned short > TCIDRange
Definition: PostScriptCMapData.h:24
V value_type
Definition: PostScriptCMapData.h:38
TCCodeUNiBank _bfcharbank
the &quot;BF Char&quot;; key: char code; value: unicode; data with unicode as value; used in ToUnicode CMap&#39;s...
Definition: PostScriptCMapData.h:128
FontEngine::EDBCompActionRes EDBCompActionRes
Definition: PostScriptCMapData.h:25
TRangeCIDBank _cidrangebank
the &quot;CID code Range&quot; data; key: char code range; value: cid range; used in Encoding CMap&#39;s ...
Definition: PostScriptCMapData.h:132
unsigned int TPSNameObjID
the CMap data bank type definitions
Definition: PostScriptCMapData.h:112
TCIDData is the cmap data template struct, used to keep cmap data bank class, the data are always sim...
Definition: PostScriptCMapData.h:35
the CMap storage struct keep all possible CMap data
Definition: PostScriptCMapData.h:125
FontEngine::TDBank< TRangeCCode, TRangeCCode::ESelector, TRangeCCode::eValue+1, TRangeCCode > TRangeCCodeBank
Definition: PostScriptCMapData.h:120
/CIDSystemInfo /Registry is present
Definition: PostScriptCMapData.h:146
/CIDSystemInfo /Ordering is present
Definition: PostScriptCMapData.h:147
CMap dict information.
Definition: PostScriptCMapData.h:140
/CMapVersion is present
Definition: PostScriptCMapData.h:151
keep existing item discard new item
Definition: FontEngineDBank.h:29
int _si_supplement
/CIDSystemInfo /Registry integer
Definition: PostScriptCMapData.h:172
TCCodeCIDBank _cidcharbank
the &quot;CID code&quot; data; key: char code; value: cid; used in Encoding CMap&#39;s
Definition: PostScriptCMapData.h:131
std::string _si_registry
/CIDSystemInfo /Registry text
Definition: PostScriptCMapData.h:170
value_type _value
a value
Definition: PostScriptCMapData.h:108
FontEngine::TDBank< TRangeCID, TRangeCID::ESelector, TRangeCID::eValue+1, TRangeCID > TRangeCIDBank
Definition: PostScriptCMapData.h:122
TCIDData< TCCode, unsigned short > TCCodeCID
Definition: PostScriptCMapData.h:117
TCCodeNameBank _bfcharnamebank
the &quot;BF Char&quot;; key: char code; value: PostScript glyph name; used in ToUnicode CMap&#39;s ...
Definition: PostScriptCMapData.h:130
template class to keep small memory objects
Definition: FontEngineTCode.h:33
/usecmap is present
Definition: PostScriptCMapData.h:149
Definition: FontEngineTCode.h:432
std::vector< int > TXUID
Definition: PostScriptCMapData.h:137
TValidBSet _valid
the valid bitset
Definition: PostScriptCMapData.h:169
always insert the item, allow duplicates of same item
Definition: FontEngineDBank.h:27
TCIDData< TCCodeRange, TCCodeRange > TRangeCCode
Definition: PostScriptCMapData.h:119
FontEngine::TCharCode TCCode
Definition: PostScriptCMapData.h:22
int _cmapType
/CMapType 1 == Encoding CMap; 2 == ToUnicode CMap
Definition: PostScriptCMapData.h:176
std::multiset< TCCodeRange > TCodeRangeSet
Definition: PostScriptCMapData.h:26
TCCodeCIDBank _notdefcharbank
the &quot;.notdef Char&quot; data; key: char code; value: cid; used in Encoding CMap&#39;s
Definition: PostScriptCMapData.h:133
key_type _key
a key
Definition: PostScriptCMapData.h:107
/WMode is present
Definition: PostScriptCMapData.h:155
bool operator()(const TCIDData &d1, const TCIDData &d2, ESelector sel) const
callback comparison function to sort TCIDData items into the data bank class, see struct TDBComp ...
Definition: PostScriptCMapData.h:81
K key_type
Definition: PostScriptCMapData.h:37
TRangeCIDBank _notdefrangebank
the &quot;.notdef Range&quot; data; key: char code range; value: cid range; used in Encoding CMap&#39;s ...
Definition: PostScriptCMapData.h:134
float _cmapVersion
/CMapVersion version number
Definition: PostScriptCMapData.h:175
TCIDData< TCCode, TPSNameObjID > TCCodeName
Definition: PostScriptCMapData.h:113
FontEngine::TDBank< TCCodeUNi, TCCodeUNi::ESelector, TCCodeUNi::eValue+1, TCCodeUNi > TCCodeUNiBank
Definition: PostScriptCMapData.h:116
bool operator==(const TCIDData &cidd) const
to compare two objects of struct TCIDData
Definition: PostScriptCMapData.h:70
/CMapType is present
Definition: PostScriptCMapData.h:152
EValid
the valid flags for all member to see what info is present in CMap file
Definition: PostScriptCMapData.h:143
FontEngine::TDBank< TCCodeName, TCCodeName::ESelector, TCCodeName::eValue+1, TCCodeName > TCCodeNameBank
Definition: PostScriptCMapData.h:114
TXUID _xuid
/XUID integer vector
Definition: PostScriptCMapData.h:178
Definition: PostScriptCMapData.h:43
std::string _si_ordering
/CIDSystemInfo /Ordering text
Definition: PostScriptCMapData.h:171
TCIDData< TCCode, TCCode > TCCodeUNi
Definition: PostScriptCMapData.h:115
FontEngine::TDBank< TCCodeCID, TCCodeCID::ESelector, TCCodeCID::eValue+1, TCCodeCID > TCCodeCIDBank
Definition: PostScriptCMapData.h:118
TCIDData(const key_type &cr)
Definition: PostScriptCMapData.h:52
InsideFont and ADI-FontEngine : Andreas Dippe, © 2013
http://www.insidefont.de