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>
45#include <vcl/fontcharmap.hxx>
46#include <i18nlangtag/lang.h>
47
48#include <array>
49#include <memory>
50#include <vector>
51#include <cstdint>
52
53namespace 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 */
75 FW_THIN = 100,
77 FW_LIGHT = 300,
78 FW_NORMAL = 400,
79 FW_MEDIUM = 500,
81 FW_BOLD = 700,
83 FW_BLACK = 900
84 };
85#endif /* FW_THIN */
86
98 };
99
111 OVERLAP_COMPOUND = 1<<10
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;
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*/
259constexpr int OS2_Legacy_length = 68;
260constexpr int OS2_V0_length = 78;
261constexpr int OS2_V1_length = 86;
262
263constexpr int OS2_usWeightClass_offset = 4;
264constexpr int OS2_usWidthClass_offset = 6;
265constexpr int OS2_fsType_offset = 8;
266constexpr int OS2_panose_offset = 32;
267constexpr int OS2_panoseNbBytes_offset = 10;
268constexpr int OS2_ulUnicodeRange1_offset = 42;
269constexpr int OS2_ulUnicodeRange2_offset = 46;
270constexpr int OS2_ulUnicodeRange3_offset = 50;
271constexpr int OS2_ulUnicodeRange4_offset = 54;
272constexpr int OS2_fsSelection_offset = 62;
273constexpr int OS2_typoAscender_offset = 68;
274constexpr int OS2_typoDescender_offset = 70;
275constexpr int OS2_typoLineGap_offset = 72;
276constexpr int OS2_winAscent_offset = 74;
277constexpr int OS2_winDescent_offset = 76;
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*/
308constexpr int HHEA_Length = 36;
309
310constexpr int HHEA_ascender_offset = 4;
311constexpr int HHEA_descender_offset = 6;
312constexpr int HHEA_lineGap_offset = 8;
313constexpr int HHEA_caretSlopeRise_offset = 18;
314constexpr 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*/
328constexpr int POST_italicAngle_offset = 4;
331constexpr 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*/
360constexpr int HEAD_Length = 54;
361
362constexpr int HEAD_majorVersion_offset = 0;
363constexpr int HEAD_fontRevision_offset = 4;
364constexpr int HEAD_magicNumber_offset = 12;
365constexpr int HEAD_flags_offset = 16;
366constexpr int HEAD_unitsPerEm_offset = 18;
367constexpr int HEAD_created_offset = 20;
368constexpr int HEAD_xMin_offset = 36;
369constexpr int HEAD_yMin_offset = 38;
370constexpr int HEAD_xMax_offset = 40;
371constexpr int HEAD_yMax_offset = 42;
372constexpr int HEAD_macStyle_offset = 44;
373constexpr int HEAD_lowestRecPPEM_offset = 46;
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*/
396constexpr int MAXP_Version1Length = 32;
397
398constexpr int MAXP_numGlyphs_offset = 4;
399constexpr int MAXP_maxPoints_offset = 6;
400constexpr 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*/
420constexpr int GLYF_Length = 10;
421
423constexpr int GLYF_xMin_offset = 2;
424constexpr int GLYF_yMin_offset = 4;
425constexpr int GLYF_xMax_offset = 6;
426constexpr int GLYF_yMax_offset = 8;
427
428constexpr sal_uInt32 T_true = 0x74727565; /* 'true' */
429constexpr sal_uInt32 T_ttcf = 0x74746366; /* 'ttcf' */
430constexpr sal_uInt32 T_otto = 0x4f54544f; /* 'OTTO' */
431
432// standard TrueType table tags
433constexpr sal_uInt32 T_maxp = 0x6D617870;
434constexpr sal_uInt32 T_glyf = 0x676C7966;
435constexpr sal_uInt32 T_head = 0x68656164;
436constexpr sal_uInt32 T_loca = 0x6C6F6361;
437constexpr sal_uInt32 T_name = 0x6E616D65;
438constexpr sal_uInt32 T_hhea = 0x68686561;
439constexpr sal_uInt32 T_hmtx = 0x686D7478;
440constexpr sal_uInt32 T_cmap = 0x636D6170;
441constexpr sal_uInt32 T_vhea = 0x76686561;
442constexpr sal_uInt32 T_vmtx = 0x766D7478;
443constexpr sal_uInt32 T_OS2 = 0x4F532F32;
444constexpr sal_uInt32 T_post = 0x706F7374;
445constexpr sal_uInt32 T_cvt = 0x63767420;
446constexpr sal_uInt32 T_prep = 0x70726570;
447constexpr sal_uInt32 T_fpgm = 0x6670676D;
448constexpr sal_uInt32 T_gsub = 0x47535542;
449constexpr sal_uInt32 T_CFF = 0x43464620;
450
452class 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)
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
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[] */
702constexpr int O_maxp = 0;
703constexpr int O_glyf = 1; /* 'glyf' */
704constexpr int O_head = 2; /* 'head' */
705constexpr int O_loca = 3; /* 'loca' */
706constexpr int O_name = 4; /* 'name' */
707constexpr int O_hhea = 5; /* 'hhea' */
708constexpr int O_hmtx = 6; /* 'hmtx' */
709constexpr int O_cmap = 7; /* 'cmap' */
710constexpr int O_vhea = 8; /* 'vhea' */
711constexpr int O_vmtx = 9; /* 'vmtx' */
712constexpr int O_OS2 = 10; /* 'OS/2' */
713constexpr int O_post = 11; /* 'post' */
714constexpr int O_cvt = 12; /* 'cvt_' - only used in TT->TT generation */
715constexpr int O_prep = 13; /* 'prep' - only used in TT->TT generation */
716constexpr int O_fpgm = 14; /* 'fpgm' - only used in TT->TT generation */
717constexpr int O_gsub = 15; /* 'GSUB' */
718constexpr int O_CFF = 16; /* 'CFF' */
719constexpr int NUM_TAGS = 17;
720
722{
723 std::string m_sFileName;
724 sal_uInt32 m_nGlyphs;
725 sal_uInt32 m_nHorzMetrics;
726 sal_uInt32 m_nVertMetrics; /* if not 0 => font has vertical metrics information */
727 sal_uInt32 m_nUnitsPerEm;
728 std::vector<sal_uInt32> m_aGlyphOffsets;
730
731protected:
732 SFErrCodes indexGlyphData();
733
734public:
735 AbstractTrueTypeFont(const char* fileName = nullptr, const FontCharMapRef xCharMap = nullptr);
736 virtual ~AbstractTrueTypeFont();
737
738 std::string const & fileName() const { return m_sFileName; }
739 sal_uInt32 glyphCount() const { return m_nGlyphs; }
740 sal_uInt32 glyphOffset(sal_uInt32 glyphID) const;
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 const 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
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
760public:
761 sal_Int32 fsize;
763
764 char *psname;
765 char *family;
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
781const 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: */
virtual bool hasTable(sal_uInt32 ord) const =0
sal_uInt32 m_nHorzMetrics
Definition: sft.hxx:725
sal_uInt32 vertMetricCount() const
Definition: sft.hxx:742
std::string const & fileName() const
Definition: sft.hxx:738
sal_uInt32 horzMetricCount() const
Definition: sft.hxx:741
sal_uInt32 m_nVertMetrics
Definition: sft.hxx:726
const FontCharMapRef & GetCharMap() const
Definition: sft.hxx:744
virtual const sal_uInt8 * table(sal_uInt32 ord, sal_uInt32 &size) const =0
sal_uInt32 m_nUnitsPerEm
Definition: sft.hxx:727
sal_uInt32 glyphCount() const
Definition: sft.hxx:739
sal_uInt32 m_nGlyphs
Definition: sft.hxx:724
FontCharMapRef m_xCharMap
Definition: sft.hxx:729
std::string m_sFileName
Definition: sft.hxx:723
std::vector< sal_uInt32 > m_aGlyphOffsets
Definition: sft.hxx:728
sal_uInt32 unitsPerEm() const
Definition: sft.hxx:743
const sal_uInt8 * table(sal_uInt32 ord, sal_uInt32 &size) const override
Definition: sft.hxx:781
~TrueTypeFont() override
Definition: sft.cxx:1225
sal_Unicode * ufamily
Definition: sft.hxx:766
sal_uInt8 * ptr
Definition: sft.hxx:762
sal_Unicode * usubfamily
Definition: sft.hxx:768
sal_Int32 fsize
Definition: sft.hxx:761
bool hasTable(sal_uInt32 ord) const override
Definition: sft.hxx:777
char * family
Definition: sft.hxx:765
char * psname
Definition: sft.hxx:764
TrueTypeFont(const char *pFileName=nullptr, const FontCharMapRef xCharMap=nullptr)
Definition: sft.cxx:1212
char * subfamily
Definition: sft.hxx:767
sal_uInt32 ntables
Definition: sft.hxx:770
SFErrCodes open(sal_uInt32 facenum)
Definition: sft.cxx:1310
std::array< struct TTFontTable_, NUM_TAGS > m_aTableList
Definition: sft.hxx:758
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
SFErrCodes OpenTTFontBuffer(const void *pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTypeFont **ttf, const FontCharMapRef xCharMap)
TrueTypeFont constructor.
Definition: sft.cxx:1165
std::unique_ptr< sal_uInt16[]> GetTTSimpleGlyphMetrics(AbstractTrueTypeFont const *ttf, const sal_uInt16 *glyphArray, int nGlyphs, bool vertical)
Queries glyph metrics.
Definition: sft.cxx:2075
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:2215
int CountTTCFonts(const char *fname)
Get the number of fonts contained in a TrueType collection.
Definition: sft.cxx:1089
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:2306
void DisposeNameRecords(NameRecord *nr, int n)
Deallocates previously allocated array of NameRecords.
Definition: sft.cxx:2389
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:1457
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:1692
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:2144
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:1462
void CloseTTFont(TrueTypeFont *ttf)
TrueTypeFont destructor.
Definition: sft.cxx:1238
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:1539
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:1964
void GetTTFontMetrics(const uint8_t *pHhea, size_t nHhea, const uint8_t *pOs2, size_t nOs2, TTGlobalFontInfo *info)
Returns fonts metrics.
Definition: sft.cxx:2119
void GetTTGlobalFontInfo(TrueTypeFont *ttf, TTGlobalFontInfo *info)
Returns global font information about the TrueType font.
Definition: sft.cxx:2162
SFErrCodes OpenTTFontFile(const char *fname, sal_uInt32 facenum, TrueTypeFont **ttf, const FontCharMapRef xCharMap)
TrueTypeFont constructor.
Definition: sft.cxx:1105
size
constexpr int HHEA_ascender_offset
Definition: sft.hxx:310
constexpr int OS2_ulCodePageRange1_offset
Definition: sft.hxx:278
constexpr int HEAD_glyphDataFormat_offset
Definition: sft.hxx:376
constexpr int OS2_ulUnicodeRange4_offset
Definition: sft.hxx:271
constexpr int OS2_fsType_offset
Definition: sft.hxx:265
constexpr sal_uInt32 T_ttcf
Definition: sft.hxx:429
constexpr int O_vmtx
Definition: sft.hxx:711
constexpr int O_prep
Definition: sft.hxx:715
constexpr int O_fpgm
Definition: sft.hxx:716
constexpr int HHEA_lineGap_offset
Definition: sft.hxx:312
constexpr int OS2_typoDescender_offset
Definition: sft.hxx:274
constexpr int HEAD_lowestRecPPEM_offset
Definition: sft.hxx:373
constexpr int OS2_Legacy_length
Definition: sft.hxx:259
constexpr int OS2_usWeightClass_offset
Definition: sft.hxx:263
constexpr int HEAD_fontRevision_offset
Definition: sft.hxx:363
constexpr sal_uInt32 T_post
Definition: sft.hxx:444
constexpr sal_uInt32 T_cvt
Definition: sft.hxx:445
constexpr sal_uInt32 T_vhea
Definition: sft.hxx:441
constexpr sal_uInt32 T_loca
Definition: sft.hxx:436
constexpr int HEAD_majorVersion_offset
Definition: sft.hxx:362
constexpr int HHEA_Length
Definition: sft.hxx:308
constexpr int OS2_winAscent_offset
Definition: sft.hxx:276
constexpr int HEAD_yMax_offset
Definition: sft.hxx:371
constexpr int HHEA_caretSlopeRise_offset
Definition: sft.hxx:313
constexpr sal_uInt32 T_otto
Definition: sft.hxx:430
constexpr int GLYF_xMax_offset
Definition: sft.hxx:425
SFErrCodes
Return value of OpenTTFont() and CreateT3FromTTGlyphs()
Definition: sft.hxx:61
@ FontNo
incorrect logical font number of a TTC font
@ TtFormat
incorrect TrueType font format
@ FileIo
file I/O error
@ GlyphNum
incorrect number of glyphs
@ BadFile
file not found
@ BadArg
incorrect arguments
constexpr int OS2_typoAscender_offset
Definition: sft.hxx:273
constexpr int MAXP_maxCompositePoints_offset
Definition: sft.hxx:401
constexpr int GLYF_Length
Definition: sft.hxx:420
struct TTGlobalFontInfo_ TTGlobalFontInfo
Return value of GetTTGlobalFontInfo()
Definition: salgdi.hxx:62
constexpr int OS2_typoLineGap_offset
Definition: sft.hxx:275
constexpr sal_uInt32 T_true
Definition: sft.hxx:428
constexpr sal_uInt32 T_prep
Definition: sft.hxx:446
constexpr sal_uInt32 T_glyf
Definition: sft.hxx:434
constexpr int O_OS2
Definition: sft.hxx:712
constexpr int O_vhea
Definition: sft.hxx:710
constexpr int OS2_ulUnicodeRange3_offset
Definition: sft.hxx:270
constexpr int MAXP_Version1Length
Definition: sft.hxx:396
constexpr int GLYF_numberOfContours_offset
Definition: sft.hxx:422
constexpr int O_hhea
Definition: sft.hxx:707
constexpr int OS2_ulCodePageRange2_offset
Definition: sft.hxx:279
constexpr sal_uInt32 T_hhea
Definition: sft.hxx:438
constexpr int MAXP_maxCompositeContours_offset
Definition: sft.hxx:402
constexpr int OS2_panoseNbBytes_offset
Definition: sft.hxx:267
constexpr int NUM_TAGS
Definition: sft.hxx:719
constexpr int MAXP_maxPoints_offset
Definition: sft.hxx:399
constexpr int OS2_fsSelection_offset
Definition: sft.hxx:272
constexpr int OS2_ulUnicodeRange2_offset
Definition: sft.hxx:269
constexpr int HEAD_created_offset
Definition: sft.hxx:367
constexpr int GLYF_yMax_offset
Definition: sft.hxx:426
constexpr int HHEA_caretSlopeRun_offset
Definition: sft.hxx:314
constexpr int O_cmap
Definition: sft.hxx:709
constexpr int HEAD_flags_offset
Definition: sft.hxx:365
constexpr int HEAD_unitsPerEm_offset
Definition: sft.hxx:366
constexpr int O_gsub
Definition: sft.hxx:717
constexpr int O_post
Definition: sft.hxx:713
WidthClass
Value of the width member of the TTGlobalFontInfo struct.
Definition: sft.hxx:88
@ FWIDTH_CONDENSED
75% of normal
Definition: sft.hxx:91
@ FWIDTH_ULTRA_CONDENSED
50% of normal
Definition: sft.hxx:89
@ FWIDTH_SEMI_EXPANDED
112.5% of normal
Definition: sft.hxx:94
@ FWIDTH_EXTRA_EXPANDED
150% of normal
Definition: sft.hxx:96
@ FWIDTH_EXPANDED
125% of normal
Definition: sft.hxx:95
@ FWIDTH_EXTRA_CONDENSED
62.5% of normal
Definition: sft.hxx:90
@ FWIDTH_ULTRA_EXPANDED
200% of normal
Definition: sft.hxx:97
@ FWIDTH_NORMAL
Medium, 100%
Definition: sft.hxx:93
@ FWIDTH_SEMI_CONDENSED
87.5% of normal
Definition: sft.hxx:92
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:2407
constexpr int O_loca
Definition: sft.hxx:705
constexpr int HEAD_xMax_offset
Definition: sft.hxx:370
constexpr sal_uInt32 T_head
Definition: sft.hxx:435
constexpr int HEAD_yMin_offset
Definition: sft.hxx:369
constexpr sal_uInt32 T_gsub
Definition: sft.hxx:448
constexpr int MAXP_maxContours_offset
Definition: sft.hxx:400
constexpr int HEAD_fontDirectionHint_offset
Definition: sft.hxx:374
constexpr int HEAD_xMin_offset
Definition: sft.hxx:368
constexpr int MAXP_numGlyphs_offset
Definition: sft.hxx:398
constexpr int O_CFF
Definition: sft.hxx:718
constexpr int POST_isFixedPitch_offset
Definition: sft.hxx:331
constexpr int POST_underlinePosition_offset
Definition: sft.hxx:329
constexpr int GLYF_yMin_offset
Definition: sft.hxx:424
constexpr int HEAD_magicNumber_offset
Definition: sft.hxx:364
constexpr int OS2_V1_length
Definition: sft.hxx:261
constexpr int POST_italicAngle_offset
Definition: sft.hxx:328
constexpr sal_uInt32 T_maxp
Definition: sft.hxx:433
constexpr sal_uInt32 T_OS2
Definition: sft.hxx:443
constexpr sal_uInt32 T_CFF
Definition: sft.hxx:449
constexpr int GLYF_xMin_offset
Definition: sft.hxx:423
constexpr int HEAD_indexToLocFormat_offset
Definition: sft.hxx:375
constexpr sal_uInt32 T_hmtx
Definition: sft.hxx:439
constexpr sal_uInt32 T_name
Definition: sft.hxx:437
constexpr int O_maxp
Definition: sft.hxx:702
constexpr int HEAD_macStyle_offset
Definition: sft.hxx:372
constexpr sal_uInt32 T_fpgm
Definition: sft.hxx:447
constexpr int O_cvt
Definition: sft.hxx:714
constexpr int POST_underlineThickness_offset
Definition: sft.hxx:330
constexpr int HHEA_descender_offset
Definition: sft.hxx:311
constexpr int OS2_ulUnicodeRange1_offset
Definition: sft.hxx:268
constexpr int HEAD_Length
Definition: sft.hxx:360
constexpr int O_name
Definition: sft.hxx:706
constexpr int O_glyf
Definition: sft.hxx:703
constexpr int OS2_panose_offset
Definition: sft.hxx:266
constexpr int O_head
Definition: sft.hxx:704
constexpr sal_uInt32 T_cmap
Definition: sft.hxx:440
constexpr sal_uInt32 T_vmtx
Definition: sft.hxx:442
constexpr int OS2_winDescent_offset
Definition: sft.hxx:277
WeightClass
Value of the weight member of the TTGlobalFontInfo struct.
Definition: sft.hxx:74
@ FW_THIN
Thin
Definition: sft.hxx:75
@ FW_LIGHT
Light
Definition: sft.hxx:77
@ FW_SEMIBOLD
Semi-bold (Demi-bold)
Definition: sft.hxx:80
@ FW_NORMAL
Normal (Regular)
Definition: sft.hxx:78
@ FW_EXTRALIGHT
Extra-light (Ultra-light)
Definition: sft.hxx:76
@ FW_BLACK
Black (Heavy)
Definition: sft.hxx:83
@ FW_EXTRABOLD
Extra-bold (Ultra-bold)
Definition: sft.hxx:82
@ FW_BOLD
Bold
Definition: sft.hxx:81
@ FW_MEDIUM
Medium
Definition: sft.hxx:79
constexpr int OS2_usWidthClass_offset
Definition: sft.hxx:264
CompositeFlags
Composite glyph flags definition.
Definition: sft.hxx:101
@ WE_HAVE_A_TWO_BY_TWO
Definition: sft.hxx:108
@ ARG_1_AND_2_ARE_WORDS
Definition: sft.hxx:102
@ ROUND_XY_TO_GRID
Definition: sft.hxx:104
@ WE_HAVE_A_SCALE
Definition: sft.hxx:105
@ WE_HAVE_INSTRUCTIONS
Definition: sft.hxx:109
@ MORE_COMPONENTS
Definition: sft.hxx:106
@ WE_HAVE_AN_X_AND_Y_SCALE
Definition: sft.hxx:107
@ OVERLAP_COMPOUND
Definition: sft.hxx:111
@ USE_MY_METRICS
Definition: sft.hxx:110
@ ARGS_ARE_XY_VALUES
Definition: sft.hxx:103
constexpr int O_hmtx
Definition: sft.hxx:708
sal_Int32 F16Dot16
fixed: 16.16
Definition: sft.hxx:57
constexpr int OS2_V0_length
Definition: sft.hxx:260
@ Memory
ControlPoint structure used by GetTTGlyphPoints()
Definition: sft.hxx:178
sal_Int16 y
Y coordinate in EmSquare units
Definition: sft.hxx:184
sal_Int16 x
X coordinate in EmSquare units
Definition: sft.hxx:183
sal_uInt32 flags
00000000 00000000 e0000000 bbbbbbbb
Definition: sft.hxx:179
Structure used by the TrueType Creator and GetRawGlyphData()
Definition: sft.hxx:122
sal_uInt32 glyphID
glyph ID
Definition: sft.hxx:123
bool compflag
false- if non-composite
Definition: sft.hxx:128
sal_uInt16 ncontours
number of contours
Definition: sft.hxx:130
sal_uInt16 npoints
number of points
Definition: sft.hxx:129
sal_uInt8 * ptr
pointer to glyph data
Definition: sft.hxx:125
sal_uInt16 aw
advance width
Definition: sft.hxx:126
sal_uInt32 newID
used internally by the TTCR
Definition: sft.hxx:132
sal_uInt16 nbytes
number of bytes in glyph data
Definition: sft.hxx:124
sal_Int16 lsb
left sidebearing
Definition: sft.hxx:127
Structure used by the TrueType Creator and CreateTTFromTTGlyphs()
Definition: sft.hxx:136
sal_uInt16 slen
String length in bytes
Definition: sft.hxx:141
sal_uInt16 encodingID
Platform-specific encoding ID
Definition: sft.hxx:138
LanguageType languageID
Language ID
Definition: sft.hxx:139
sal_uInt16 platformID
Platform ID
Definition: sft.hxx:137
sal_uInt8 * sptr
Pointer to string data (not zero-terminated!)
Definition: sft.hxx:142
sal_uInt16 nameID
Name ID
Definition: sft.hxx:140
Return value of GetTTGlobalFontInfo()
Definition: sft.hxx:147
int italicAngle
in counter-clockwise degrees * 65536
Definition: sft.hxx:157
int ascender
typographic ascent.
Definition: sft.hxx:162
int typoDescender
OS/2 portable typographic descender
Definition: sft.hxx:167
int yMin
global bounding box: yMin
Definition: sft.hxx:159
int winAscent
ascender metric for Windows
Definition: sft.hxx:169
int xMin
global bounding box: xMin
Definition: sft.hxx:158
int typoAscender
OS/2 portable typographic ascender
Definition: sft.hxx:166
sal_uInt8 panose[10]
PANOSE classification number
Definition: sft.hxx:172
int width
value of WidthClass or 0 if can't be determined
Definition: sft.hxx:155
sal_Unicode * ufamily
family name UCS2
Definition: sft.hxx:149
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
int xMax
global bounding box: xMax
Definition: sft.hxx:160
sal_uInt32 typeFlags
type flags (copyright bits)
Definition: sft.hxx:173
int winDescent
descender metric for Windows
Definition: sft.hxx:170
char * psname
PostScript name
Definition: sft.hxx:152
char * subfamily
subfamily name
Definition: sft.hxx:150
int linegap
typographic line gap. Negative values are treated as zero in Win 3.1, System 6 and System 7.
Definition: sft.hxx:164
int descender
typographic descent.
Definition: sft.hxx:163
bool symbolEncoded
true: MS symbol encoded
Definition: sft.hxx:171
char * family
family name
Definition: sft.hxx:148
int pitch
0: proportional font, otherwise: monospaced
Definition: sft.hxx:156
sal_uInt16 fsSelection
OS/2 fsSelection.
Definition: sft.hxx:174
sal_Unicode * usubfamily
subfamily name UCS2
Definition: sft.hxx:151
sal_uInt16 macStyle
macstyle bits from 'HEAD' table
Definition: sft.hxx:153
int yMax
global bounding box: yMax
Definition: sft.hxx:161
Structure used by GetTTSimpleCharMetrics() functions.
Definition: sft.hxx:115
sal_Int16 sb
left or top sidebearing
Definition: sft.hxx:117
sal_uInt16 adv
advance width or height
Definition: sft.hxx:116
const sal_uInt8 * pData
Definition: sft.hxx:754
unsigned char sal_uInt8
sal_uInt16 sal_Unicode