ADi-FontEngine  1.0
PDF Optimized FontEngine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FontEngineEncoding.h
Go to the documentation of this file.
1 // FontEngine/FontEngineEncoding.h
2 //
3 // Copyright 2012 - Andreas Dippe
4 //
5 // This file is part of ADi-FontEngine, 2012
6 //-----------------------------------------------------------------------------
7 
8 #ifndef FONTENGINEENCODING_H
9 #define FONTENGINEENCODING_H
10 
14 
15 #include <string>
16 #include <vector>
17 
18 //-----------------------------------------------------------------------------
19 //-----------------------------------------------------------------------------
20 
21 namespace FontEngine
22 {
23 
24  /*! \brief abstract class interface from Character-Code to Unicode converter
25  */
27  {
28  /*! \brief virtual dtor
29  */
30  virtual ~TToUNiCodeEnc()
31  {}
32  //-----------------------------------------------------------------------------
33  /*! \brief get a Unicode from given Char-Code
34  \param charcode the given Char-Code to get Unicode
35  \return the Unicode if empty no Unicode will be available
36  */
37  virtual TCharCode getUNiCode( const TCharCode & charcode) const = 0;
38  //-----------------------------------------------------------------------------
39  /*! \brief get a Char-Code from given Unicode
40  \param uni the given Unicode to get Char-Code
41  \return the Char-Code if empty no Char-Code will be available
42  */
43  virtual TCharCode getCharCode( const TCharCode & uni) const = 0;
44  };
45  //-----------------------------------------------------------------------------
46  /*! \brief get Character-Code to Unicode converter instance pointer
47  \param platform the platfoem id, see OpenType Spec <br><http://www.microsoft.com/typography/otspec/name.htm>
48  \param encoding the encoding id, see OpenType Spec
49  \param cmaprespath the file path to encoding CMap files
50  \return a Character-Code to Unicode converter instance or NULL if not such exist
51  */
52  const TToUNiCodeEnc* const getToUNiCodeEncoder( unsigned int platform, unsigned int encoding, const std::wstring & cmaprespath);
53  //-----------------------------------------------------------------------------
54  //-----------------------------------------------------------------------------
55  /*! \brief abstract class interface from CID to Unicode converter. CID's are Character Collection for CID-Keyed fonts from Adobe saved in CMap files
56  */
58  {
59  typedef unsigned short TCID;
60  typedef std::vector<TCharCode> TCharCodeVec;
61  //-----------------------------------------------------------------------------
62  /*! \brief virtual dtor
63  */
64  virtual ~TCIDToUNiCode()
65  {}
66  //-----------------------------------------------------------------------------
67  /*! \brief get a Unicode from given CID
68  \param cid the given CID to get Unicode
69  \return the Unicode if empty no Unicode will be available
70  */
71  virtual TCharCode getUNiCode( TCID cid) const = 0;
72  //-----------------------------------------------------------------------------
73  /*! \brief get a Unicodes from given CID, if more than one Unicode are available
74  \param cid the given CID to get Unicode
75  \return the Unicodes if empty no Unicode will be available
76  */
77  virtual TCharCodeVec getUNiCodes( TCID cid) const = 0;
78  //-----------------------------------------------------------------------------
79  /*! \brief get a CID from given Unicode
80  \param uni the given Unicode to get CID
81  \return the CID if 0 no CID will be available, this is .notdef
82  */
83  virtual TCID getCID( const TCharCode & uni) const = 0;
84  };
85  //-----------------------------------------------------------------------------
86  /*! \brief get CID to Unicode converter instance pointer
87  \param registry name of the registrar of the character collection.
88  \param ordering unique name for this specified registry.
89  \param cmaprespath the file path to CMap files
90  \param vert_wmode if true get converter for vertical write mode
91  \return a CID to Unicode converter instance or NULL if not such exist
92  */
93  FONTENGINE_EXPORTS const TCIDToUNiCode* const getCIDToUNiCode( const char* registry, const char* ordering, const std::wstring & cmaprespath, bool vert_wmode = false);
94  //-----------------------------------------------------------------------------
95  //-----------------------------------------------------------------------------
96  /*! \brief try to convert some used unicode combinations to single ligature unicode
97  U+0066 U+0066 ==> U+fb00;
98  U+0066 U+0069 ==> U+fb01;
99  U+0066 U+006c ==> U+fb02;
100  U+017f U+0074 ==> U+fb05;
101  U+0073 U+0074 ==> U+fb06;
102  U+0066 U+0066 U+0069 ==> U+fb03;
103  U+0066 U+0069 U+006c ==> U+fb04;
104  \param unicode the given Unicode, will be changed by the function
105  \return true if ligature was found
106  */
108  //-----------------------------------------------------------------------------
109  //-----------------------------------------------------------------------------
110  /*! \brief get utf8 encoded unicode string from wstring
111  \param text the wstring to convert
112  \return utf8 encoded unicode string
113  */
114  FONTENGINE_EXPORTS std::string getUTF8Text( const std::wstring & text);
115  //-----------------------------------------------------------------------------
116  /*! \brief get sys encoded unicode string from wstring
117  \param text the wstring to convert
118  \return sys encoded unicode string
119  */
120  FONTENGINE_EXPORTS std::string getSysText( const std::wstring & text);
121  //-----------------------------------------------------------------------------
122  /*! \brief get wstring from utf8 encoded unicode string
123  \param text pointer to utf8 encoded unicode string
124  \param textlen the length of utf8 encoded unicode string
125  \return wstring
126  */
127  FONTENGINE_EXPORTS std::wstring getUCS2Text( const char* text, unsigned int textlen);
128  //-----------------------------------------------------------------------------
129  /*! \brief get wstring from utf8 encoded unicode string
130  \param text pointer to utf8 encoded unicode string
131  \return wstring
132  */
133  inline std::wstring getUCS2Text( const std::string & text)
134  {
135  return getUCS2Text( text.c_str(), text.size());
136  }
137  //-----------------------------------------------------------------------------
138  /*! \brief get wstring from TrueType name string
139  \param platform the platfoem id, see OpenType Spec <br><http://www.microsoft.com/typography/otspec/name.htm>
140  \param encoding the encoding id, see OpenType Spec
141  \param text TrueType name string
142  \param len the length of TrueType name string
143  \return wstring of TrueType name string
144  */
145  FONTENGINE_EXPORTS std::wstring getEncodedTTName( unsigned int platform, unsigned int encoding, const char* text, unsigned int len);
146  //-----------------------------------------------------------------------------
147  /*! \brief get wstring from string buffer could be contain 2 byte character also, the format is certain by encoding.
148  \param platform the platfoem id, see OpenType Spec <br><http://www.microsoft.com/typography/otspec/name.htm>
149  \param encoding the encoding id, see OpenType Spec
150  \param text TrueType name string
151  \param big_endian must be true if text contains 2 byte character with big endian order
152  \return wstring of TrueType name string
153  */
154  FONTENGINE_EXPORTS std::wstring getEncodedText( unsigned int platform, unsigned int encoding, const std::string & text, bool big_endian);
155  //-----------------------------------------------------------------------------
156 
157 } // FontEngine
158 
159 #endif // FONTENGINEENCODING_H
160 //-----------------------------------------------------------------------------
161 /*!\history
162 ** ADi-2012-12-14: creation
163 ** ADi-2013-01-25: add TToUNiCodeEnc::getCharCode(..)
164 ** ADi-2013-04-19: add TCIDToUNiCode::getUNiCodes(..) to get all possible unicodes from given cid
165 ** ADi-2013-05-02: function getCIDToUNiCode(..) must regard horz/vert write order
166 ** ADi-2013-06-25: add some FONTENGINE_EXPORTS
167 ** ADi-2013-11-18: correct doxygen comments
168 */
virtual TCharCode getUNiCode(const TCharCode &charcode) const =0
get a Unicode from given Char-Code
virtual ~TToUNiCodeEnc()
virtual dtor
Definition: FontEngineEncoding.h:30
FONTENGINE_EXPORTS std::string getUTF8Text(const std::wstring &text)
get utf8 encoded unicode string from wstring
virtual TCharCode getCharCode(const TCharCode &uni) const =0
get a Char-Code from given Unicode
virtual ~TCIDToUNiCode()
virtual dtor
Definition: FontEngineEncoding.h:64
FONTENGINE_EXPORTS bool checkLatinLigature(TCharCode &unicode)
try to convert some used unicode combinations to single ligature unicode U+0066 U+0066 ==&gt; U+fb00; U+...
const TToUNiCodeEnc *const getToUNiCodeEncoder(unsigned int platform, unsigned int encoding, const std::wstring &cmaprespath)
get Character-Code to Unicode converter instance pointer
FONTENGINE_EXPORTS std::wstring getEncodedTTName(unsigned int platform, unsigned int encoding, const char *text, unsigned int len)
get wstring from TrueType name string
abstract class interface from Character-Code to Unicode converter
Definition: FontEngineEncoding.h:26
FONTENGINE_EXPORTS std::string getSysText(const std::wstring &text)
get sys encoded unicode string from wstring
FONTENGINE_EXPORTS const TCIDToUNiCode *const getCIDToUNiCode(const char *registry, const char *ordering, const std::wstring &cmaprespath, bool vert_wmode=false)
get CID to Unicode converter instance pointer
std::vector< TCharCode > TCharCodeVec
Definition: FontEngineEncoding.h:60
unsigned short TCID
Definition: FontEngineEncoding.h:59
template class to keep small memory objects
Definition: FontEngineTCode.h:33
FONTENGINE_EXPORTS std::wstring getEncodedText(unsigned int platform, unsigned int encoding, const std::string &text, bool big_endian)
get wstring from string buffer could be contain 2 byte character also, the format is certain by encod...
FONTENGINE_EXPORTS std::wstring getUCS2Text(const char *text, unsigned int textlen)
get wstring from utf8 encoded unicode string
#define FONTENGINE_EXPORTS
Definition: FontEngineDLL.h:20
abstract class interface from CID to Unicode converter. CID&#39;s are Character Collection for CID-Keyed ...
Definition: FontEngineEncoding.h:57
FontEngine::TCode TCharCode
Definition: FontEngineTypes.h:30
InsideFont and ADI-FontEngine : Andreas Dippe, © 2013
http://www.insidefont.de