LibreOffice Module vcl (master)  1
sft.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
25 /*
26  * Generated fonts contain an XUID entry in the form of:
27  *
28  * 103 0 T C1 N C2 C3
29  *
30  * 103 - Sun's Adobe assigned XUID number. Contact person: Alexander Gelfenbain <gelf@eng.sun.com>
31  *
32  * T - font type. 0: Type 3, 1: Type 42
33  * C1 - CRC-32 of the entire source TrueType font
34  * N - number of glyphs in the subset
35  * C2 - CRC-32 of the array of glyph IDs used to generate the subset
36  * C3 - CRC-32 of the array of encoding numbers used to generate the subset
37  *
38  */
39 
40 #ifndef INCLUDED_VCL_INC_SFT_HXX
41 #define INCLUDED_VCL_INC_SFT_HXX
42 
43 #include <vcl/dllapi.h>
44 #include <vcl/fontcapabilities.hxx>
45 #include <i18nlangtag/lang.h>
46 
47 #include <array>
48 #include <memory>
49 #include <vector>
50 #include <cstdint>
51 
52 namespace vcl
53 {
54 
56  typedef sal_Int32 F16Dot16;
58 
60  enum class SFErrCodes {
61  Ok,
62  BadFile,
63  FileIo,
64  Memory,
65  GlyphNum,
66  BadArg,
67  TtFormat,
68  FontNo
69  };
70 
71 #ifndef FW_THIN /* WIN32 compilation would conflict */
72 
73  enum WeightClass {
74  FW_THIN = 100,
75  FW_EXTRALIGHT = 200,
76  FW_LIGHT = 300,
77  FW_NORMAL = 400,
78  FW_MEDIUM = 500,
79  FW_SEMIBOLD = 600,
80  FW_BOLD = 700,
81  FW_EXTRABOLD = 800,
82  FW_BLACK = 900
83  };
84 #endif /* FW_THIN */
85 
87  enum WidthClass {
97  };
98 
111  };
112 
114  typedef struct {
115  sal_uInt16 adv;
116  sal_Int16 sb;
118 
121  typedef struct {
122  sal_uInt32 glyphID;
123  sal_uInt16 nbytes;
125  sal_uInt16 aw;
126  sal_Int16 lsb;
127  bool compflag;
128  sal_uInt16 npoints;
129  sal_uInt16 ncontours;
130  /* */
131  sal_uInt32 newID;
132  } GlyphData;
133 
135  typedef struct {
136  sal_uInt16 platformID;
137  sal_uInt16 encodingID;
139  sal_uInt16 nameID;
140  sal_uInt16 slen;
142  } NameRecord;
143 
146  typedef struct {
147  char *family;
149  char *subfamily;
151  char *psname;
152  sal_uInt16 macStyle;
153  int weight;
154  int width;
155  int pitch;
157  int xMin;
158  int yMin;
159  int xMax;
160  int yMax;
161  int ascender;
162  int descender;
163  int linegap;
168  int winAscent;
171  sal_uInt8 panose[10];
172  sal_uInt32 typeFlags;
173  sal_uInt16 fsSelection;
175 
177  typedef struct {
178  sal_uInt32 flags;
182  sal_Int16 x;
183  sal_Int16 y;
184  } ControlPoint;
185 
186  struct TrueTypeFont;
187 
188 /*
189  Some table OS/2 consts
190  quick history:
191  OpenType has been created from TrueType
192  - original TrueType had an OS/2 table with a length of 68 bytes
193  (cf https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6OS2.html)
194  - There have been 6 versions (from version 0 to 5)
195  (cf https://docs.microsoft.com/en-us/typography/opentype/otspec140/os2ver0)
196 
197  For the record:
198  // From Initial TrueType version
199  TYPE NAME FROM BYTE
200  uint16 version 0
201  int16 xAvgCharWidth 2
202  uint16 usWeightClass 4
203  uint16 usWidthClass 6
204  uint16 fsType 8
205  int16 ySubscriptXSize 10
206  int16 ySubscriptYSize 12
207  int16 ySubscriptXOffset 14
208  int16 ySubscriptYOffset 16
209  int16 ySuperscriptXSize 18
210  int16 ySuperscriptYSize 20
211  int16 ySuperscriptXOffset 22
212  int16 ySuperscriptYOffset 24
213  int16 yStrikeoutSize 26
214  int16 yStrikeoutPosition 28
215  int16 sFamilyClass 30
216  uint8 panose[10] 32
217  uint32 ulUnicodeRange1 42
218  uint32 ulUnicodeRange2 46
219  uint32 ulUnicodeRange3 50
220  uint32 ulUnicodeRange4 54
221  Tag achVendID 58
222  uint16 fsSelection 62
223  uint16 usFirstCharIndex 64
224  uint16 usLastCharIndex 66
225 
226  // From Version 0 of OpenType
227  int16 sTypoAscender 68
228  int16 sTypoDescender 70
229  int16 sTypoLineGap 72
230  uint16 usWinAscent 74
231  uint16 usWinDescent 76
232 
233  => length for OpenType version 0 = 78 bytes
234 
235  // From Version 1 of OpenType
236  uint32 ulCodePageRange1 78
237  uint32 ulCodePageRange2 82
238 
239  => length for OpenType version 1 = 86 bytes
240 
241  // From Version 2 of OpenType
242  // (idem for Versions 3 and 4)
243  int16 sxHeight 86
244  int16 sCapHeight 88
245  uint16 usDefaultChar 90
246  uint16 usBreakChar 92
247  uint16 usMaxContext 94
248 
249  => length for OpenType version 2, 3 and 4 = 96 bytes
250 
251  // From Version 5 of OpenType
252  uint16 usLowerOpticalPointSize 96
253  uint16 usUpperOpticalPointSize 98
254  END 100
255 
256  => length for OS/2 table version 5 = 100 bytes
257 
258 */
259 constexpr int OS2_Legacy_length = 68;
260 constexpr int OS2_V0_length = 78;
261 constexpr int OS2_V1_length = 86;
262 
263 constexpr int OS2_usWeightClass_offset = 4;
264 constexpr int OS2_usWidthClass_offset = 6;
265 constexpr int OS2_fsType_offset = 8;
266 constexpr int OS2_panose_offset = 32;
267 constexpr int OS2_panoseNbBytes_offset = 10;
268 constexpr int OS2_ulUnicodeRange1_offset = 42;
269 constexpr int OS2_ulUnicodeRange2_offset = 46;
270 constexpr int OS2_ulUnicodeRange3_offset = 50;
271 constexpr int OS2_ulUnicodeRange4_offset = 54;
272 constexpr int OS2_fsSelection_offset = 62;
273 constexpr int OS2_typoAscender_offset = 68;
274 constexpr int OS2_typoDescender_offset = 70;
275 constexpr int OS2_typoLineGap_offset = 72;
276 constexpr int OS2_winAscent_offset = 74;
277 constexpr int OS2_winDescent_offset = 76;
278 constexpr int OS2_ulCodePageRange1_offset = 78;
279 constexpr int OS2_ulCodePageRange2_offset = 82;
280 
281 /*
282  Some table hhea consts
283  cf https://docs.microsoft.com/fr-fr/typography/opentype/spec/hhea
284  TYPE NAME FROM BYTE
285  uint16 majorVersion 0
286  uint16 minorVersion 2
287  FWORD ascender 4
288  FWORD descender 6
289  FWORD lineGap 8
290  UFWORD advanceWidthMax 10
291  FWORD minLeftSideBearing 12
292  FWORD minRightSideBearing 14
293  FWORD xMaxExtent 16
294  int16 caretSlopeRise 18
295  int16 caretSlopeRun 20
296  int16 caretOffset 22
297  int16 (reserved) 24
298  int16 (reserved) 26
299  int16 (reserved) 28
300  int16 (reserved) 30
301  int16 metricDataFormat 32
302  uint16 numberOfHMetrics 34
303  END 36
304 
305  => length for hhea table = 36 bytes
306 
307 */
308 constexpr int HHEA_Length = 36;
309 
310 constexpr int HHEA_ascender_offset = 4;
311 constexpr int HHEA_descender_offset = 6;
312 constexpr int HHEA_lineGap_offset = 8;
313 constexpr int HHEA_caretSlopeRise_offset = 18;
314 constexpr int HHEA_caretSlopeRun_offset = 20;
315 
316 /*
317  Some table post consts
318  cf https://docs.microsoft.com/fr-fr/typography/opentype/spec/post
319  TYPE NAME FROM BYTE
320  Fixed version 0
321  Fixed italicAngle 4
322  FWord underlinePosition 8
323  FWord underlineThickness 10
324  uint32 isFixedPitch 12
325  ...
326 
327 */
328 constexpr int POST_italicAngle_offset = 4;
331 constexpr int POST_isFixedPitch_offset = 12;
332 
333 /*
334  Some table head consts
335  cf https://docs.microsoft.com/fr-fr/typography/opentype/spec/head
336  TYPE NAME FROM BYTE
337  uit16 majorVersion 0
338  uit16 minorVersion 2
339  Fixed fontRevision 4
340  uint32 checkSumAdjustment 8
341  uint32 magicNumber 12 (= 0x5F0F3CF5)
342  uint16 flags 16
343  uint16 unitsPerEm 18
344  LONGDATETIME created 20
345  LONGDATETIME modified 28
346  int16 xMin 36
347  int16 yMin 38
348  int16 xMax 40
349  int16 yMax 42
350  uint16 macStyle 44
351  uint16 lowestRecPPEM 46
352  int16 fontDirectionHint 48
353  int16 indexToLocFormat 50
354  int16 glyphDataFormat 52
355 
356  END 54
357 
358  => length head table = 54 bytes
359 */
360 constexpr int HEAD_Length = 54;
361 
362 constexpr int HEAD_majorVersion_offset = 0;
363 constexpr int HEAD_fontRevision_offset = 4;
364 constexpr int HEAD_magicNumber_offset = 12;
365 constexpr int HEAD_flags_offset = 16;
366 constexpr int HEAD_unitsPerEm_offset = 18;
367 constexpr int HEAD_created_offset = 20;
368 constexpr int HEAD_xMin_offset = 36;
369 constexpr int HEAD_yMin_offset = 38;
370 constexpr int HEAD_xMax_offset = 40;
371 constexpr int HEAD_yMax_offset = 42;
372 constexpr int HEAD_macStyle_offset = 44;
373 constexpr int HEAD_lowestRecPPEM_offset = 46;
374 constexpr int HEAD_fontDirectionHint_offset = 48;
375 constexpr int HEAD_indexToLocFormat_offset = 50;
376 constexpr int HEAD_glyphDataFormat_offset = 52;
377 
378 /*
379  Some table maxp consts
380  cf https://docs.microsoft.com/fr-fr/typography/opentype/spec/maxp
381  For 0.5 version
382  TYPE NAME FROM BYTE
383  Fixed version 0
384  uint16 numGlyphs 4
385 
386  For 1.0 Version
387  Fixed version 0
388  uint16 numGlyphs 4
389  uint16 maxPoints 6
390  uint16 maxContours 8
391  uint16 maxCompositePoints 10
392  uint16 maxCompositeContours 12
393  ...
394 
395 */
396 constexpr int MAXP_Version1Length = 32;
397 
398 constexpr int MAXP_numGlyphs_offset = 4;
399 constexpr int MAXP_maxPoints_offset = 6;
400 constexpr int MAXP_maxContours_offset = 8;
403 
404 /*
405  Some table glyf consts
406  cf https://docs.microsoft.com/fr-fr/typography/opentype/spec/glyf
407  For 0.5 version
408  TYPE NAME FROM BYTE
409  int16 numberOfContours 0
410  int16 xMin 2
411  int16 yMin 4
412  int16 xMax 6
413  int16 yMax 8
414 
415  END 10
416 
417  => length glyf table = 10 bytes
418 
419 */
420 constexpr int GLYF_Length = 10;
421 
423 constexpr int GLYF_xMin_offset = 2;
424 constexpr int GLYF_yMin_offset = 4;
425 constexpr int GLYF_xMax_offset = 6;
426 constexpr int GLYF_yMax_offset = 8;
427 
428 constexpr sal_uInt32 T_true = 0x74727565; /* 'true' */
429 constexpr sal_uInt32 T_ttcf = 0x74746366; /* 'ttcf' */
430 constexpr sal_uInt32 T_otto = 0x4f54544f; /* 'OTTO' */
431 
432 // standard TrueType table tags
433 constexpr sal_uInt32 T_maxp = 0x6D617870;
434 constexpr sal_uInt32 T_glyf = 0x676C7966;
435 constexpr sal_uInt32 T_head = 0x68656164;
436 constexpr sal_uInt32 T_loca = 0x6C6F6361;
437 constexpr sal_uInt32 T_name = 0x6E616D65;
438 constexpr sal_uInt32 T_hhea = 0x68686561;
439 constexpr sal_uInt32 T_hmtx = 0x686D7478;
440 constexpr sal_uInt32 T_cmap = 0x636D6170;
441 constexpr sal_uInt32 T_vhea = 0x76686561;
442 constexpr sal_uInt32 T_vmtx = 0x766D7478;
443 constexpr sal_uInt32 T_OS2 = 0x4F532F32;
444 constexpr sal_uInt32 T_post = 0x706F7374;
445 constexpr sal_uInt32 T_cvt = 0x63767420;
446 constexpr sal_uInt32 T_prep = 0x70726570;
447 constexpr sal_uInt32 T_fpgm = 0x6670676D;
448 constexpr sal_uInt32 T_gsub = 0x47535542;
449 constexpr sal_uInt32 T_CFF = 0x43464620;
450 
451 
462  int CountTTCFonts(const char* fname);
463 
475  SFErrCodes VCL_DLLPUBLIC OpenTTFontBuffer(const void* pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTypeFont** ttf);
476 #if !defined(_WIN32)
477 
488  SFErrCodes VCL_DLLPUBLIC OpenTTFontFile(const char *fname, sal_uInt32 facenum, TrueTypeFont** ttf);
489 #endif
490 
492  o3tl::optional<std::bitset<UnicodeCoverage::MAX_UC_ENUM>> & rUnicodeCoverage,
493  o3tl::optional<std::bitset<CodePageCoverage::MAX_CP_ENUM>> & rCodePageCoverage,
494  const unsigned char* pTable, size_t nLength);
495 
501 
515  int GetTTGlyphPoints(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoint **pointArray);
516 
529  GlyphData *GetTTRawGlyphData(TrueTypeFont *ttf, sal_uInt32 glyphID);
530 
546  int GetTTGlyphComponents(TrueTypeFont *ttf, sal_uInt32 glyphID, std::vector< sal_uInt32 >& glyphlist);
547 
559  int GetTTNameRecords(TrueTypeFont const *ttf, NameRecord **nr);
560 
569  void DisposeNameRecords(NameRecord* nr, int n);
570 
588  SFErrCodes CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, sal_uInt16 const *glyphArray, sal_uInt8 *encoding, int nGlyphs, int wmode);
589 
608  const char *fname,
609  sal_uInt16 const *glyphArray,
610  sal_uInt8 const *encoding,
611  int nGlyphs);
612 
634  FILE *outf,
635  const char *psname,
636  sal_uInt16 const *glyphArray,
637  sal_uInt8 *encoding,
638  int nGlyphs);
639 
650  VCL_DLLPUBLIC std::unique_ptr<sal_uInt16[]> GetTTSimpleGlyphMetrics(TrueTypeFont const *ttf, const sal_uInt16 *glyphArray, int nGlyphs, bool vertical);
651 
652 #if defined(_WIN32) || defined(MACOSX) || defined(IOS)
653 
662  VCL_DLLPUBLIC sal_uInt16 MapChar(TrueTypeFont const *ttf, sal_uInt16 ch);
663 #endif
664 
675 
686  void GetTTFontMetrics(const uint8_t *pHhea, size_t nHhea,
687  const uint8_t *pOs2, size_t nOs2,
688  TTGlobalFontInfo *info);
689 
693  VCL_DLLPUBLIC int GetTTGlyphCount( TrueTypeFont const * ttf );
694 
698  bool GetSfntTable( TrueTypeFont const * ttf, int nSubtableIndex,
699  const sal_uInt8** ppRawBytes, int* pRawLength );
700 
701 /*- private definitions */
702 
703 /* indexes into TrueTypeFont::tables[] and TrueTypeFont::tlens[] */
704 constexpr int O_maxp = 0;
705 constexpr int O_glyf = 1; /* 'glyf' */
706 constexpr int O_head = 2; /* 'head' */
707 constexpr int O_loca = 3; /* 'loca' */
708 constexpr int O_name = 4; /* 'name' */
709 constexpr int O_hhea = 5; /* 'hhea' */
710 constexpr int O_hmtx = 6; /* 'hmtx' */
711 constexpr int O_cmap = 7; /* 'cmap' */
712 constexpr int O_vhea = 8; /* 'vhea' */
713 constexpr int O_vmtx = 9; /* 'vmtx' */
714 constexpr int O_OS2 = 10; /* 'OS/2' */
715 constexpr int O_post = 11; /* 'post' */
716 constexpr int O_cvt = 12; /* 'cvt_' - only used in TT->TT generation */
717 constexpr int O_prep = 13; /* 'prep' - only used in TT->TT generation */
718 constexpr int O_fpgm = 14; /* 'fpgm' - only used in TT->TT generation */
719 constexpr int O_gsub = 15; /* 'GSUB' */
720 constexpr int O_CFF = 16; /* 'CFF' */
721 constexpr int NUM_TAGS = 17;
722 
723  struct TrueTypeFont {
724  char *fname;
725  sal_Int32 fsize;
727 
728  char *psname;
729  char *family;
731  char *subfamily;
733 
734  sal_uInt32 ntables;
735  sal_uInt32 *goffsets;
736  sal_uInt32 nglyphs;
737  sal_uInt32 unitsPerEm;
738  sal_uInt32 numberOfHMetrics;
739  sal_uInt32 numOfLongVerMetrics; /* if this number is not 0, font has vertical metrics information */
740  const sal_uInt8* cmap;
741  int cmapType;
742  sal_uInt32 (*mapper)(const sal_uInt8 *, sal_uInt32, sal_uInt32); /* character to glyphID translation function */
743  std::array<const sal_uInt8 *, NUM_TAGS> tables; /* array of pointers to raw subtables in SFNT file */
744  std::array<sal_uInt32, NUM_TAGS> tlens; /* array of table lengths */
745  };
746 
747 
748 } // namespace vcl
749 
750 #endif // INCLUDED_VCL_INC_SFT_HXX
751 
752 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
char * psname
PostScript name.
Definition: sft.hxx:151
bool symbolEncoded
true: MS symbol encoded
Definition: sft.hxx:170
Extra-light (Ultra-light)
Definition: sft.hxx:75
constexpr int HEAD_yMax_offset
Definition: sft.hxx:371
constexpr int O_head
Definition: sft.hxx:706
constexpr int HEAD_magicNumber_offset
Definition: sft.hxx:364
constexpr sal_uInt32 T_head
Definition: sft.hxx:435
sal_Int32 F16Dot16
fixed: 16.16
Definition: sft.hxx:56
constexpr int OS2_ulCodePageRange2_offset
Definition: sft.hxx:279
sal_Int16 sb
left or top sidebearing
Definition: sft.hxx:116
sal_uInt16 ncontours
number of contours
Definition: sft.hxx:129
50% of normal
Definition: sft.hxx:88
constexpr int OS2_ulCodePageRange1_offset
Definition: sft.hxx:278
constexpr sal_uInt32 T_OS2
Definition: sft.hxx:443
constexpr sal_uInt32 T_gsub
Definition: sft.hxx:448
bool compflag
false- if non-composite
Definition: sft.hxx:127
constexpr int HEAD_unitsPerEm_offset
Definition: sft.hxx:366
sal_uInt32 numOfLongVerMetrics
Definition: sft.hxx:739
SFErrCodes OpenTTFontBuffer(const void *pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTypeFont **ttf)
TrueTypeFont constructor.
Definition: sft.cxx:1438
int CountTTCFonts(const char *fname)
Get the number of fonts contained in a TrueType collection.
Definition: sft.cxx:1347
sal_Int16 y
Y coordinate in EmSquare units.
Definition: sft.hxx:183
Bold.
Definition: sft.hxx:80
Thin.
Definition: sft.hxx:74
int descender
typographic descent.
Definition: sft.hxx:162
constexpr int MAXP_Version1Length
Definition: sft.hxx:396
constexpr sal_uInt32 T_hhea
Definition: sft.hxx:438
const sal_uInt8 * cmap
Definition: sft.hxx:740
void DisposeNameRecords(NameRecord *nr, int n)
Deallocates previously allocated array of NameRecords.
Definition: sft.cxx:2585
SFErrCodes
Return value of OpenTTFont() and CreateT3FromTTGlyphs()
Definition: sft.hxx:60
bool GetSfntTable(TrueTypeFont const *ttf, int nSubtableIndex, const sal_uInt8 **ppRawBytes, int *pRawLength)
provide access to the raw data of a SFNT-container's subtable
Definition: sft.cxx:2297
constexpr int O_OS2
Definition: sft.hxx:714
constexpr int OS2_ulUnicodeRange1_offset
Definition: sft.hxx:268
char * fname
Definition: sft.hxx:724
WidthClass
Value of the width member of the TTGlobalFontInfo struct.
Definition: sft.hxx:87
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
void CloseTTFont(TrueTypeFont *ttf)
TrueTypeFont destructor.
Definition: sft.cxx:1684
memory allocation error
int ascender
typographic ascent.
Definition: sft.hxx:161
GlyphData * GetTTRawGlyphData(TrueTypeFont *ttf, sal_uInt32 glyphID)
Extracts raw glyph data from the 'glyf' table and returns it in an allocated GlyphData structure...
Definition: sft.cxx:2437
sal_uInt32 * goffsets
Definition: sft.hxx:735
constexpr sal_uInt32 T_true
Definition: sft.hxx:428
Black (Heavy)
Definition: sft.hxx:82
int typoAscender
OS/2 portable typographic ascender.
Definition: sft.hxx:165
constexpr int HHEA_descender_offset
Definition: sft.hxx:311
Return value of GetTTGlobalFontInfo()
Definition: sft.hxx:146
constexpr int O_CFF
Definition: sft.hxx:720
constexpr sal_uInt32 T_loca
Definition: sft.hxx:436
sal_uInt16 adv
advance width or height
Definition: sft.hxx:115
constexpr int HEAD_created_offset
Definition: sft.hxx:367
constexpr int POST_underlineThickness_offset
Definition: sft.hxx:330
Normal (Regular)
Definition: sft.hxx:77
constexpr int HEAD_macStyle_offset
Definition: sft.hxx:372
constexpr int OS2_fsType_offset
Definition: sft.hxx:265
constexpr sal_uInt32 T_vhea
Definition: sft.hxx:441
constexpr int OS2_ulUnicodeRange3_offset
Definition: sft.hxx:270
int yMax
global bounding box: yMax
Definition: sft.hxx:160
Medium.
Definition: sft.hxx:78
constexpr int HEAD_lowestRecPPEM_offset
Definition: sft.hxx:373
sal_uInt32 typeFlags
type flags (copyright bits)
Definition: sft.hxx:172
int linegap
typographic line gap. Negative values are treated as zero in Win 3.1, System 6 and System 7...
Definition: sft.hxx:163
constexpr int O_cvt
Definition: sft.hxx:716
constexpr int HEAD_Length
Definition: sft.hxx:360
constexpr int HEAD_xMax_offset
Definition: sft.hxx:370
Structure used by the TrueType Creator and GetRawGlyphData()
Definition: sft.hxx:121
constexpr int O_cmap
Definition: sft.hxx:711
int xMax
global bounding box: xMax
Definition: sft.hxx:159
sal_uInt16 nbytes
number of bytes in glyph data
Definition: sft.hxx:123
incorrect logical font number of a TTC font
sal_Unicode * usubfamily
subfamily name UCS2
Definition: sft.hxx:150
int typoLineGap
OS/2 portable typographic line gap.
Definition: sft.hxx:167
constexpr int GLYF_numberOfContours_offset
Definition: sft.hxx:422
constexpr int MAXP_maxCompositePoints_offset
Definition: sft.hxx:401
sal_Int16 x
X coordinate in EmSquare units.
Definition: sft.hxx:182
Semi-bold (Demi-bold)
Definition: sft.hxx:79
constexpr int OS2_panoseNbBytes_offset
Definition: sft.hxx:267
constexpr int HEAD_fontDirectionHint_offset
Definition: sft.hxx:374
constexpr int GLYF_Length
Definition: sft.hxx:420
constexpr int OS2_typoAscender_offset
Definition: sft.hxx:273
constexpr sal_uInt32 T_cmap
Definition: sft.hxx:440
int winDescent
descender metric for Windows
Definition: sft.hxx:169
Medium, 100%.
Definition: sft.hxx:92
sal_uInt32 ntables
Definition: sft.hxx:734
sal_uInt16 sal_Unicode
int winAscent
ascender metric for Windows
Definition: sft.hxx:168
constexpr int OS2_usWidthClass_offset
Definition: sft.hxx:264
75% of normal
Definition: sft.hxx:90
62.5% of normal
Definition: sft.hxx:89
constexpr int O_prep
Definition: sft.hxx:717
SFErrCodes CreateT42FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *psname, sal_uInt16 const *glyphArray, sal_uInt8 *encoding, int nGlyphs)
Generates a new PostScript Type42 font and dumps it to outf file.
Definition: sft.cxx:2152
sal_uInt32(* mapper)(const sal_uInt8 *, sal_uInt32, sal_uInt32)
Definition: sft.hxx:742
constexpr int MAXP_maxContours_offset
Definition: sft.hxx:400
constexpr int OS2_Legacy_length
Definition: sft.hxx:259
constexpr sal_uInt32 T_prep
Definition: sft.hxx:446
constexpr int OS2_typoDescender_offset
Definition: sft.hxx:274
constexpr int O_fpgm
Definition: sft.hxx:718
constexpr int HHEA_caretSlopeRise_offset
Definition: sft.hxx:313
void GetTTGlobalFontInfo(TrueTypeFont *ttf, TTGlobalFontInfo *info)
Returns global font information about the TrueType font.
Definition: sft.cxx:2376
void GetTTFontMetrics(const uint8_t *pHhea, size_t nHhea, const uint8_t *pOs2, size_t nOs2, TTGlobalFontInfo *info)
Returns fonts metrics.
Definition: sft.cxx:2351
Extra-bold (Ultra-bold)
Definition: sft.hxx:81
CompositeFlags
Composite glyph flags definition.
Definition: sft.hxx:100
constexpr sal_uInt32 T_maxp
Definition: sft.hxx:433
constexpr int HEAD_yMin_offset
Definition: sft.hxx:369
sal_uInt8 * ptr
Definition: sft.hxx:726
ControlPoint structure used by GetTTGlyphPoints()
Definition: sft.hxx:177
constexpr sal_uInt32 T_glyf
Definition: sft.hxx:434
constexpr sal_uInt32 T_cvt
Definition: sft.hxx:445
constexpr int NUM_TAGS
Definition: sft.hxx:721
constexpr int OS2_winAscent_offset
Definition: sft.hxx:276
constexpr int HHEA_Length
Definition: sft.hxx:308
constexpr int HHEA_ascender_offset
Definition: sft.hxx:310
sal_uInt32 newID
used internally by the TTCR
Definition: sft.hxx:131
constexpr int O_post
Definition: sft.hxx:715
112.5% of normal
Definition: sft.hxx:93
constexpr int HHEA_lineGap_offset
Definition: sft.hxx:312
incorrect number of glyphs
constexpr int HEAD_indexToLocFormat_offset
Definition: sft.hxx:375
constexpr int HEAD_flags_offset
Definition: sft.hxx:365
constexpr int O_hmtx
Definition: sft.hxx:710
150% of normal
Definition: sft.hxx:95
incorrect arguments
constexpr int O_gsub
Definition: sft.hxx:719
constexpr int HEAD_glyphDataFormat_offset
Definition: sft.hxx:376
constexpr sal_uInt32 T_hmtx
Definition: sft.hxx:439
sal_Unicode * usubfamily
Definition: sft.hxx:732
int width
value of WidthClass or 0 if can't be determined
Definition: sft.hxx:154
sal_uInt16 platformID
Platform ID.
Definition: sft.hxx:136
sal_uInt8 * sptr
Pointer to string data (not zero-terminated!)
Definition: sft.hxx:141
constexpr int HEAD_fontRevision_offset
Definition: sft.hxx:363
char * family
Definition: sft.hxx:729
constexpr sal_uInt32 T_fpgm
Definition: sft.hxx:447
Light.
Definition: sft.hxx:76
sal_uInt16 fsSelection
OS/2 fsSelection.
Definition: sft.hxx:173
SFErrCodes CreateTTFromTTGlyphs(TrueTypeFont *ttf, const char *fname, sal_uInt16 const *glyphArray, sal_uInt8 const *encoding, int nGlyphs)
Generates a new TrueType font and dumps it to outf file.
Definition: sft.cxx:1904
200% of normal
Definition: sft.hxx:96
constexpr int GLYF_xMin_offset
Definition: sft.hxx:423
constexpr int GLYF_yMax_offset
Definition: sft.hxx:426
constexpr int OS2_V0_length
Definition: sft.hxx:260
int GetTTGlyphPoints(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoint **pointArray)
Extracts TrueType control points, and stores them in an allocated array pointed to by *pointArray...
Definition: sft.cxx:1703
constexpr int O_loca
Definition: sft.hxx:707
constexpr int POST_isFixedPitch_offset
Definition: sft.hxx:331
constexpr int O_hhea
Definition: sft.hxx:709
std::array< sal_uInt32, NUM_TAGS > tlens
Definition: sft.hxx:744
int xMin
global bounding box: xMin
Definition: sft.hxx:157
constexpr int GLYF_xMax_offset
Definition: sft.hxx:425
SFErrCodes OpenTTFontFile(const char *fname, sal_uInt32 facenum, TrueTypeFont **ttf)
TrueTypeFont constructor.
Definition: sft.cxx:1378
sal_Unicode * ufamily
Definition: sft.hxx:730
constexpr int OS2_typoLineGap_offset
Definition: sft.hxx:275
constexpr int O_maxp
Definition: sft.hxx:704
int GetTTNameRecords(TrueTypeFont const *ttf, NameRecord **nr)
Extracts all Name Records from the font and stores them in an allocated array of NameRecord structs...
Definition: sft.cxx:2501
int yMin
global bounding box: yMin
Definition: sft.hxx:158
87.5% of normal
Definition: sft.hxx:91
Structure used by the TrueType Creator and CreateTTFromTTGlyphs()
Definition: sft.hxx:135
incorrect TrueType font format
int typoDescender
OS/2 portable typographic descender.
Definition: sft.hxx:166
sal_Int16 lsb
left sidebearing
Definition: sft.hxx:126
WeightClass
Value of the weight member of the TTGlobalFontInfo struct.
Definition: sft.hxx:73
Structure used by GetTTSimpleCharMetrics() functions.
Definition: sft.hxx:114
constexpr int HEAD_xMin_offset
Definition: sft.hxx:368
int GetTTGlyphComponents(TrueTypeFont *ttf, sal_uInt32 glyphID, std::vector< sal_uInt32 > &glyphlist)
For a specified glyph adds all component glyphs IDs to the list and return their number.
Definition: sft.cxx:1708
constexpr int MAXP_maxPoints_offset
Definition: sft.hxx:399
sal_uInt32 numberOfHMetrics
Definition: sft.hxx:738
unsigned char sal_uInt8
sal_uInt16 encodingID
Platform-specific encoding ID.
Definition: sft.hxx:137
char * psname
Definition: sft.hxx:728
LanguageType languageID
Language ID.
Definition: sft.hxx:138
int weight
value of WeightClass or 0 if can't be determined
Definition: sft.hxx:153
constexpr int OS2_V1_length
Definition: sft.hxx:261
constexpr sal_uInt32 T_name
Definition: sft.hxx:437
constexpr sal_uInt32 T_otto
Definition: sft.hxx:430
constexpr sal_uInt32 T_post
Definition: sft.hxx:444
constexpr int OS2_winDescent_offset
Definition: sft.hxx:277
constexpr int OS2_panose_offset
Definition: sft.hxx:266
constexpr sal_uInt32 T_ttcf
Definition: sft.hxx:429
125% of normal
Definition: sft.hxx:94
constexpr int POST_underlinePosition_offset
Definition: sft.hxx:329
constexpr int O_vhea
Definition: sft.hxx:712
sal_Unicode * ufamily
family name UCS2
Definition: sft.hxx:148
sal_uInt16 slen
String length in bytes.
Definition: sft.hxx:140
sal_uInt16 npoints
number of points
Definition: sft.hxx:128
constexpr int O_glyf
Definition: sft.hxx:705
constexpr int MAXP_maxCompositeContours_offset
Definition: sft.hxx:402
constexpr sal_uInt32 T_CFF
Definition: sft.hxx:449
constexpr int OS2_fsSelection_offset
Definition: sft.hxx:272
int GetTTGlyphCount(TrueTypeFont const *ttf)
returns the number of glyphs in a font
Definition: sft.cxx:2292
sal_uInt16 aw
advance width
Definition: sft.hxx:125
bool getTTCoverage(o3tl::optional< std::bitset< UnicodeCoverage::MAX_UC_ENUM >> &rUnicodeRange, o3tl::optional< std::bitset< CodePageCoverage::MAX_CP_ENUM >> &rCodePageRange, const unsigned char *pTable, size_t nLength)
Definition: sft.cxx:2603
sal_uInt32 glyphID
glyph ID
Definition: sft.hxx:122
sal_Int32 fsize
Definition: sft.hxx:725
char * subfamily
subfamily name
Definition: sft.hxx:149
constexpr int O_vmtx
Definition: sft.hxx:713
SFErrCodes CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, sal_uInt16 const *glyphArray, sal_uInt8 *encoding, int nGlyphs, int wmode)
Generates a new PostScript Type 3 font and dumps it to outf file.
Definition: sft.cxx:1752
int italicAngle
in counter-clockwise degrees * 65536
Definition: sft.hxx:156
sal_uInt16 macStyle
macstyle bits from 'HEAD' table
Definition: sft.hxx:152
char * family
family name
Definition: sft.hxx:147
sal_uInt32 flags
00000000 00000000 e0000000 bbbbbbbb
Definition: sft.hxx:178
sal_uInt16 nameID
Name ID.
Definition: sft.hxx:139
int pitch
0: proportional font, otherwise: monospaced
Definition: sft.hxx:155
constexpr int HEAD_majorVersion_offset
Definition: sft.hxx:362
constexpr int HHEA_caretSlopeRun_offset
Definition: sft.hxx:314
constexpr int POST_italicAngle_offset
Definition: sft.hxx:328
constexpr int OS2_usWeightClass_offset
Definition: sft.hxx:263
std::unique_ptr< sal_uInt16[]> GetTTSimpleGlyphMetrics(TrueTypeFont const *ttf, const sal_uInt16 *glyphArray, int nGlyphs, bool vertical)
Queries glyph metrics.
Definition: sft.cxx:2308
constexpr int O_name
Definition: sft.hxx:708
constexpr int OS2_ulUnicodeRange2_offset
Definition: sft.hxx:269
constexpr int MAXP_numGlyphs_offset
Definition: sft.hxx:398
constexpr sal_uInt32 T_vmtx
Definition: sft.hxx:442
char * subfamily
Definition: sft.hxx:731
constexpr int GLYF_yMin_offset
Definition: sft.hxx:424
constexpr int OS2_ulUnicodeRange4_offset
Definition: sft.hxx:271
sal_uInt32 unitsPerEm
Definition: sft.hxx:737
std::array< const sal_uInt8 *, NUM_TAGS > tables
Definition: sft.hxx:743
sal_uInt8 * ptr
pointer to glyph data
Definition: sft.hxx:124
sal_uInt32 nglyphs
Definition: sft.hxx:736