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 <vcl/fontcharmap.hxx>
46 #include <i18nlangtag/lang.h>
47 
48 #include <array>
49 #include <memory>
50 #include <vector>
51 #include <cstdint>
52 
53 namespace vcl
54 {
55 
57  typedef sal_Int32 F16Dot16;
59 
61  enum class SFErrCodes {
62  Ok,
63  BadFile,
64  FileIo,
65  Memory,
66  GlyphNum,
67  BadArg,
68  TtFormat,
69  FontNo
70  };
71 
72 #ifndef FW_THIN /* WIN32 compilation would conflict */
73 
74  enum WeightClass {
75  FW_THIN = 100,
76  FW_EXTRALIGHT = 200,
77  FW_LIGHT = 300,
78  FW_NORMAL = 400,
79  FW_MEDIUM = 500,
80  FW_SEMIBOLD = 600,
81  FW_BOLD = 700,
82  FW_EXTRABOLD = 800,
83  FW_BLACK = 900
84  };
85 #endif /* FW_THIN */
86 
88  enum WidthClass {
98  };
99 
112  };
113 
115  typedef struct {
116  sal_uInt16 adv;
117  sal_Int16 sb;
119 
122  typedef struct {
123  sal_uInt32 glyphID;
124  sal_uInt16 nbytes;
126  sal_uInt16 aw;
127  sal_Int16 lsb;
128  bool compflag;
129  sal_uInt16 npoints;
130  sal_uInt16 ncontours;
131  /* */
132  sal_uInt32 newID;
133  } GlyphData;
134 
136  typedef struct {
137  sal_uInt16 platformID;
138  sal_uInt16 encodingID;
140  sal_uInt16 nameID;
141  sal_uInt16 slen;
143  } NameRecord;
144 
147  typedef struct TTGlobalFontInfo_ {
148  char *family;
150  char *subfamily;
152  char *psname;
153  sal_uInt16 macStyle;
154  int weight;
155  int width;
156  int pitch;
158  int xMin;
159  int yMin;
160  int xMax;
161  int yMax;
162  int ascender;
163  int descender;
164  int linegap;
169  int winAscent;
173  sal_uInt32 typeFlags;
174  sal_uInt16 fsSelection;
176 
178  typedef struct {
179  sal_uInt32 flags;
183  sal_Int16 x;
184  sal_Int16 y;
185  } ControlPoint;
186 
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 
452 class TrueTypeFont;
453 
464  int CountTTCFonts(const char* fname);
465 
478  SFErrCodes VCL_DLLPUBLIC OpenTTFontBuffer(const void* pBuffer, sal_uInt32 nLen, sal_uInt32 facenum,
479  TrueTypeFont** ttf, const FontCharMapRef xCharMap = nullptr);
480 #if !defined(_WIN32)
481 
493  SFErrCodes VCL_DLLPUBLIC OpenTTFontFile(const char *fname, sal_uInt32 facenum, TrueTypeFont** ttf,
494  const FontCharMapRef xCharMap = nullptr);
495 #endif
496 
498  std::optional<std::bitset<UnicodeCoverage::MAX_UC_ENUM>> & rUnicodeCoverage,
499  std::optional<std::bitset<CodePageCoverage::MAX_CP_ENUM>> & rCodePageCoverage,
500  const unsigned char* pTable, size_t nLength);
501 
507 
521  int GetTTGlyphPoints(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoint **pointArray);
522 
535  GlyphData *GetTTRawGlyphData(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID);
536 
552  int GetTTGlyphComponents(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID, std::vector< sal_uInt32 >& glyphlist);
553 
565  int GetTTNameRecords(AbstractTrueTypeFont const *ttf, NameRecord **nr);
566 
575  void DisposeNameRecords(NameRecord* nr, int n);
576 
594  SFErrCodes CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, sal_uInt16 const *glyphArray, sal_uInt8 *encoding, int nGlyphs, int wmode);
595 
614  const char *fname,
615  sal_uInt16 const *glyphArray,
616  sal_uInt8 const *encoding,
617  int nGlyphs);
618 
640  FILE *outf,
641  const char *psname,
642  sal_uInt16 const *glyphArray,
643  sal_uInt8 *encoding,
644  int nGlyphs);
645 
656  VCL_DLLPUBLIC std::unique_ptr<sal_uInt16[]> GetTTSimpleGlyphMetrics(AbstractTrueTypeFont const *ttf, const sal_uInt16 *glyphArray, int nGlyphs, bool vertical);
657 
668 
683  VCL_DLLPUBLIC bool GetTTGlobalFontHeadInfo(const AbstractTrueTypeFont *ttf, int& xMin, int& yMin, int& xMax, int& yMax, sal_uInt16& macStyle);
684 
695  void GetTTFontMetrics(const uint8_t *pHhea, size_t nHhea,
696  const uint8_t *pOs2, size_t nOs2,
697  TTGlobalFontInfo *info);
698 
699 /*- private definitions */
700 
701 /* indexes into TrueTypeFont::tables[] and TrueTypeFont::tlens[] */
702 constexpr int O_maxp = 0;
703 constexpr int O_glyf = 1; /* 'glyf' */
704 constexpr int O_head = 2; /* 'head' */
705 constexpr int O_loca = 3; /* 'loca' */
706 constexpr int O_name = 4; /* 'name' */
707 constexpr int O_hhea = 5; /* 'hhea' */
708 constexpr int O_hmtx = 6; /* 'hmtx' */
709 constexpr int O_cmap = 7; /* 'cmap' */
710 constexpr int O_vhea = 8; /* 'vhea' */
711 constexpr int O_vmtx = 9; /* 'vmtx' */
712 constexpr int O_OS2 = 10; /* 'OS/2' */
713 constexpr int O_post = 11; /* 'post' */
714 constexpr int O_cvt = 12; /* 'cvt_' - only used in TT->TT generation */
715 constexpr int O_prep = 13; /* 'prep' - only used in TT->TT generation */
716 constexpr int O_fpgm = 14; /* 'fpgm' - only used in TT->TT generation */
717 constexpr int O_gsub = 15; /* 'GSUB' */
718 constexpr int O_CFF = 16; /* 'CFF' */
719 constexpr int NUM_TAGS = 17;
720 
722 {
723  char* m_pFileName;
724  sal_uInt32 m_nGlyphs;
725  sal_uInt32* m_pGlyphOffsets;
726  sal_uInt32 m_nHorzMetrics;
727  sal_uInt32 m_nVertMetrics; /* if not 0 => font has vertical metrics information */
728  sal_uInt32 m_nUnitsPerEm;
730 
731 protected:
732  SFErrCodes indexGlyphData();
733 
734 public:
735  AbstractTrueTypeFont(const char* fileName = nullptr, const FontCharMapRef xCharMap = nullptr);
736  virtual ~AbstractTrueTypeFont();
737 
738  const char* fileName() const { return m_pFileName; }
739  sal_uInt32 glyphCount() const { return m_nGlyphs; }
740  sal_uInt32 glyphOffset(sal_uInt32 glyphID) const { return m_pGlyphOffsets[glyphID]; }
741  sal_uInt32 horzMetricCount() const { return m_nHorzMetrics; }
742  sal_uInt32 vertMetricCount() const { return m_nVertMetrics; }
743  sal_uInt32 unitsPerEm() const { return m_nUnitsPerEm; }
744  FontCharMapRef GetCharMap() const { return m_xCharMap; }
745 
746  virtual bool hasTable(sal_uInt32 ord) const = 0;
747  virtual const sal_uInt8* table(sal_uInt32 ord, sal_uInt32& size) const = 0;
748 };
749 
750 class TrueTypeFont final : public AbstractTrueTypeFont
751 {
753  {
754  const sal_uInt8* pData = nullptr; /* pointer to a raw subtable in the SFNT file */
755  sal_uInt32 nSize = 0; /* table size */
756  };
757 
758  std::array<struct TTFontTable_, NUM_TAGS> m_aTableList;
759 
760 public:
761  sal_Int32 fsize;
763 
764  char *psname;
765  char *family;
767  char *subfamily;
769 
770  sal_uInt32 ntables;
771 
772  TrueTypeFont(const char* pFileName = nullptr, const FontCharMapRef xCharMap = nullptr);
773  ~TrueTypeFont() override;
774 
775  SFErrCodes open(sal_uInt32 facenum);
776 
777  bool hasTable(sal_uInt32 ord) const override { return m_aTableList[ord].pData != nullptr; }
778  inline const sal_uInt8* table(sal_uInt32 ord, sal_uInt32& size) const override;
779 };
780 
781 const sal_uInt8* TrueTypeFont::table(sal_uInt32 ord, sal_uInt32& size) const
782 {
783  if (ord >= NUM_TAGS)
784  {
785  size = 0;
786  return nullptr;
787  }
788 
789  auto& rTable = m_aTableList[ord];
790  size = rTable.nSize;
791  return rTable.pData;
792 }
793 
794 } // namespace vcl
795 
796 #endif // INCLUDED_VCL_INC_SFT_HXX
797 
798 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 fsize
Definition: sft.hxx:761
Extra-light (Ultra-light)
Definition: sft.hxx:76
int winDescent
descender metric for Windows
Definition: sft.hxx:170
constexpr int HEAD_yMax_offset
Definition: sft.hxx:371
constexpr int O_head
Definition: sft.hxx:704
constexpr int HEAD_magicNumber_offset
Definition: sft.hxx:364
constexpr sal_uInt32 T_head
Definition: sft.hxx:435
bool symbolEncoded
true: MS symbol encoded
Definition: sft.hxx:171
sal_Int32 F16Dot16
fixed: 16.16
Definition: sft.hxx:57
sal_Unicode * usubfamily
subfamily name UCS2
Definition: sft.hxx:151
int pitch
0: proportional font, otherwise: monospaced
Definition: sft.hxx:156
constexpr int OS2_ulCodePageRange2_offset
Definition: sft.hxx:279
sal_Int16 sb
left or top sidebearing
Definition: sft.hxx:117
sal_uInt16 ncontours
number of contours
Definition: sft.hxx:130
50% of normal
Definition: sft.hxx:89
SFErrCodes CreateTTFromTTGlyphs(AbstractTrueTypeFont *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:1582
sal_uInt32 unitsPerEm() const
Definition: sft.hxx:743
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:128
sal_uInt16 fsSelection
OS/2 fsSelection.
Definition: sft.hxx:174
constexpr int HEAD_unitsPerEm_offset
Definition: sft.hxx:366
int CountTTCFonts(const char *fname)
Get the number of fonts contained in a TrueType collection.
Definition: sft.cxx:1008
sal_Int16 y
Y coordinate in EmSquare units.
Definition: sft.hxx:184
Bold.
Definition: sft.hxx:81
Thin.
Definition: sft.hxx:75
std::unique_ptr< sal_uInt16[]> GetTTSimpleGlyphMetrics(AbstractTrueTypeFont const *ttf, const sal_uInt16 *glyphArray, int nGlyphs, bool vertical)
Queries glyph metrics.
Definition: sft.cxx:1938
constexpr int MAXP_Version1Length
Definition: sft.hxx:396
constexpr sal_uInt32 T_hhea
Definition: sft.hxx:438
~TrueTypeFont() override
Definition: sft.cxx:1148
void DisposeNameRecords(NameRecord *nr, int n)
Deallocates previously allocated array of NameRecords.
Definition: sft.cxx:2223
SFErrCodes
Return value of OpenTTFont() and CreateT3FromTTGlyphs()
Definition: sft.hxx:61
struct TTGlobalFontInfo_ TTGlobalFontInfo
Return value of GetTTGlobalFontInfo()
Definition: salgdi.hxx:60
constexpr int O_OS2
Definition: sft.hxx:712
constexpr int OS2_ulUnicodeRange1_offset
Definition: sft.hxx:268
char * subfamily
subfamily name
Definition: sft.hxx:150
char * psname
PostScript name.
Definition: sft.hxx:152
sal_uInt32 glyphCount() const
Definition: sft.hxx:739
WidthClass
Value of the width member of the TTGlobalFontInfo struct.
Definition: sft.hxx:88
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
void CloseTTFont(TrueTypeFont *ttf)
TrueTypeFont destructor.
Definition: sft.cxx:1161
SFErrCodes OpenTTFontFile(const char *fname, sal_uInt32 facenum, TrueTypeFont **ttf, const FontCharMapRef xCharMap)
TrueTypeFont constructor.
Definition: sft.cxx:1024
memory allocation error
constexpr sal_uInt32 T_true
Definition: sft.hxx:428
Black (Heavy)
Definition: sft.hxx:83
constexpr int HHEA_descender_offset
Definition: sft.hxx:311
constexpr int O_CFF
Definition: sft.hxx:718
constexpr sal_uInt32 T_loca
Definition: sft.hxx:436
sal_uInt16 adv
advance width or height
Definition: sft.hxx:116
constexpr int HEAD_created_offset
Definition: sft.hxx:367
constexpr int POST_underlineThickness_offset
Definition: sft.hxx:330
Normal (Regular)
Definition: sft.hxx:78
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
exports com.sun.star. table
Medium.
Definition: sft.hxx:79
sal_uInt32 m_nHorzMetrics
Definition: sft.hxx:726
sal_uInt32 m_nGlyphs
Definition: sft.hxx:724
sal_uInt32 ntables
Definition: sft.hxx:770
constexpr int HEAD_lowestRecPPEM_offset
Definition: sft.hxx:373
bool hasTable(sal_uInt32 ord) const override
Definition: sft.hxx:777
constexpr int O_cvt
Definition: sft.hxx:714
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:122
constexpr int O_cmap
Definition: sft.hxx:709
sal_uInt16 nbytes
number of bytes in glyph data
Definition: sft.hxx:124
incorrect logical font number of a TTC font
int width
value of WidthClass or 0 if can't be determined
Definition: sft.hxx:155
constexpr int GLYF_numberOfContours_offset
Definition: sft.hxx:422
int GetTTGlyphComponents(AbstractTrueTypeFont *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:1384
constexpr int MAXP_maxCompositePoints_offset
Definition: sft.hxx:401
sal_uInt8 panose[10]
PANOSE classification number.
Definition: sft.hxx:172
sal_Int16 x
X coordinate in EmSquare units.
Definition: sft.hxx:183
Semi-bold (Demi-bold)
Definition: sft.hxx:80
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
char * family
family name
Definition: sft.hxx:148
int yMin
global bounding box: yMin
Definition: sft.hxx:159
const char * fileName() const
Definition: sft.hxx:738
FontCharMapRef GetCharMap() const
Definition: sft.hxx:744
Medium, 100%.
Definition: sft.hxx:93
sal_uInt16 sal_Unicode
SFErrCodes open(sal_uInt32 facenum)
Definition: sft.cxx:1232
constexpr int OS2_usWidthClass_offset
Definition: sft.hxx:264
sal_uInt32 vertMetricCount() const
Definition: sft.hxx:742
TrueTypeFont(const char *pFileName=nullptr, const FontCharMapRef xCharMap=nullptr)
Definition: sft.cxx:1135
75% of normal
Definition: sft.hxx:91
62.5% of normal
Definition: sft.hxx:90
constexpr int O_prep
Definition: sft.hxx:715
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:1827
constexpr int MAXP_maxContours_offset
Definition: sft.hxx:400
constexpr int OS2_Legacy_length
Definition: sft.hxx:259
sal_Unicode * ufamily
Definition: sft.hxx:766
constexpr sal_uInt32 T_prep
Definition: sft.hxx:446
int winAscent
ascender metric for Windows
Definition: sft.hxx:169
constexpr int OS2_typoDescender_offset
Definition: sft.hxx:274
constexpr int O_fpgm
Definition: sft.hxx:716
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:2023
void GetTTFontMetrics(const uint8_t *pHhea, size_t nHhea, const uint8_t *pOs2, size_t nOs2, TTGlobalFontInfo *info)
Returns fonts metrics.
Definition: sft.cxx:1982
Extra-bold (Ultra-bold)
Definition: sft.hxx:82
CompositeFlags
Composite glyph flags definition.
Definition: sft.hxx:101
GlyphData * GetTTRawGlyphData(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID)
Extracts raw glyph data from the 'glyf' table and returns it in an allocated GlyphData structure...
Definition: sft.cxx:2076
sal_uInt32 typeFlags
type flags (copyright bits)
Definition: sft.hxx:173
char * psname
Definition: sft.hxx:764
constexpr sal_uInt32 T_maxp
Definition: sft.hxx:433
constexpr int HEAD_yMin_offset
Definition: sft.hxx:369
ControlPoint structure used by GetTTGlyphPoints()
Definition: sft.hxx:178
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:719
constexpr int OS2_winAscent_offset
Definition: sft.hxx:276
constexpr int HHEA_Length
Definition: sft.hxx:308
int typoAscender
OS/2 portable typographic ascender.
Definition: sft.hxx:166
constexpr int HHEA_ascender_offset
Definition: sft.hxx:310
sal_uInt32 newID
used internally by the TTCR
Definition: sft.hxx:132
int ascender
typographic ascent.
Definition: sft.hxx:162
constexpr int O_post
Definition: sft.hxx:713
112.5% of normal
Definition: sft.hxx:94
constexpr int HHEA_lineGap_offset
Definition: sft.hxx:312
int GetTTNameRecords(AbstractTrueTypeFont const *ttf, NameRecord **nr)
Extracts all Name Records from the font and stores them in an allocated array of NameRecord structs...
Definition: sft.cxx:2140
bool GetTTGlobalFontHeadInfo(const AbstractTrueTypeFont *ttf, int &xMin, int &yMin, int &xMax, int &yMax, sal_uInt16 &macStyle)
Returns part of the head table info, normally collected by GetTTGlobalFontInfo.
Definition: sft.cxx:2007
sal_Unicode * usubfamily
Definition: sft.hxx:768
int descender
typographic descent.
Definition: sft.hxx:163
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:708
int italicAngle
in counter-clockwise degrees * 65536
Definition: sft.hxx:157
150% of normal
Definition: sft.hxx:96
incorrect arguments
constexpr int O_gsub
Definition: sft.hxx:717
constexpr int HEAD_glyphDataFormat_offset
Definition: sft.hxx:376
constexpr sal_uInt32 T_hmtx
Definition: sft.hxx:439
sal_uInt32 horzMetricCount() const
Definition: sft.hxx:741
sal_uInt16 platformID
Platform ID.
Definition: sft.hxx:137
sal_uInt8 * sptr
Pointer to string data (not zero-terminated!)
Definition: sft.hxx:142
constexpr int HEAD_fontRevision_offset
Definition: sft.hxx:363
sal_uInt32 m_nUnitsPerEm
Definition: sft.hxx:728
char * family
Definition: sft.hxx:765
constexpr sal_uInt32 T_fpgm
Definition: sft.hxx:447
Light.
Definition: sft.hxx:77
int typoLineGap
OS/2 portable typographic line gap.
Definition: sft.hxx:168
int weight
value of WeightClass or 0 if can't be determined
Definition: sft.hxx:154
200% of normal
Definition: sft.hxx:97
constexpr int GLYF_xMin_offset
Definition: sft.hxx:423
int yMax
global bounding box: yMax
Definition: sft.hxx:161
constexpr int GLYF_yMax_offset
Definition: sft.hxx:426
constexpr int OS2_V0_length
Definition: sft.hxx:260
constexpr int O_loca
Definition: sft.hxx:705
constexpr int POST_isFixedPitch_offset
Definition: sft.hxx:331
constexpr int O_hhea
Definition: sft.hxx:707
const sal_uInt8 * table(sal_uInt32 ord, sal_uInt32 &size) const override
Definition: sft.hxx:781
constexpr int GLYF_xMax_offset
Definition: sft.hxx:425
std::array< struct TTFontTable_, NUM_TAGS > m_aTableList
Definition: sft.hxx:758
constexpr int OS2_typoLineGap_offset
Definition: sft.hxx:275
int xMax
global bounding box: xMax
Definition: sft.hxx:160
constexpr int O_maxp
Definition: sft.hxx:702
sal_uInt16 macStyle
macstyle bits from 'HEAD' table
Definition: sft.hxx:153
sal_uInt8 * ptr
Definition: sft.hxx:762
int xMin
global bounding box: xMin
Definition: sft.hxx:158
87.5% of normal
Definition: sft.hxx:92
Structure used by the TrueType Creator and CreateTTFromTTGlyphs()
Definition: sft.hxx:136
char * subfamily
Definition: sft.hxx:767
incorrect TrueType font format
sal_uInt32 glyphOffset(sal_uInt32 glyphID) const
Definition: sft.hxx:740
sal_Int16 lsb
left sidebearing
Definition: sft.hxx:127
WeightClass
Value of the weight member of the TTGlobalFontInfo struct.
Definition: sft.hxx:74
Structure used by GetTTSimpleCharMetrics() functions.
Definition: sft.hxx:115
constexpr int HEAD_xMin_offset
Definition: sft.hxx:368
constexpr int MAXP_maxPoints_offset
Definition: sft.hxx:399
unsigned char sal_uInt8
sal_uInt16 encodingID
Platform-specific encoding ID.
Definition: sft.hxx:138
LanguageType languageID
Language ID.
Definition: sft.hxx:139
const sal_uInt8 * pData
Definition: sft.hxx:754
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
bool getTTCoverage(std::optional< std::bitset< UnicodeCoverage::MAX_UC_ENUM >> &rUnicodeRange, std::optional< std::bitset< CodePageCoverage::MAX_CP_ENUM >> &rCodePageRange, const unsigned char *pTable, size_t nLength)
Definition: sft.cxx:2241
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
sal_Unicode * ufamily
family name UCS2
Definition: sft.hxx:149
125% of normal
Definition: sft.hxx:95
constexpr int POST_underlinePosition_offset
Definition: sft.hxx:329
constexpr int O_vhea
Definition: sft.hxx:710
sal_uInt16 slen
String length in bytes.
Definition: sft.hxx:141
sal_uInt16 npoints
number of points
Definition: sft.hxx:129
constexpr int O_glyf
Definition: sft.hxx:703
constexpr int MAXP_maxCompositeContours_offset
Definition: sft.hxx:402
constexpr sal_uInt32 T_CFF
Definition: sft.hxx:449
int linegap
typographic line gap. Negative values are treated as zero in Win 3.1, System 6 and System 7...
Definition: sft.hxx:164
constexpr int OS2_fsSelection_offset
Definition: sft.hxx:272
int GetTTGlyphPoints(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoint **pointArray)
Extracts TrueType control points, and stores them in an allocated array pointed to by *pointArray...
Definition: sft.cxx:1379
sal_uInt16 aw
advance width
Definition: sft.hxx:126
sal_uInt32 glyphID
glyph ID
Definition: sft.hxx:123
constexpr int O_vmtx
Definition: sft.hxx:711
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:1429
sal_uInt32 flags
00000000 00000000 e0000000 bbbbbbbb
Definition: sft.hxx:179
sal_uInt16 nameID
Name ID.
Definition: sft.hxx:140
sal_uInt32 m_nVertMetrics
Definition: sft.hxx:727
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
constexpr int O_name
Definition: sft.hxx:706
int typoDescender
OS/2 portable typographic descender.
Definition: sft.hxx:167
constexpr int OS2_ulUnicodeRange2_offset
Definition: sft.hxx:269
Return value of GetTTGlobalFontInfo()
Definition: sft.hxx:147
constexpr int MAXP_numGlyphs_offset
Definition: sft.hxx:398
constexpr sal_uInt32 T_vmtx
Definition: sft.hxx:442
sal_uInt32 * m_pGlyphOffsets
Definition: sft.hxx:725
constexpr int GLYF_yMin_offset
Definition: sft.hxx:424
constexpr int OS2_ulUnicodeRange4_offset
Definition: sft.hxx:271
sal_uInt8 * ptr
pointer to glyph data
Definition: sft.hxx:125
FontCharMapRef m_xCharMap
Definition: sft.hxx:729
SFErrCodes OpenTTFontBuffer(const void *pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTypeFont **ttf, const FontCharMapRef xCharMap)
TrueTypeFont constructor.
Definition: sft.cxx:1084