ADi-FontEngine  1.0
PDF Optimized FontEngine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FontEngineTypes.h
Go to the documentation of this file.
1 // FontEngine/FontEngineTypes.h
2 //
3 // Copyright 2012 - Andreas Dippe
4 //
5 // This file is part of ADi-FontEngine, 2012
6 //-----------------------------------------------------------------------------
7 
8 #ifndef FONTENGINETYPES_H
9 #define FONTENGINETYPES_H
10 
14 
15 #include <vector>
16 #include <string>
17 #include <bitset>
18 #include <set>
19 #include <iostream>
20 #include <iomanip>
21 
22 //-----------------------------------------------------------------------------
23 //-----------------------------------------------------------------------------
24 
25 namespace FontEngine
26 {
27 
28  typedef std::vector<double> TNumberVec;
29  typedef std::basic_string<char> TBlock;
32  //-----------------------------------------------------------------------------
33  //-----------------------------------------------------------------------------
34  typedef std::pair<const char*, unsigned int> TPSName;
35  typedef std::wstring TPath;
36  typedef std::vector< TPath > TPathVec;
37  typedef std::set< std::string > TAltNameSet;
38  typedef std::pair<unsigned short, bool> TUShortBoolRes;
39  //-----------------------------------------------------------------------------
40  //-----------------------------------------------------------------------------
41  //! struct to keep glyph width info
42  struct TWidth
43  {
44  /*! \brief default ctor
45  \param width is glyph width
46  \param defw (get functions) true if default width is used or (set functions) set these width value in glyph description
47  */
48  TWidth( double width = 0, bool defw = false)
49  : _width( width)
50  , _defw( defw)
51  {}
52  //-----------------------------------------------------------------------------
53  double _width; //!< the glyph width
54  bool _defw; //!< is true if default width is used
55  };
56  //-----------------------------------------------------------------------------
57  //-----------------------------------------------------------------------------
58  //!< Description of TCoordVec path command vector, number of entries determine what does it mean
59  //!< 1. size is 3: a move command consumer must close open path first [x, y, dummy]
60  //!< 2. size is 2: a lineto command [x, y]
61  //!< 3. Size is 6: a bezier curve [x1 y1 x2 y2 x3 y3]
62  //!< 4. Size is 1: a hinting index + 1, a negative value show a vertical stem into _vstem else it is a horizontal stem into _hstem
64  typedef std::vector<TCoordVec> TPointsVec;
65  typedef std::pair<double, double> TStemPair;
66  typedef std::vector<TStemPair> TStemVec;
67  //-----------------------------------------------------------------------------
68  //-----------------------------------------------------------------------------
69  //! struct to keep glyph outline, width and stem hint info
70  struct TGOutline
71  {
72  /*! \brief default ctor
73  \param gw a glyph width
74  */
75  TGOutline( const TWidth & gw = TWidth())
76  : _gw( gw)
77  {}
78  //-----------------------------------------------------------------------------
79  TPointsVec _gcurves; //!< the glyph contour data see TPointsVec
80  TWidth _gw; //!< the glyph width see TWidth
81  TStemVec _hstem; //!< the horizontal stem hint value pairs if present
82  TStemVec _vstem; //!< the vertical stem hint value pairs if present
83  };
84  //-----------------------------------------------------------------------------
85  //-----------------------------------------------------------------------------
86  //! struct to keep single 2D point
87  struct TFPoint
88  {
89  /*! \brief default ctor
90  \param x coordinate
91  \param y coordinate
92  */
93  TFPoint( double x = 0, double y = 0)
94  : _x( x)
95  , _y( y)
96  {}
97  //-----------------------------------------------------------------------------
98  double _x; //!< x coordinate
99  double _y; //!< y coordinate
100  };
101  //-----------------------------------------------------------------------------
102  //-----------------------------------------------------------------------------
103  //! struct to keep rectangle
104  struct TBBox
105  {
106  /*! \brief default ctor
107  */
109  : _left( 0.0)
110  , _bottom( 0.0)
111  , _right( 0.0)
112  , _top( 0.0)
113  {}
114  //-----------------------------------------------------------------------------
115  double _left; //!< left edge coordinate
116  double _bottom; //!< bottom edge coordinate
117  double _right; //!< right edge coordinate
118  double _top; //!< top edge coordinate
119  };
120  //-----------------------------------------------------------------------------
121  //-----------------------------------------------------------------------------
122  //! struct to keep glyph bounding box and width
123  struct TGlyphBox
124  {
125  /*! \brief default ctor
126  */
128  : _numContour( 0)
129  {}
130  //-----------------------------------------------------------------------------
131  TBBox _bbox; //!< the glyph bounding box will provide a smallest rectangle around the glyph
132  TWidth _gw; //!< the glyph width see TWidth
133  unsigned int _numContour; //!< the number of contours to draw the glyph
134  };
135  //-----------------------------------------------------------------------------
136  //-----------------------------------------------------------------------------
137  //! enum to interpret dump result entries, this is a metainfo to get context information
139  {
140  edtGeneric //!< ( 0) any type
141  , edtHeadline //!< ( 1) Headline
142  , edtStringUTF8 //!< ( 1) UTF8 encoded string
143 
144  , edtCFFCard8 //!< ( 2) [0 - 255] 1-byte unsigned number
145  , edtCFFOffSize //!< ( 3) [1 - 4] 1-byte unsigned number specifies the size of an Offset field or fields
146  , edtCFFCard16 //!< ( 4) [0 - 65535] 2-byte unsigned number
147  , edtCFFSID //!< ( 5) [0 - 64999] 2-byte string identifier
148  , edtCFFOffset //!< ( 6) varies 1, 2, 3, or 4 byte offset (specified by OffSize field)
149  , edtCFFGID //!< ( 7) a glyph index, (charsets, encodings, and glyphs are related in CFF as 3 “parallel” arrays that are indexed in unison)
150  , edtCFFOperator //!< ( 8) one or two byte operator
151  , edtCFFBoolean //!< ( 9) operators operant, integer type with the values 0 (false) and 1 (true)
152  , edtCFFNumber //!< (10) operators operant, integer or real number
153  , edtCFFArray //!< (11) operators operant array, one or more numbers
154  , edtCFFDelta //!< (12) operators operant, a number or a delta-encoded array of numbers
155  , edtCFFDictData //!< (13) Font dictionary data comprising key-value pairs
156  , edtCFFINDEXData //!< (14) An INDEX is an array of variable-sized objects.
157  , edtCFFFDArray //!< (15) the FDArray data
158  , edtCFFFDSelect //!< (16) the FDSelect data
159  , edtCFFGlyph //!< (17) CFF glyph
160  // Tpye1 PosScript
161  , edtT1Operator = 100 //!< (100) one or two byte Fype1 operator
162  , edtPSOperator //!< (101) PostScript operator
163  , edtT1Null //!< (102) operators operant, boolean value
164  , edtT1Boolean //!< (103) operators operant, boolean value
165  , edtT1Fixed //!< (104) operators operant, fixed number
166  , edtT1Integer //!< (105) operators operant, integer number
167  , edtT1Name //!< (106) PostScript name
168  , edtT1String //!< (107) PostScript string
169  , edtT1Array //!< (108) PostScript array
170  , edtT1Dictionary //!< (109) PostScript dictionary
171  , edtT1Procedure //!< (110) PostScript procedure
172  , edtT1Glyph //!< (111) T1 glyph
173  , edtT1FontName //!< (112) CID fontname from FDArray FontInfo dict
174  , edtT1GlyphData //!< (112) CID GlyphData string in CID font
175  // TrueTpye
176  , edtTTDirectory = 200 //!< (200) The TrueType table directory
177  , edtTTBYTE //!< (201) 8-bit unsigned integer.
178  , edtTTCHAR //!< (202) 8-bit signed integer.
179  , edtTTUSHORT //!< (203) 16-bit unsigned integer.
180  , edtTTSHORT //!< (204) 16-bit signed integer.
181  , edtTTULONG //!< (205) 32-bit unsigned integer.
182  , edtTTLONG //!< (206) 32-bit signed integer.
183  , edtTTFIXED //!< (207) 32-bit signed fixed-point number (16.16)
184  , edtTTFUNIT //!< (208) Smallest measurable distance in the em space.
185  , edtTTFWORD //!< (209) 16-bit signed integer (SHORT) that describes a quantity in FUnits.
186  , edtTTUFWORD //!< (210) Unsigned 16-bit integer (USHORT) that describes a quantity in FUnits.
187  , edtTTF2DOT14 //!< (211) 16-bit signed fixed number with the low 14 bits of fraction (2.14).
188  , edtTTLONGDATETIME //!< (212) Date represented in number of seconds since 12:00 midnight, January 1, 1904. The value is represented as a signed 64-bit integer.
189  , edtTTTableHead //!< (213) the tabel directory entry head
190  , edtTTBitEnable //!< (214) a single bit from bitfield with enable state
191  , edtTTBitDisable //!< (215) a single bit from bitfield with disable state
192  , edtTTGlyphName //!< (216) a glyph name used by PostScript table
193  , edtTTGlyphCoord //!< (217) TT glyph coordinate
194  , edtTTGlyphMtx //!< (218) TT composite glyph matrix
195  , edtTTGlyphEmpty //!< (219) TT empty glyph
196  , edtTTGlyph //!< (220) TT glyph
197  , edtTTNumContour //!< (221) "Number of contour" metadata dump line
198 
199  };
200  //-----------------------------------------------------------------------------
201  //-----------------------------------------------------------------------------
202  //! the glyph data struct, used as main type in font cache data bank class
203  struct TGlyph
204  {
205  //! enum to define the comparison selectors
207  {
208  egsGID //!< create a gid (glyph index) primary key set
209  , egsCharCode //!< create a character code primary key set
210  , egsPSName //!< create a glyph PostScript name primary key set
211  , egsUnicode //!< create a unicode primary key set
212  , egsCID //!< create a cid (character collection id) primary key set
213  };
214  //-----------------------------------------------------------------------------
215  //!< enum to get info about valid member or not
216  enum EGValid
217  {
218  egvGID //!< if set _gid is valid
219  , egvCharCode //!< if set _charcode is valid
220  , egvPSName //!< if set _psname is valid
221  , egvUnicode //!< if set _unicode is valid
222  , egvCID //!< if set _cid is valid
223  , egvTTEmpty //!< empty TrueType glyph, without any contour
224  };
225  typedef std::bitset< egvTTEmpty + 1> TValidBS;
226  //-----------------------------------------------------------------------------
227  /*! \brief default ctor
228  */
230  : _gid( 0)
231  , _cid( 0)
232  {}
233  //-----------------------------------------------------------------------------
234  /*! \brief ctor
235  \param ccode a character code
236  \param unicode a unicode
237  \param gid a glyph index
238  \param psname a glyph PostScript name
239  \param cid a character collection id
240  */
241  TGlyph( const TCharCode & ccode, const TCharCode & unicode, unsigned int gid, const std::string & psname, unsigned short cid)
243  , _gid( gid)
244  , _charcode( ccode)
245  , _psname( psname)
246  , _unicode( unicode)
247  , _cid( cid)
248  {}
249  //-----------------------------------------------------------------------------
250  /*! \brief callback comparison function to sort TGlyph items into the data bank class, see struct TDBComp
251  \param g1 the first TGlyph item
252  \param g2 the second TGlyph item
253  \param sel the comparison selector, see EGSelector
254  \return true if v1 < v2, depends from sel
255  */
256  bool operator()( const TGlyph & g1, const TGlyph & g2, EGSelector sel) const
257  {
258  switch( sel) {
259  case egsGID: return g1._gid < g2._gid;
260  case egsCharCode: return g1._charcode < g2._charcode;
261  case egsPSName: return g1._psname < g2._psname;
262  case egsUnicode: return TUNiDataEval()( g1._unicode, g2._unicode);
263  case egsCID: return g1._cid < g2._cid;
264  default: FontEngine_Assert( false); break;
265  }
266  return false;
267  }
268  //-----------------------------------------------------------------------------
269  /*! \brief callback function called by data bank class before insert an TGlyph item, see struct TDBComp.
270  \param g the data bank TGlyph item to insert
271  \param sel the comparison selector, see EGSelector
272  \return one of the EDBCompActionRes values to set insert action
273  */
275  {
276  switch( sel) {
277  case egsGID: break;
279  case egsPSName: return !g._psname.empty() ? edbaInsertAlways : edbaInsertNever;
281  case egsCID: return (0 < g._cid) ? edbaInsertAlways : edbaInsertNever;
282  default: FontEngine_Assert( false); break;
283  }
284  return edbaInsertAlways;
285  }
286  //-----------------------------------------------------------------------------
287  TValidBS _vmask; //!< the valid mask see EGSelector
288  unsigned int _gid; //!< [0 - 65535] valid range, to mark it as unknown glyph use any number greater as number of glyphs in current font
289  TCharCode _charcode; //!< character code used by this glyph is depends from encoding
290  std::string _psname; //!< PostScript name of glyph if present or needed
291  TCharCode _unicode; //!< the unicode derived from internal font encoding or PostScript
292  unsigned short _cid; //!< [in] the cid (character collection id) in cid fonts
293  };
294  //-----------------------------------------------------------------------------
295  //! the font cache data bank type definition, good sample for TDBank template class
297  //-----------------------------------------------------------------------------
298  //-----------------------------------------------------------------------------
299  //! The ignore marker to select ignore state for platform, encoding and/or language parameter
301  {
302  enimIgnore = 0xffff //!< ignore marker for platform, encoding and/or language parameter
303  };
304  //-----------------------------------------------------------------------------
305  //! the enum to encoding settings, to understand the sense see OpenType Spec <br><http://www.microsoft.com/typography/otspec/name.htm>
306  struct TEncInfo
307  {
308  /*! \brief default ctor
309  \param platform platform id
310  \param encoding encoding id depends from platform
311  \param language language id depends from platform and encoding
312  */
313  TEncInfo( unsigned short platform = enimIgnore, unsigned short encoding = enimIgnore, unsigned short language = enimIgnore)
314  : _platform( platform)
315  , _encoding( encoding)
316  , _language( language)
317  {}
318  //-----------------------------------------------------------------------------
319  unsigned short _platform; //!< 0 = Unicode, 1 = Macintosh, 2 = ISO [deprecated], 3 = Windows, 4 = Custom; (same as define in OpenType fonts)
320  unsigned short _encoding; //!< depends from _platform; (same as define in OpenType fonts)
321  unsigned short _language; //!< (same as define in OpenType fonts)
322  };
323  typedef std::vector<TEncInfo> TEncInfoVec;
324  //-----------------------------------------------------------------------------
325  //! struct glyph data bank with encoding information
326  struct TEncGlyph : public TEncInfo
327  {
328  /*! \brief default ctor
329  \param platform platform id
330  \param encoding encoding id depends from platform
331  \param language language id depends from platform and encoding
332  */
333  TEncGlyph( unsigned short platform = enimIgnore, unsigned short encoding = enimIgnore, unsigned short language = enimIgnore)
334  : TEncInfo( platform, encoding, language)
335  {}
336  //-----------------------------------------------------------------------------
337  TGlyphDBank _ccodeGIDVec; //!< the glyph data bank contains all glyph informations defined in this encoding
338  };
339  typedef std::vector<TEncGlyph> TEncGlyphVec;
340  //-----------------------------------------------------------------------------
341  //-----------------------------------------------------------------------------
342  typedef std::pair<TEncInfo, TGlyph> TGInfo;
343  typedef std::vector<TGInfo> TGInfoVec;
344  //-----------------------------------------------------------------------------
345  //-----------------------------------------------------------------------------
346  //! dump result entry struct keep information about one dump entity
348  {
349  /*! \brief default ctor
350  \param level the depth in dump hierarchy this will be a tree architecture
351  \param length the length of the text string of this entry
352  */
353  TDumpEntry( unsigned char level = 0, int length = 0)
354  : _type( edtGeneric)
355  , _id( 0)
356  , _length( (0 > length) ? 0 : length)
357  , _level( level)
358  {}
359  //-----------------------------------------------------------------------------
360  EDumpType _type; //!< the dump entrie type see EDumpType
361  unsigned int _id; //!< the id is the text begin position of this entry into dump text
362  int _length; //!< the length of the text string of this entry
363  unsigned char _level; //!< the depth in dump hierarchy this will be a tree architecture
364  };
365  //-----------------------------------------------------------------------------
366  //-----------------------------------------------------------------------------
367  //! dump parameter struct to select all dump feature
369  {
370  //!< enum used as bit mask to steer the dump output format
371  enum EInFlag
372  {
373  edpWithGlyphs = 0x01 //!< fill glyph information
374  , edpNoLevelTabs = 0x02 //!< insert no level tabs in front of each text string
375  , edpNoEntryVec = 0x04 //!< don't fill the _entryVec member
376  , edpOTgetTT = 0x08 //!< get the TrueType part of an OpenType font if 'cff ' table is available
377  , edpBinary = 0x10 //!< add binary glyph data into _bin
378  , edpDisasm = 0x20 //!< add disassembler binary glyph data in comand line (cff only)
379  };
380  //-----------------------------------------------------------------------------
381  typedef std::vector<TDumpEntry> TDumpEntryVec;
382  //-----------------------------------------------------------------------------
383  /*! \brief default ctor
384  */
385  explicit TDumpParam()
386  : _inflags( 0)
387  , _endl( 1, '\n')
388  {}
389  //-----------------------------------------------------------------------------
390  unsigned char _inflags; //!< copy of input bit mast, see EInFlag
391  std::string _dumptext; //!< the dump text storage
392  TDumpEntryVec _entryVec; //!< the entry vector to interpret the dump text
393  std::string _endl; //!< the end of line marker used in dum text could be empty no such needed, default is newline '\n'
394  std::string _bin; //!< storage to keep all bytes used by this glyph to parse, filled if edpBinary is set in _inflags
395  };
396  //-----------------------------------------------------------------------------
397  //-----------------------------------------------------------------------------
398  //! enum to define possible font output format type used by font write functions
400  {
401  efotCFF //!< simple CFF font, valid character codes rage are [0 - 255]
402  , efotCIDCFF //!< CID CFF font, valid character codes rage are [0 - 65535]
403 // , efotType1 //!< not supported will be converted to cff
404  , efotTrueType //!< simple TrueType font, valid character codes rage are [0 - 255]
405  , efotCIDTrueType //!< CID TrueType font, valid character codes rage are [0 - 65535]
406  };
407  //-----------------------------------------------------------------------------
408  //! struct to define glyph decriptions inclusive outline data for input or modify new or existing glyphs
409  struct TEmbFontData : public TGlyph
410  {
411  /*! \brief ctor
412  \param unicode a unicode
413  \param charcode a character code
414  \param gwidth the glyph width
415  \param psname a glyph PostScript name
416  \param gid a glyph index
417  \param cid a character collection id
418  */
419  TEmbFontData( const TCharCode & unicode, const TCharCode & charcode, double gwidth, const std::string & psname, unsigned int gid, unsigned short cid)
420  : TGlyph( charcode, unicode, gid, psname, cid)
421  , _goutline( TWidth( gwidth, true))
422  , _newgid( gid)
423  {}
424  //-----------------------------------------------------------------------------
425  /*! \brief ctor
426  \param glyph the glyph traits to copy
427  */
428  TEmbFontData( const TGlyph & glyph)
429  : TGlyph( glyph)
430  , _newgid( glyph._gid)
431  {}
432  //-----------------------------------------------------------------------------
433  TGOutline _goutline; //!< [in] the glyph outline can be empty if font should be subset and font type doesn't change
434  unsigned int _newgid; //!< [out] [0 - 65535] valid range, if glyph must be moved to a new gid
435  };
436  //-----------------------------------------------------------------------------
437  typedef std::vector<TEmbFontData> TEmbFontDataVec;
438  //-----------------------------------------------------------------------------
439  //-----------------------------------------------------------------------------
440  //! enum to config some font output traits if font should be converted, subseted or created
442  {
443  eeffSymbol //!< the font is declared as symbol font
444  , eeffPDF1_4Compliant //!< in PDF 1.4 symbol TrueType fonts should contain a (1,0) instead of (3,0) cmap
445  , eeffPostScript //!< create PostScript 'post' information in TrueType font file
446  , eeffHiResTT //!< if font converted from CFF to TrueType the cubic bezier curves will be split into 4 pieces instead of 2
447  , eeffUseGNames //!< if font is a cff font force use of PostScript glyph names instead of gid's (glyph index id)
448  };
449  typedef std::bitset< eeffUseGNames + 1 > EEmbFontFlags;
450  //-----------------------------------------------------------------------------
451  //! contains parameter to create new font or subset existing font
453  {
454  /*! \brief ctor
455  \param fontname the new font name to subset font, will be ignored in font creating functions
456  \param eff the flags to config output traits, see EEmbFontFlags
457  */
458  TEmbFontParameter( const std::string & fontname, const EEmbFontFlags & eff)
459  : _fontname( fontname)
460  , _fontOutType( FontEngine::efotCFF)
461  , _embFFlags( eff)
462  , _supplement( 0)
463  {}
464  //-----------------------------------------------------------------------------
465  std::string _fontname; //!< UTF-8 encoded; the new font name in subset process, will be ignored in font creating functions
466  EFontOutType _fontOutType; //!< font output format to convert to, see EFontOutType
467  TEmbFontDataVec _embFontDataVec; //!< contains data from needed glyphs to subset or create, see TEmbFontData
468  EEmbFontFlags _embFFlags; //!< flags to config output traits, see EEmbFontFlags
469  std::string _registry; //!< UTF-8 encoded; to subset or create a CID font keep the Register key from CIDSystemInfo
470  std::string _ordering; //!< UTF-8 encoded; to subset or create a CID font keep the Ordering key from CIDSystemInfo
471  int _supplement; //!< to subset or create a CID font keep the Supplement key from CIDSystemInfo
472  };
473  //-----------------------------------------------------------------------------
474  //-----------------------------------------------------------------------------
475  //! enum to define various characteristics of a font, derived from PDF format, see also FontDescriptor Flags <br><http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf>
477  {
478  epdfFixedPitch = 0x00000001 //!< All glyphs have the same width (as opposed to proportional or variable-pitch fonts, which have different widths).
479  , epdfSerif = 0x00000002 //!< Glyphs have serifs, which are short strokes drawn at an angle on the top and bottom of glyph stems. (Sans serif fonts do not have serifs.)
480  , epdfSymbolic = 0x00000004 //!< Font contains glyphs outside the Adobe standard Latin character set. This flag and the Nonsymbolic flag shall not both be set or both be clear.
481  , epdfScript = 0x00000008 //!< Glyphs resemble cursive handwriting.
482  , epdfNonsymbolic = 0x00000020 //!< Font uses the Adobe standard Latin character set or a subset of it.
483  , epdfItalic = 0x00000040 //!< Glyphs have dominant vertical strokes that are slanted.
484  , epdfAllCap = 0x00010000 //!< Font contains no lowercase letters; typically used for display purposes, such as for titles or headlines.
485  , epdfSmallCap = 0x00020000 //!< Font contains both uppercase and lowercase letters. The glyphs for the lowercase letters have the same shapes as the corresponding uppercase letters, but they are sized.
486  , epdfForceBold = 0x00040000 //!< Shall determine whether bold glyphs shall be painted with extra pixels even at very small text sizes.
487  };
488  typedef unsigned int TPDFFontFlags; //!< combination of bits from EPDFFontFlags
489  //-----------------------------------------------------------------------------
490  //! contain font properties, derived from PDF format, see also FontDescriptor <br><http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf>
492  {
493  /*! \brief default ctor
494  */
496  : _pdfflags( 0)
497  , _italicangle( 0)
498  , _fontweight( 400) // "Regular"
499  , _ascent( 0)
500  , _descent( 0)
501  , _capheight( 0)
502  , _xheight( 0)
503  , _stemv( 0)
504  {}
505  //-----------------------------------------------------------------------------
506  std::string _fontname; //!< UTF-8 encoded; the font name
507  std::string _fontfamily; //!< UTF-8 encoded; the font family name
508  TPDFFontFlags _pdfflags; //!< the font characteristics as bit mask (same as in PDF FontDescriptor), see EPDFFontFlags
509  TBBox _fontbox; //!< the font bounding box all glyphs must be inside these rectangle
510  double _italicangle; //!< a font angle to describe angle of italic or oblique fonts shall be 0 if unknown
511  double _fontweight; //!< the font weigth, possible values shall be 100, 200, 300, 400, 500, 600, 700, 800, or 900
512  double _ascent; //!< the maximum height above the baseline
513  double _descent; //!< the maximum depth below the baseline, shall be nagativ or 0
514  double _capheight; //!< the vertical coordinate of the top of flat capital letters from baseline (like the letter H)
515  double _xheight; //!< the vertical coordinate of the top of flat nonascending lowercase letters (like the letter x)
516  double _stemv; //!< the horizontally thickness of the dominant vertical stems of glyphs in the font. In TrueType fonts this will be calculated form _fontweight
517  };
518  //-----------------------------------------------------------------------------
519  //! the length of the three parts of PostScript Type 1 fonts
521  {
522  unsigned int _len1; //!< The length in bytes of the clear-text portion of the Type 1 font program.
523  unsigned int _len2; //!< The length in bytes of the encrypted portion of the Type 1 font program.
524  unsigned int _len3; //!< The length in bytes of the fixed-content portion of the Type 1 font program.
525  //!< If this is 0, it indicates that the 512 zeros and cleartomark have not been included in the font program.
526  };
527 
528 } // namespace FontEngine
529 
530 //-----------------------------------------------------------------------------
531 //-----------------------------------------------------------------------------
532 /*! \brief global stream out operator for FontEngine::TCharCode as hex encoded string
533  \param os the out stream
534  \param charcode the FontEngine::TCharCode instance
535  \return the out stream instance
536 */
537 inline std::ostream & operator<<( std::ostream & os, const FontEngine::TCharCode & charcode)
538 {
539  FontEngine::TCharCode::TCodeData cd( charcode);
540 
541  for( unsigned int i = 0; i < cd.second; ++i)
542  os << std::hex << /*std::uppercase <<*/ std::setfill( '0') << std::setw( 2) << static_cast<unsigned int>( cd.first[i]) << std::dec;
543  return os;
544 }
545 //-----------------------------------------------------------------------------
546 
547 #endif // FONTENGINETYPES_H
548 //-----------------------------------------------------------------------------
549 /*!\history
550 ** ADi-2012-12-14: creation
551 ** ADi-2013-01-02: struct TEmbFontData need new ctor
552 ** ADi-2013-01-25: add struct T1PiecesLength
553 ** ADi-2013-02-22: bugfix append glyph and dump
554 ** ADi-2013-04-15: add comment at epdfForceBold
555 ** ADi-2013-05-22: add egvTTEmpty in enum EGValid
556 ** ADi-2013-06-05: add FontEngine::edtTTNumContour
557 ** ADi-2013-07-01: correct TNumberVec typedef
558 ** ADi-2013-07-23: remove obsolete function TBBox::size()
559 ** ADi-2013-08-30: some new types
560 ** ADi-2013-09-25: add typedef TBlock
561 ** ADi-2013-10-07: add typedef TGInfo and TGInfoVec and add member 'bin' in struct TDumpParam
562 ** ADi-2013-11-18: correct doxygen comments
563 */
std::string _dumptext
the dump text storage
Definition: FontEngineTypes.h:391
(107) PostScript string
Definition: FontEngineTypes.h:168
(105) operators operant, integer number
Definition: FontEngineTypes.h:166
in PDF 1.4 symbol TrueType fonts should contain a (1,0) instead of (3,0) cmap
Definition: FontEngineTypes.h:444
double _italicangle
a font angle to describe angle of italic or oblique fonts shall be 0 if unknown
Definition: FontEngineTypes.h:510
Font contains glyphs outside the Adobe standard Latin character set. This flag and the Nonsymbolic fl...
Definition: FontEngineTypes.h:480
create PostScript &#39;post&#39; information in TrueType font file
Definition: FontEngineTypes.h:445
(13) Font dictionary data comprising key-value pairs
Definition: FontEngineTypes.h:155
(201) 8-bit unsigned integer.
Definition: FontEngineTypes.h:177
std::string _bin
storage to keep all bytes used by this glyph to parse, filled if edpBinary is set in _inflags ...
Definition: FontEngineTypes.h:394
double _descent
the maximum depth below the baseline, shall be nagativ or 0
Definition: FontEngineTypes.h:513
std::pair< const char *, unsigned int > TPSName
Definition: FontEngineTypes.h:34
(213) the tabel directory entry head
Definition: FontEngineTypes.h:189
(104) operators operant, fixed number
Definition: FontEngineTypes.h:165
(110) PostScript procedure
Definition: FontEngineTypes.h:171
TWidth(double width=0, bool defw=false)
default ctor
Definition: FontEngineTypes.h:48
unsigned short _cid
[in] the cid (character collection id) in cid fonts
Definition: FontEngineTypes.h:292
contains parameter to create new font or subset existing font
Definition: FontEngineTypes.h:452
(204) 16-bit signed integer.
Definition: FontEngineTypes.h:180
create a gid (glyph index) primary key set
Definition: FontEngineTypes.h:208
unsigned char _inflags
copy of input bit mast, see EInFlag
Definition: FontEngineTypes.h:390
EFontOutType _fontOutType
font output format to convert to, see EFontOutType
Definition: FontEngineTypes.h:466
TEmbFontParameter(const std::string &fontname, const EEmbFontFlags &eff)
ctor
Definition: FontEngineTypes.h:458
(108) PostScript array
Definition: FontEngineTypes.h:169
(203) 16-bit unsigned integer.
Definition: FontEngineTypes.h:179
(208) Smallest measurable distance in the em space.
Definition: FontEngineTypes.h:184
create a cid (character collection id) primary key set
Definition: FontEngineTypes.h:212
(10) operators operant, integer or real number
Definition: FontEngineTypes.h:152
EDBCompActionRes
The insert action enum, to set data bank behavior if a item will be inserted, modified or imported...
Definition: FontEngineDBank.h:25
unsigned short _language
(same as define in OpenType fonts)
Definition: FontEngineTypes.h:321
(106) PostScript name
Definition: FontEngineTypes.h:167
unsigned int TPDFFontFlags
combination of bits from EPDFFontFlags
Definition: FontEngineTypes.h:488
double _capheight
the vertical coordinate of the top of flat capital letters from baseline (like the letter H) ...
Definition: FontEngineTypes.h:514
( 4) [0 - 65535] 2-byte unsigned number
Definition: FontEngineTypes.h:146
struct to keep glyph bounding box and width
Definition: FontEngineTypes.h:123
unsigned int _gid
[0 - 65535] valid range, to mark it as unknown glyph use any number greater as number of glyphs in cu...
Definition: FontEngineTypes.h:288
bool operator()(const TGlyph &g1, const TGlyph &g2, EGSelector sel) const
callback comparison function to sort TGlyph items into the data bank class, see struct TDBComp ...
Definition: FontEngineTypes.h:256
TEmbFontData(const TCharCode &unicode, const TCharCode &charcode, double gwidth, const std::string &psname, unsigned int gid, unsigned short cid)
ctor
Definition: FontEngineTypes.h:419
EGSelector
enum to define the comparison selectors
Definition: FontEngineTypes.h:206
struct to keep single 2D point
Definition: FontEngineTypes.h:87
CID TrueType font, valid character codes rage are [0 - 65535].
Definition: FontEngineTypes.h:405
if set _psname is valid
Definition: FontEngineTypes.h:220
std::vector< TEmbFontData > TEmbFontDataVec
Definition: FontEngineTypes.h:437
std::pair< TEncInfo, TGlyph > TGInfo
Definition: FontEngineTypes.h:342
double _right
right edge coordinate
Definition: FontEngineTypes.h:117
TGlyphDBank _ccodeGIDVec
the glyph data bank contains all glyph informations defined in this encoding
Definition: FontEngineTypes.h:337
Font contains no lowercase letters; typically used for display purposes, such as for titles or headli...
Definition: FontEngineTypes.h:484
(112) CID GlyphData string in CID font
Definition: FontEngineTypes.h:174
( 0) any type
Definition: FontEngineTypes.h:140
Glyphs have dominant vertical strokes that are slanted.
Definition: FontEngineTypes.h:483
std::vector< TCoordVec > TPointsVec
Definition: FontEngineTypes.h:64
TFPoint(double x=0, double y=0)
default ctor
Definition: FontEngineTypes.h:93
( 7) a glyph index, (charsets, encodings, and glyphs are related in CFF as 3 “parallel” arrays that are...
Definition: FontEngineTypes.h:149
EDBCompActionRes operator()(const TGlyph &g, EGSelector sel) const
callback function called by data bank class before insert an TGlyph item, see struct TDBComp...
Definition: FontEngineTypes.h:274
(217) TT glyph coordinate
Definition: FontEngineTypes.h:193
TDumpEntryVec _entryVec
the entry vector to interpret the dump text
Definition: FontEngineTypes.h:392
the glyph data struct, used as main type in font cache data bank class
Definition: FontEngineTypes.h:203
(216) a glyph name used by PostScript table
Definition: FontEngineTypes.h:192
EFontOutType
enum to define possible font output format type used by font write functions
Definition: FontEngineTypes.h:399
(17) CFF glyph
Definition: FontEngineTypes.h:159
TDBank< TGlyph, TGlyph::EGSelector, TGlyph::egsCID+1, TGlyph > TGlyphDBank
the font cache data bank type definition, good sample for TDBank template class
Definition: FontEngineTypes.h:296
std::vector< TGInfo > TGInfoVec
Definition: FontEngineTypes.h:343
the enum to encoding settings, to understand the sense see OpenType Spec http://www.microsoft.com/typography/otspec/name.htm
Definition: FontEngineTypes.h:306
( 5) [0 - 64999] 2-byte string identifier
Definition: FontEngineTypes.h:147
CID CFF font, valid character codes rage are [0 - 65535].
Definition: FontEngineTypes.h:402
std::string _fontname
UTF-8 encoded; the font name.
Definition: FontEngineTypes.h:506
(206) 32-bit signed integer.
Definition: FontEngineTypes.h:182
std::string _fontfamily
UTF-8 encoded; the font family name.
Definition: FontEngineTypes.h:507
TGlyphBox()
default ctor
Definition: FontEngineTypes.h:127
(15) the FDArray data
Definition: FontEngineTypes.h:157
contain font properties, derived from PDF format, see also FontDescriptor http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/PDF32000_2008.pdf
Definition: FontEngineTypes.h:491
(214) a single bit from bitfield with enable state
Definition: FontEngineTypes.h:190
TDumpEntry(unsigned char level=0, int length=0)
default ctor
Definition: FontEngineTypes.h:353
unsigned short _platform
0 = Unicode, 1 = Macintosh, 2 = ISO [deprecated], 3 = Windows, 4 = Custom; (same as define in OpenTyp...
Definition: FontEngineTypes.h:319
TBBox()
default ctor
Definition: FontEngineTypes.h:108
unsigned short _encoding
depends from _platform; (same as define in OpenType fonts)
Definition: FontEngineTypes.h:320
bool empty() const
return the empty buffer state
Definition: FontEngineTCode.h:206
dump parameter struct to select all dump feature
Definition: FontEngineTypes.h:368
the font is declared as symbol font
Definition: FontEngineTypes.h:443
bool _defw
is true if default width is used
Definition: FontEngineTypes.h:54
Font uses the Adobe standard Latin character set or a subset of it.
Definition: FontEngineTypes.h:482
TPDFFontFlags _pdfflags
the font characteristics as bit mask (same as in PDF FontDescriptor), see EPDFFontFlags ...
Definition: FontEngineTypes.h:508
dump result entry struct keep information about one dump entity
Definition: FontEngineTypes.h:347
( 1) Headline
Definition: FontEngineTypes.h:141
Shall determine whether bold glyphs shall be painted with extra pixels even at very small text sizes...
Definition: FontEngineTypes.h:486
std::string _ordering
UTF-8 encoded; to subset or create a CID font keep the Ordering key from CIDSystemInfo.
Definition: FontEngineTypes.h:470
TCharCode _unicode
the unicode derived from internal font encoding or PostScript
Definition: FontEngineTypes.h:291
empty TrueType glyph, without any contour
Definition: FontEngineTypes.h:223
std::vector< TEncGlyph > TEncGlyphVec
Definition: FontEngineTypes.h:339
(218) TT composite glyph matrix
Definition: FontEngineTypes.h:194
EGValid
&lt; enum to get info about valid member or not
Definition: FontEngineTypes.h:216
double _xheight
the vertical coordinate of the top of flat nonascending lowercase letters (like the letter x) ...
Definition: FontEngineTypes.h:515
std::vector< TPath > TPathVec
Definition: FontEngineTypes.h:36
All glyphs have the same width (as opposed to proportional or variable-pitch fonts, which have different widths).
Definition: FontEngineTypes.h:478
unsigned char _level
the depth in dump hierarchy this will be a tree architecture
Definition: FontEngineTypes.h:363
double _left
left edge coordinate
Definition: FontEngineTypes.h:115
struct to keep glyph outline, width and stem hint info
Definition: FontEngineTypes.h:70
TBBox _bbox
the glyph bounding box will provide a smallest rectangle around the glyph
Definition: FontEngineTypes.h:131
std::basic_string< char > TBlock
Definition: FontEngineTypes.h:29
Definition: FontEngineTCode.h:485
( 9) operators operant, integer type with the values 0 (false) and 1 (true)
Definition: FontEngineTypes.h:151
(220) TT glyph
Definition: FontEngineTypes.h:196
TGlyph()
default ctor
Definition: FontEngineTypes.h:229
(210) Unsigned 16-bit integer (USHORT) that describes a quantity in FUnits.
Definition: FontEngineTypes.h:186
ignore marker for platform, encoding and/or language parameter
Definition: FontEngineTypes.h:302
unsigned int _len3
Definition: FontEngineTypes.h:524
if font converted from CFF to TrueType the cubic bezier curves will be split into 4 pieces instead of...
Definition: FontEngineTypes.h:446
(219) TT empty glyph
Definition: FontEngineTypes.h:195
Glyphs resemble cursive handwriting.
Definition: FontEngineTypes.h:481
simple CFF font, valid character codes rage are [0 - 255]
Definition: FontEngineTypes.h:401
simple TrueType font, valid character codes rage are [0 - 255]
Definition: FontEngineTypes.h:404
( 1) UTF8 encoded string
Definition: FontEngineTypes.h:142
if set _charcode is valid
Definition: FontEngineTypes.h:219
(16) the FDSelect data
Definition: FontEngineTypes.h:158
(211) 16-bit signed fixed number with the low 14 bits of fraction (2.14).
Definition: FontEngineTypes.h:187
keep existing item discard new item
Definition: FontEngineDBank.h:29
double _top
top edge coordinate
Definition: FontEngineTypes.h:118
std::ostream & operator<<(std::ostream &os, const FontEngine::TCharCode &charcode)
global stream out operator for FontEngine::TCharCode as hex encoded string
Definition: FontEngineTypes.h:537
(200) The TrueType table directory
Definition: FontEngineTypes.h:176
TEncInfo(unsigned short platform=enimIgnore, unsigned short encoding=enimIgnore, unsigned short language=enimIgnore)
default ctor
Definition: FontEngineTypes.h:313
std::vector< TDumpEntry > TDumpEntryVec
Definition: FontEngineTypes.h:381
unsigned int _numContour
the number of contours to draw the glyph
Definition: FontEngineTypes.h:133
std::string _fontname
UTF-8 encoded; the new font name in subset process, will be ignored in font creating functions...
Definition: FontEngineTypes.h:465
template class to keep small memory objects
Definition: FontEngineTCode.h:33
std::string _registry
UTF-8 encoded; to subset or create a CID font keep the Register key from CIDSystemInfo.
Definition: FontEngineTypes.h:469
the length of the three parts of PostScript Type 1 fonts
Definition: FontEngineTypes.h:520
TWidth _gw
the glyph width see TWidth
Definition: FontEngineTypes.h:132
unsigned int _len2
The length in bytes of the encrypted portion of the Type 1 font program.
Definition: FontEngineTypes.h:523
struct to keep glyph width info
Definition: FontEngineTypes.h:42
TGlyph(const TCharCode &ccode, const TCharCode &unicode, unsigned int gid, const std::string &psname, unsigned short cid)
ctor
Definition: FontEngineTypes.h:241
std::vector< TUNiValue > TUNiData
Definition: FontEngineTCode.h:47
if set _cid is valid
Definition: FontEngineTypes.h:222
std::vector< double > TNumberVec
Definition: FontEngineTypes.h:28
TDumpParam()
default ctor
Definition: FontEngineTypes.h:385
if font is a cff font force use of PostScript glyph names instead of gid&#39;s (glyph index id) ...
Definition: FontEngineTypes.h:447
TWidth _gw
the glyph width see TWidth
Definition: FontEngineTypes.h:80
always insert the item, allow duplicates of same item
Definition: FontEngineDBank.h:27
EEmbFFlags
enum to config some font output traits if font should be converted, subseted or created ...
Definition: FontEngineTypes.h:441
std::pair< double, double > TStemPair
Definition: FontEngineTypes.h:65
std::vector< TEncInfo > TEncInfoVec
Definition: FontEngineTypes.h:323
TCharCode _charcode
character code used by this glyph is depends from encoding
Definition: FontEngineTypes.h:289
TStemVec _vstem
the vertical stem hint value pairs if present
Definition: FontEngineTypes.h:82
double _y
y coordinate
Definition: FontEngineTypes.h:99
void FontEngine_Assert(bool expr)
function to check program process no excption raise
Definition: FontEngineError.h:200
std::wstring TPath
Definition: FontEngineTypes.h:35
(11) operators operant array, one or more numbers
Definition: FontEngineTypes.h:153
( 8) one or two byte operator
Definition: FontEngineTypes.h:150
std::string _endl
the end of line marker used in dum text could be empty no such needed, default is newline &#39; &#39; ...
Definition: FontEngineTypes.h:393
(109) PostScript dictionary
Definition: FontEngineTypes.h:170
EInFlag
&lt; enum used as bit mask to steer the dump output format
Definition: FontEngineTypes.h:371
ENameIgnoreMarker
The ignore marker to select ignore state for platform, encoding and/or language parameter.
Definition: FontEngineTypes.h:300
unsigned int _newgid
[out] [0 - 65535] valid range, if glyph must be moved to a new gid
Definition: FontEngineTypes.h:434
Font contains both uppercase and lowercase letters. The glyphs for the lowercase letters have the sam...
Definition: FontEngineTypes.h:485
std::string _psname
PostScript name of glyph if present or needed.
Definition: FontEngineTypes.h:290
double _width
the glyph width
Definition: FontEngineTypes.h:53
(101) PostScript operator
Definition: FontEngineTypes.h:162
EDumpType
enum to interpret dump result entries, this is a metainfo to get context information ...
Definition: FontEngineTypes.h:138
struct glyph data bank with encoding information
Definition: FontEngineTypes.h:326
unsigned int _id
the id is the text begin position of this entry into dump text
Definition: FontEngineTypes.h:361
(111) T1 glyph
Definition: FontEngineTypes.h:172
TValidBS _vmask
the valid mask see EGSelector
Definition: FontEngineTypes.h:287
EDumpType _type
the dump entrie type see EDumpType
Definition: FontEngineTypes.h:360
std::set< std::string > TAltNameSet
Definition: FontEngineTypes.h:37
#define FONTENGINE_EXPORTS
Definition: FontEngineDLL.h:20
TCharCode::TUNiData TUNiData
Definition: FontEngineTypes.h:31
TFontDictionary()
default ctor
Definition: FontEngineTypes.h:495
EPDFFontFlags
enum to define various characteristics of a font, derived from PDF format, see also FontDescriptor Fl...
Definition: FontEngineTypes.h:476
EEmbFontFlags _embFFlags
flags to config output traits, see EEmbFontFlags
Definition: FontEngineTypes.h:468
TEmbFontDataVec _embFontDataVec
contains data from needed glyphs to subset or create, see TEmbFontData
Definition: FontEngineTypes.h:467
std::pair< unsigned short, bool > TUShortBoolRes
Definition: FontEngineTypes.h:38
TGOutline _goutline
[in] the glyph outline can be empty if font should be subset and font type doesn&#39;t change ...
Definition: FontEngineTypes.h:433
double _stemv
the horizontally thickness of the dominant vertical stems of glyphs in the font. In TrueType fonts th...
Definition: FontEngineTypes.h:516
double _fontweight
the font weigth, possible values shall be 100, 200, 300, 400, 500, 600, 700, 800, or 900 ...
Definition: FontEngineTypes.h:511
(14) An INDEX is an array of variable-sized objects.
Definition: FontEngineTypes.h:156
std::pair< const unsigned char *, unsigned int > TCodeData
Definition: FontEngineTCode.h:45
struct to define glyph decriptions inclusive outline data for input or modify new or existing glyphs ...
Definition: FontEngineTypes.h:409
FontEngine::TCode TCharCode
Definition: FontEngineTypes.h:30
create a unicode primary key set
Definition: FontEngineTypes.h:211
(100) one or two byte Fype1 operator
Definition: FontEngineTypes.h:161
double _x
x coordinate
Definition: FontEngineTypes.h:98
double _ascent
the maximum height above the baseline
Definition: FontEngineTypes.h:512
(205) 32-bit unsigned integer.
Definition: FontEngineTypes.h:181
( 2) [0 - 255] 1-byte unsigned number
Definition: FontEngineTypes.h:144
int _length
the length of the text string of this entry
Definition: FontEngineTypes.h:362
double _bottom
bottom edge coordinate
Definition: FontEngineTypes.h:116
(103) operators operant, boolean value
Definition: FontEngineTypes.h:164
TEncGlyph(unsigned short platform=enimIgnore, unsigned short encoding=enimIgnore, unsigned short language=enimIgnore)
default ctor
Definition: FontEngineTypes.h:333
if set _gid is valid
Definition: FontEngineTypes.h:218
(12) operators operant, a number or a delta-encoded array of numbers
Definition: FontEngineTypes.h:154
TStemVec _hstem
the horizontal stem hint value pairs if present
Definition: FontEngineTypes.h:81
TBBox _fontbox
the font bounding box all glyphs must be inside these rectangle
Definition: FontEngineTypes.h:509
(221) &quot;Number of contour&quot; metadata dump line
Definition: FontEngineTypes.h:197
std::bitset< eeffUseGNames+1 > EEmbFontFlags
Definition: FontEngineTypes.h:449
int _supplement
to subset or create a CID font keep the Supplement key from CIDSystemInfo
Definition: FontEngineTypes.h:471
create a character code primary key set
Definition: FontEngineTypes.h:209
create a glyph PostScript name primary key set
Definition: FontEngineTypes.h:210
(207) 32-bit signed fixed-point number (16.16)
Definition: FontEngineTypes.h:183
( 6) varies 1, 2, 3, or 4 byte offset (specified by OffSize field)
Definition: FontEngineTypes.h:148
(112) CID fontname from FDArray FontInfo dict
Definition: FontEngineTypes.h:173
( 3) [1 - 4] 1-byte unsigned number specifies the size of an Offset field or fields ...
Definition: FontEngineTypes.h:145
std::vector< TStemPair > TStemVec
Definition: FontEngineTypes.h:66
(215) a single bit from bitfield with disable state
Definition: FontEngineTypes.h:191
struct to keep rectangle
Definition: FontEngineTypes.h:104
(102) operators operant, boolean value
Definition: FontEngineTypes.h:163
TEmbFontData(const TGlyph &glyph)
ctor
Definition: FontEngineTypes.h:428
unsigned int _len1
The length in bytes of the clear-text portion of the Type 1 font program.
Definition: FontEngineTypes.h:522
(209) 16-bit signed integer (SHORT) that describes a quantity in FUnits.
Definition: FontEngineTypes.h:185
(212) Date represented in number of seconds since 12:00 midnight, January 1, 1904. The value is represented as a signed 64-bit integer.
Definition: FontEngineTypes.h:188
(202) 8-bit signed integer.
Definition: FontEngineTypes.h:178
TNumberVec TCoordVec
Definition: FontEngineTypes.h:63
if set _unicode is valid
Definition: FontEngineTypes.h:221
Glyphs have serifs, which are short strokes drawn at an angle on the top and bottom of glyph stems...
Definition: FontEngineTypes.h:479
std::bitset< egvTTEmpty+1 > TValidBS
Definition: FontEngineTypes.h:225
InsideFont and ADI-FontEngine : Andreas Dippe, © 2013
http://www.insidefont.de