ADi-FontEngine  1.0
PDF Optimized FontEngine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FontEngineError.h
Go to the documentation of this file.
1 // FontEngine/FontEngineError.h
2 //
3 // Copyright 2012 - Andreas Dippe
4 //
5 // This file is part of ADi-FontEngine, 2012
6 //-----------------------------------------------------------------------------
7 
8 #ifndef FONTENGINEERROR_H
9 #define FONTENGINEERROR_H
10 
12 
13 #if defined(_WIN32) || defined(_M_X64)
14 # define NOMINMAX
15 # include <windows.h>
16 #elif defined( __APPLE__ )
17 # include <Carbon/Carbon.h>
18 #endif // defined(_WIN32) || defined(_M_X64)
19 
20 #include <bitset>
21 //-----------------------------------------------------------------------------
22 //-----------------------------------------------------------------------------
23 
24 namespace FontEngine
25 {
26  //! TrueType font problems, this could be a error or can be ignored
28  {
29  ettpMissing_cmap //!< ( 0) 'cmap' table is not available therfore no encoding info also
30  , ettpChecksum //!< ( 1) at least one of the table checksum is incorrect with exception of 'head'
31  , ettpFourByteBoundary //!< ( 2) at least one table offset begin not on a four byte boundary
32  , ettpPaddingNotZero //!< ( 3) at least one table padding bytes are not zero
33  , ettpWrong_hmtx //!< ( 4) the size of 'hmtx' table is wrong
34  , ettpMissAligned_cmap //!< ( 5) one cmap in font file is not aligned to four byte boundary
35  , ettpCompGRecursion //!< ( 6) wrong composite glyph, there is a self recursion into
36  , ettpmaxCompElements //!< ( 7) wrong maxComponentElements entry in maxp.
37  , ettpmaxCompDepth //!< ( 8) wrong maxComponentDepth entry in maxp
38 
40  };
41  typedef std::bitset<ettp_LAST_ENTRY> TTProblemBS;
42  //-----------------------------------------------------------------------------
43  //-----------------------------------------------------------------------------
44  //! CFF font problems, this could be a error or can be ignored
46  {
47  ecffpEmptySubrs //!< ( 0) font has empty Subrs data, a font without local subrs has no Subrs operator in the Private DICT.
48  , ecffpBlueArraySize //!< ( 1) any of BlueValues, OtherBlues, FamilyBlues, FamilyOtherBlues has wrong size must be multiple of 2
49  , ecffpBlueValues //!< ( 2) array of up to 7 pairs numbers
50  , ecffpOtherBlues //!< ( 3) array of up to 5 pairs numbers
51  , ecffpStemSnapH //!< ( 4) array of up to 12 real numbers
52  , ecffpStemSnapV //!< ( 5) array of up to 12 real numbers
53  , ecffpDict //!< ( 6) a dictionary (font | privat) is wrong
54  , ecffpDictInteger //!< ( 7) a dictionary (font | privat) is wrong, integer expected
55  , ecffpDictReal //!< ( 8) a dictionary (font | privat) is wrong, real number expected
56  , ecffpDictTwoByteOp //!< ( 9) a dictionary (font | privat) is wrong, two byte operator expected
57 
59  };
60  typedef std::bitset<ecffp_LAST_ENTRY> TCFFProblemBS;
61  //-----------------------------------------------------------------------------
62  //-----------------------------------------------------------------------------
63  //! FontEngine error codes
65  {
67 
68  , eUnknown = 1 //!< ( 1) Unknown error
69  , eNoOpenFont //!< ( 2) first open font
70  , eParameterFail //!< ( 3) wrong parameter
71  , eUserCancel //!< ( 4) user cancel command occur
72  , eWrongDBSelector //!< ( 5) wrong selector in dbank class
73  , eDBEntryExist //!< ( 6) dbank entry already exist
74  , eDBEntryInvalid //!< ( 7) dbank entry or iterator is invalid
75  , eDBIndexInvalid //!< ( 8) dbank direct index is invalid
76 
77  , ecffUnknown = 1000 //!< (1000) cff - Unknown error
78  , ecffHeader //!< (1001) cff - Header could not be read/write
79  , ecffNameIndex //!< (1002) cff - Name INDEX could not be read/write
80  , ecffTopDictIndex //!< (1003) cff - Top DICT INDEX could not be read/write
81  , ecffTopDictData //!< (1004) cff - Top DICT INDEX DATA could not be read
82  , ecffStringIndex //!< (1005) cff - String INDEX could not be read/write
83  , ecffGlobSubIndex //!< (1006) cff - Global Sub INDEX could not be read/write
84  , ecffLocaleSubIndex //!< (1007) cff - Locale Sub INDEX could not be read/write
85  , ecffCharStringIndex //!< (1008) cff - CharString INDEX could not be read/write
86  , ecffFDArrayIndex //!< (1009) cff - FDArray INDEX could not be read/write
87  , ecffFDSelectArray //!< (1010) cff - FDSelect array could not be read
88  , ecffFDSelectIdx //!< (1011) cff - FDSelect array index ist to large for FDArray
89  , ecffPrivate //!< (1012) cff - Private DICT could not be read/write
90  , ecffIntNumber //!< (1013) cff - Integer number expected
91  , ecffRealNumber //!< (1014) cff - BCD real number expected
92  , ecffTwoByteOperator //!< (1015) cff - Two byte operator expected
93  , ecffWrongEncoding //!< (1016) cff - Unable to read encoding data
94  , ecffWrongCharset //!< (1017) cff - Unable to read charset data
95  , ecffWrongCharstring //!< (1018) cff - Unable to read charstring data
96  , ecffCharstringEnd //!< (1019) cff - charstring ends with return
97  , ecffSubRNotFound //!< (1020) cff - a subroutione could not found
98  , ecffWrongOffset //!< (1021) cff - offset in INDEX is out of data range
99  , ecffWrite //!< (1022) cff - unable to write font file
100  , ecffNotANumber //!< (1023) cff - result of matrix calculation is undefined
101 
102  , ettUnknown = 2000 //!< (2000) tt - Unknown error
103  , ettHeader //!< (2001) tt - Header could not be read
104  , ettOffsetInvalid //!< (2002) tt - A given offset or lenght entry is out of file
105  , ettMagicNumber //!< (2003) tt - _magicNumber member in TT header missmatch
106  , ettMissRequiredTbl //!< (2004) tt - Required tables missing
107  , ettCFFOTPossible //!< (2005) tt - the font could be a CFF OpenType font
108  , ettCMap //!< (2006) tt - cmap struct could not be read
109  , ettLoca //!< (2007) tt - loca table is to short
110  , ettPostScript //!< (2008) tt - post table is invalid some pointer out of data
111  , ettRead //!< (2009) tt - unable to read from font file
112  , ettWrite //!< (2010) tt - unable to write font file
113  , ettInvalidCharCode //!< (2011) tt - Character Code is to big to use in simple font
114  , ettNoGlyphfound //!< (2012) tt - The font contains no glyph
115  , ettWrongAddress //!< (2013) tt - A caculated address into font is out of range
116  , ettWrongGID //!< (2014) tt - A given GID is unknown
117 
118  , et1Unknown = 3000 //!< (3000) t1 - Unknown error
119  , et1NoPostScript //!< (3001) t1 - invalid PostScript file
120  , et1NoFontDict //!< (3002) t1 - there is no font dictionary
121  , et1Semantic //!< (3003) t1 - semantic error in Type1 PostScript code, e.g. wrong "FontBBox" not 4 numbers
122  , et1WrongGlyphName //!< (3004) t1 - a CharStrings contain glyph without name key
123  , et1MissEncoding //!< (3005) t1 - the Encoding vector is required
124  , et1WrongEncoding //!< (3007) t1 - Encoding vector must be size of 256 and all objects are names
125  , et1OperandsLimit //!< (3008) t1 - The number of operands is bigger than 24, 24 is the limit for BuildChar operand stack
126  , et1FlexSubRFail //!< (3009) t1 - The flex subroutine has not right order or number
127  , et1GlobSubIndex //!< (3010) t1 - Global Sub INDEX could not be read
128  , et1WrongCharstring //!< (3011) t1 - Unable to read charstring data
129  , et1IntNumber //!< (3012) t1 - Integer number expected
130  , et1CharstringEnd //!< (3013) t1 - charstring ends with return
131  , et1OtherSubMissing //!< (3014) t1 - Unable to find other subroutine
132  , et1CIDSystemInfo //!< (3015) t1 - invalid CIDSystemInfo found
133  , et1MissCIDParam //!< (3016) t1 - CID font parameter is missing
134  , et1GlyphOverflow //!< (3017) t1 - CID glyph offset overflow
135 
136  , eencUnknown = 4000 //!< (4000) encoding - Unknown error
137  , eencCMap //!< (4001) encoding - CMap file is invalid
138  , eencETCPath //!< (4002) encoding - invalid cmap resource files lying in etc/Encoding folder
139 
140  , efcUnknown = 5000 //!< (5000) font cache - Unknown error
141  , efccPath //!< (5001) font cache - Cache file could not open
142  , efccCacheHeader //!< (5002) font cache - Wrong font cache file haeder
143  , efccCacheRead //!< (5003) font cache - Wrong font cache binaer file
144  , efccCacheEmpty //!< (5004) font cache - The font cache file contains no data
145  , efccInvalidIterator //!< (5005) font cache - The search iterator is invalid
146  , efccIndexInvalid //!< (5006) font cache - index is invalid
147  };
148  //-----------------------------------------------------------------------------
149  //! FontEngine C++ exception type
151  {
153  : errcode( ec)
154  {}
155  EErrorCodes errcode; //!< current error code
156  };
157  //-----------------------------------------------------------------------------
158  //-----------------------------------------------------------------------------
159  //-----------------------------------------------------------------------------
160 # if !(defined(_WIN32) || defined(__APPLE__)) // unix only
161  extern void fontengine_debug();
162 # endif
163  //-----------------------------------------------------------------------------
164  /*! \brief function to raise FontEngine exception
165  \param expr if false a exception with error code will be raised
166  \param errcode FontEngine error codes
167  \param dbg_break if true the program will stop if a debugger is present
168  */
169  inline void ThrowFontEngineException( bool expr, EErrorCodes errcode, bool dbg_break = true)
170  {
171  if( !expr) {
172 # if defined( _DEBUG)
173  static bool s_ignore( false);
174  static int s_errorcode( 1); // 1 == impossible
175 # ifdef WIN32
176  if( dbg_break && ::IsDebuggerPresent() && !s_ignore && (s_errorcode != errcode)) {
177  ::DebugBreak();
178  }
179 # elif defined( __APPLE__ )
180  if( dbg_break && !s_ignore && (s_errorcode != errcode)) {
181  ::Debugger();
182  }
183 # else // WIN32
184 # error (define_own_stuff_here)
185 # endif //def WIN32
186 # else // _DEBUG
187 # if defined(_WIN32) || defined(__APPLE__)
188  (void)dbg_break;
189 # else
190  fontengine_debug(); // unix only
191 # endif
192 # endif // _DEBUG
193  throw TFontError( errcode);
194  }
195  }
196  //-----------------------------------------------------------------------------
197  /*! \brief function to check program process no excption raise
198  \param expr if false the program will stop if a debugger is present
199  */
200  inline void FontEngine_Assert( bool expr)
201  {
202 # if defined( _DEBUG)
203  static bool s_ignore( false);
204  if( !expr) {
205 # ifdef WIN32
206  if( ::IsDebuggerPresent() && !s_ignore) {
207  ::DebugBreak();
208  }
209 # elif defined( __APPLE__ )
210  if( !s_ignore) {
211  ::Debugger();
212  }
213 # else // WIN32
214 # error (define_own_stuff_here)
215 # endif //def WIN32
216  }
217 # else // _DEBUG
218 # if defined(_WIN32) || defined(__APPLE__)
219  (void)expr;
220 # else
221  if( !expr)
222  fontengine_debug(); // unix_only
223 # endif
224 # endif // _DEBUG
225  }
226  //-----------------------------------------------------------------------------
227 
228 } // namespace FontEngine
229 
230 #endif // FONTENGINEERROR_H
231 //-----------------------------------------------------------------------------
232 /*!\history
233 ** ADi-2012-12-14: creation
234 ** ADi-2012-12-18: windows.h must be encapsulated
235 ** RGu-2012-12-18: added Carbon/Carbon.h on mac
236 ** ADi-2013-01-30: add ettWrongGID
237 ** ADi-2013-04-11: reduce compiler warning
238 ** ADi-2013-05-07: add enum ETTProblems to remember non fatal errors in "problem bitset" TTProblemBS
239 ** ADi-2013-05-22: add enum ECFFProblems to show errors in cff fonts
240 ** ADi-2013-06-25: export struct TFontError
241 ** HTh-2013-07-09: add enum efccPackedStruct (used for struct alignment or padding errors)
242 ** ADi-2013-07-12: code review and some small changes
243 ** HTh-2013-07-12: added unix debug support
244 ** ADi-2013-07-22: add ettpMissAligned_cmap
245 ** ADi-2013-08-30: some small changes
246 ** ADi-2013-09-24: BUG 0008930: add problem values
247 ** ADi-2013-10-16: use Windows NOMINMAX
248 */
(3011) t1 - Unable to read charstring data
Definition: FontEngineError.h:128
(1002) cff - Name INDEX could not be read/write
Definition: FontEngineError.h:79
(1009) cff - FDArray INDEX could not be read/write
Definition: FontEngineError.h:86
(1006) cff - Global Sub INDEX could not be read/write
Definition: FontEngineError.h:83
( 6) wrong composite glyph, there is a self recursion into
Definition: FontEngineError.h:35
(4001) encoding - CMap file is invalid
Definition: FontEngineError.h:137
(3015) t1 - invalid CIDSystemInfo found
Definition: FontEngineError.h:132
( 8) a dictionary (font | privat) is wrong, real number expected
Definition: FontEngineError.h:55
std::bitset< ettp_LAST_ENTRY > TTProblemBS
Definition: FontEngineError.h:41
(1022) cff - unable to write font file
Definition: FontEngineError.h:99
(1016) cff - Unable to read encoding data
Definition: FontEngineError.h:93
(2003) tt - _magicNumber member in TT header missmatch
Definition: FontEngineError.h:105
(1023) cff - result of matrix calculation is undefined
Definition: FontEngineError.h:100
(1004) cff - Top DICT INDEX DATA could not be read
Definition: FontEngineError.h:81
(2009) tt - unable to read from font file
Definition: FontEngineError.h:111
(1012) cff - Private DICT could not be read/write
Definition: FontEngineError.h:89
(5001) font cache - Cache file could not open
Definition: FontEngineError.h:141
( 5) one cmap in font file is not aligned to four byte boundary
Definition: FontEngineError.h:34
(3014) t1 - Unable to find other subroutine
Definition: FontEngineError.h:131
( 2) array of up to 7 pairs numbers
Definition: FontEngineError.h:49
void fontengine_debug()
(3001) t1 - invalid PostScript file
Definition: FontEngineError.h:119
(3009) t1 - The flex subroutine has not right order or number
Definition: FontEngineError.h:126
(3002) t1 - there is no font dictionary
Definition: FontEngineError.h:120
( 8) dbank direct index is invalid
Definition: FontEngineError.h:75
(1005) cff - String INDEX could not be read/write
Definition: FontEngineError.h:82
( 2) first open font
Definition: FontEngineError.h:69
( 4) user cancel command occur
Definition: FontEngineError.h:71
(3000) t1 - Unknown error
Definition: FontEngineError.h:118
( 0) &#39;cmap&#39; table is not available therfore no encoding info also
Definition: FontEngineError.h:29
(1013) cff - Integer number expected
Definition: FontEngineError.h:90
( 5) array of up to 12 real numbers
Definition: FontEngineError.h:52
( 6) dbank entry already exist
Definition: FontEngineError.h:73
( 8) wrong maxComponentDepth entry in maxp
Definition: FontEngineError.h:37
( 1) Unknown error
Definition: FontEngineError.h:68
(5002) font cache - Wrong font cache file haeder
Definition: FontEngineError.h:142
( 1) at least one of the table checksum is incorrect with exception of &#39;head&#39;
Definition: FontEngineError.h:30
(1011) cff - FDSelect array index ist to large for FDArray
Definition: FontEngineError.h:88
EErrorCodes errcode
current error code
Definition: FontEngineError.h:155
(2010) tt - unable to write font file
Definition: FontEngineError.h:112
(1015) cff - Two byte operator expected
Definition: FontEngineError.h:92
(2008) tt - post table is invalid some pointer out of data
Definition: FontEngineError.h:110
(1020) cff - a subroutione could not found
Definition: FontEngineError.h:97
( 5) wrong selector in dbank class
Definition: FontEngineError.h:72
(5004) font cache - The font cache file contains no data
Definition: FontEngineError.h:144
ETTProblems
TrueType font problems, this could be a error or can be ignored.
Definition: FontEngineError.h:27
(2014) tt - A given GID is unknown
Definition: FontEngineError.h:116
( 4) the size of &#39;hmtx&#39; table is wrong
Definition: FontEngineError.h:33
(2001) tt - Header could not be read
Definition: FontEngineError.h:103
Definition: FontEngineError.h:39
(5005) font cache - The search iterator is invalid
Definition: FontEngineError.h:145
(1014) cff - BCD real number expected
Definition: FontEngineError.h:91
(3013) t1 - charstring ends with return
Definition: FontEngineError.h:130
Definition: FontEngineError.h:58
(3017) t1 - CID glyph offset overflow
Definition: FontEngineError.h:134
( 7) a dictionary (font | privat) is wrong, integer expected
Definition: FontEngineError.h:54
(1018) cff - Unable to read charstring data
Definition: FontEngineError.h:95
(2007) tt - loca table is to short
Definition: FontEngineError.h:109
(4000) encoding - Unknown error
Definition: FontEngineError.h:136
TFontError(EErrorCodes ec)
Definition: FontEngineError.h:152
(3016) t1 - CID font parameter is missing
Definition: FontEngineError.h:133
(3007) t1 - Encoding vector must be size of 256 and all objects are names
Definition: FontEngineError.h:124
(1017) cff - Unable to read charset data
Definition: FontEngineError.h:94
(4002) encoding - invalid cmap resource files lying in etc/Encoding folder
Definition: FontEngineError.h:138
( 3) wrong parameter
Definition: FontEngineError.h:70
( 4) array of up to 12 real numbers
Definition: FontEngineError.h:51
(3003) t1 - semantic error in Type1 PostScript code, e.g. wrong &quot;FontBBox&quot; not 4 numbers ...
Definition: FontEngineError.h:121
(5006) font cache - index is invalid
Definition: FontEngineError.h:146
(2004) tt - Required tables missing
Definition: FontEngineError.h:106
(3005) t1 - the Encoding vector is required
Definition: FontEngineError.h:123
void FontEngine_Assert(bool expr)
function to check program process no excption raise
Definition: FontEngineError.h:200
std::bitset< ecffp_LAST_ENTRY > TCFFProblemBS
Definition: FontEngineError.h:60
( 2) at least one table offset begin not on a four byte boundary
Definition: FontEngineError.h:31
(2000) tt - Unknown error
Definition: FontEngineError.h:102
( 6) a dictionary (font | privat) is wrong
Definition: FontEngineError.h:53
(3010) t1 - Global Sub INDEX could not be read
Definition: FontEngineError.h:127
(1019) cff - charstring ends with return
Definition: FontEngineError.h:96
void ThrowFontEngineException(bool expr, EErrorCodes errcode, bool dbg_break=true)
function to raise FontEngine exception
Definition: FontEngineError.h:169
(2002) tt - A given offset or lenght entry is out of file
Definition: FontEngineError.h:104
(1010) cff - FDSelect array could not be read
Definition: FontEngineError.h:87
( 3) at least one table padding bytes are not zero
Definition: FontEngineError.h:32
(2013) tt - A caculated address into font is out of range
Definition: FontEngineError.h:115
( 3) array of up to 5 pairs numbers
Definition: FontEngineError.h:50
(5000) font cache - Unknown error
Definition: FontEngineError.h:140
FontEngine C++ exception type.
Definition: FontEngineError.h:150
#define FONTENGINE_EXPORTS
Definition: FontEngineDLL.h:20
ECFFProblems
CFF font problems, this could be a error or can be ignored.
Definition: FontEngineError.h:45
(1021) cff - offset in INDEX is out of data range
Definition: FontEngineError.h:98
(1000) cff - Unknown error
Definition: FontEngineError.h:77
(1008) cff - CharString INDEX could not be read/write
Definition: FontEngineError.h:85
( 9) a dictionary (font | privat) is wrong, two byte operator expected
Definition: FontEngineError.h:56
(1001) cff - Header could not be read/write
Definition: FontEngineError.h:78
(2006) tt - cmap struct could not be read
Definition: FontEngineError.h:108
( 0) font has empty Subrs data, a font without local subrs has no Subrs operator in the Private DICT...
Definition: FontEngineError.h:47
(2011) tt - Character Code is to big to use in simple font
Definition: FontEngineError.h:113
EErrorCodes
FontEngine error codes.
Definition: FontEngineError.h:64
( 1) any of BlueValues, OtherBlues, FamilyBlues, FamilyOtherBlues has wrong size must be multiple of ...
Definition: FontEngineError.h:48
( 7) dbank entry or iterator is invalid
Definition: FontEngineError.h:74
(2005) tt - the font could be a CFF OpenType font
Definition: FontEngineError.h:107
(5003) font cache - Wrong font cache binaer file
Definition: FontEngineError.h:143
(3012) t1 - Integer number expected
Definition: FontEngineError.h:129
Definition: FontEngineError.h:66
(1007) cff - Locale Sub INDEX could not be read/write
Definition: FontEngineError.h:84
(3008) t1 - The number of operands is bigger than 24, 24 is the limit for BuildChar operand stack ...
Definition: FontEngineError.h:125
(1003) cff - Top DICT INDEX could not be read/write
Definition: FontEngineError.h:80
(2012) tt - The font contains no glyph
Definition: FontEngineError.h:114
( 7) wrong maxComponentElements entry in maxp.
Definition: FontEngineError.h:36
(3004) t1 - a CharStrings contain glyph without name key
Definition: FontEngineError.h:122
InsideFont and ADI-FontEngine : Andreas Dippe, © 2013
http://www.insidefont.de