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
54
55class SvStream;
56
57namespace vcl
58{
59
61 typedef sal_Int32 F16Dot16;
63
65 enum class SFErrCodes {
66 Ok,
67 BadFile,
68 FileIo,
69 Memory,
70 GlyphNum,
71 BadArg,
72 TtFormat,
73 FontNo
74 };
75
76#ifndef FW_THIN /* WIN32 compilation would conflict */
79 FW_THIN = 100,
81 FW_LIGHT = 300,
82 FW_NORMAL = 400,
83 FW_MEDIUM = 500,
85 FW_BOLD = 700,
87 FW_BLACK = 900
88 };
89#endif /* FW_THIN */
90
102 };
103
115 OVERLAP_COMPOUND = 1<<10
116 };
117
119 typedef struct {
120 sal_uInt16 adv;
121 sal_Int16 sb;
123
126 typedef struct {
127 sal_uInt32 glyphID;
128 sal_uInt16 nbytes;
129 std::unique_ptr<sal_uInt8[]> ptr;
130 sal_uInt16 aw;
131 sal_Int16 lsb;
132 bool compflag;
133 sal_uInt16 npoints;
134 sal_uInt16 ncontours;
135 /* */
136 sal_uInt32 newID;
137 } GlyphData;
138
140 struct NameRecord {
141 sal_uInt16 platformID;
142 sal_uInt16 encodingID;
144 sal_uInt16 nameID;
145 std::vector<sal_uInt8> sptr;
146 };
147
150 typedef struct TTGlobalFontInfo_ {
151 OString family;
152 OUString ufamily;
153 OString subfamily;
154 OUString usubfamily;
155 OString psname;
156 sal_uInt16 macStyle = 0;
157 int weight = 0;
158 int width = 0;
159 int pitch = 0;
160 int italicAngle = 0;
161 int xMin = 0;
162 int yMin = 0;
163 int xMax = 0;
164 int yMax = 0;
165 int ascender = 0;
166 int descender = 0;
167 int linegap = 0;
169 int typoAscender = 0;
171 int typoLineGap = 0;
172 int winAscent = 0;
173 int winDescent = 0;
175 sal_uInt8 panose[10] = {};
176 sal_uInt32 typeFlags = 0;
177 sal_uInt16 fsSelection = 0;
179
181 typedef struct {
182 sal_uInt32 flags;
186 sal_Int16 x;
187 sal_Int16 y;
188 } ControlPoint;
189
190
191/*
192 Some table OS/2 consts
193 quick history:
194 OpenType has been created from TrueType
195 - original TrueType had an OS/2 table with a length of 68 bytes
196 (cf https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6OS2.html)
197 - There have been 6 versions (from version 0 to 5)
198 (cf https://docs.microsoft.com/en-us/typography/opentype/otspec140/os2ver0)
199
200 For the record:
201 // From Initial TrueType version
202 TYPE NAME FROM BYTE
203 uint16 version 0
204 int16 xAvgCharWidth 2
205 uint16 usWeightClass 4
206 uint16 usWidthClass 6
207 uint16 fsType 8
208 int16 ySubscriptXSize 10
209 int16 ySubscriptYSize 12
210 int16 ySubscriptXOffset 14
211 int16 ySubscriptYOffset 16
212 int16 ySuperscriptXSize 18
213 int16 ySuperscriptYSize 20
214 int16 ySuperscriptXOffset 22
215 int16 ySuperscriptYOffset 24
216 int16 yStrikeoutSize 26
217 int16 yStrikeoutPosition 28
218 int16 sFamilyClass 30
219 uint8 panose[10] 32
220 uint32 ulUnicodeRange1 42
221 uint32 ulUnicodeRange2 46
222 uint32 ulUnicodeRange3 50
223 uint32 ulUnicodeRange4 54
224 Tag achVendID 58
225 uint16 fsSelection 62
226 uint16 usFirstCharIndex 64
227 uint16 usLastCharIndex 66
228
229 // From Version 0 of OpenType
230 int16 sTypoAscender 68
231 int16 sTypoDescender 70
232 int16 sTypoLineGap 72
233 uint16 usWinAscent 74
234 uint16 usWinDescent 76
235
236 => length for OpenType version 0 = 78 bytes
237
238 // From Version 1 of OpenType
239 uint32 ulCodePageRange1 78
240 uint32 ulCodePageRange2 82
241
242 => length for OpenType version 1 = 86 bytes
243
244 // From Version 2 of OpenType
245 // (idem for Versions 3 and 4)
246 int16 sxHeight 86
247 int16 sCapHeight 88
248 uint16 usDefaultChar 90
249 uint16 usBreakChar 92
250 uint16 usMaxContext 94
251
252 => length for OpenType version 2, 3 and 4 = 96 bytes
253
254 // From Version 5 of OpenType
255 uint16 usLowerOpticalPointSize 96
256 uint16 usUpperOpticalPointSize 98
257 END 100
258
259 => length for OS/2 table version 5 = 100 bytes
260
261*/
262constexpr int OS2_Legacy_length = 68;
263constexpr int OS2_V0_length = 78;
264constexpr int OS2_V1_length = 86;
265
266constexpr int OS2_usWeightClass_offset = 4;
267constexpr int OS2_usWidthClass_offset = 6;
268constexpr int OS2_fsType_offset = 8;
269constexpr int OS2_panose_offset = 32;
270constexpr int OS2_panoseNbBytes_offset = 10;
271constexpr int OS2_ulUnicodeRange1_offset = 42;
272constexpr int OS2_ulUnicodeRange2_offset = 46;
273constexpr int OS2_ulUnicodeRange3_offset = 50;
274constexpr int OS2_ulUnicodeRange4_offset = 54;
275constexpr int OS2_fsSelection_offset = 62;
276constexpr int OS2_typoAscender_offset = 68;
277constexpr int OS2_typoDescender_offset = 70;
278constexpr int OS2_typoLineGap_offset = 72;
279constexpr int OS2_winAscent_offset = 74;
280constexpr int OS2_winDescent_offset = 76;
283
284/*
285 Some table hhea consts
286 cf https://docs.microsoft.com/fr-fr/typography/opentype/spec/hhea
287 TYPE NAME FROM BYTE
288 uint16 majorVersion 0
289 uint16 minorVersion 2
290 FWORD ascender 4
291 FWORD descender 6
292 FWORD lineGap 8
293 UFWORD advanceWidthMax 10
294 FWORD minLeftSideBearing 12
295 FWORD minRightSideBearing 14
296 FWORD xMaxExtent 16
297 int16 caretSlopeRise 18
298 int16 caretSlopeRun 20
299 int16 caretOffset 22
300 int16 (reserved) 24
301 int16 (reserved) 26
302 int16 (reserved) 28
303 int16 (reserved) 30
304 int16 metricDataFormat 32
305 uint16 numberOfHMetrics 34
306 END 36
307
308 => length for hhea table = 36 bytes
309
310*/
311constexpr int HHEA_Length = 36;
312
313constexpr int HHEA_ascender_offset = 4;
314constexpr int HHEA_descender_offset = 6;
315constexpr int HHEA_lineGap_offset = 8;
316constexpr int HHEA_caretSlopeRise_offset = 18;
317constexpr int HHEA_caretSlopeRun_offset = 20;
318
319/*
320 Some table post consts
321 cf https://docs.microsoft.com/fr-fr/typography/opentype/spec/post
322 TYPE NAME FROM BYTE
323 Fixed version 0
324 Fixed italicAngle 4
325 FWord underlinePosition 8
326 FWord underlineThickness 10
327 uint32 isFixedPitch 12
328 ...
329
330*/
331constexpr int POST_italicAngle_offset = 4;
334constexpr int POST_isFixedPitch_offset = 12;
335
336/*
337 Some table head consts
338 cf https://docs.microsoft.com/fr-fr/typography/opentype/spec/head
339 TYPE NAME FROM BYTE
340 uit16 majorVersion 0
341 uit16 minorVersion 2
342 Fixed fontRevision 4
343 uint32 checkSumAdjustment 8
344 uint32 magicNumber 12 (= 0x5F0F3CF5)
345 uint16 flags 16
346 uint16 unitsPerEm 18
347 LONGDATETIME created 20
348 LONGDATETIME modified 28
349 int16 xMin 36
350 int16 yMin 38
351 int16 xMax 40
352 int16 yMax 42
353 uint16 macStyle 44
354 uint16 lowestRecPPEM 46
355 int16 fontDirectionHint 48
356 int16 indexToLocFormat 50
357 int16 glyphDataFormat 52
358
359 END 54
360
361 => length head table = 54 bytes
362*/
363constexpr int HEAD_Length = 54;
364
365constexpr int HEAD_majorVersion_offset = 0;
366constexpr int HEAD_fontRevision_offset = 4;
367constexpr int HEAD_magicNumber_offset = 12;
368constexpr int HEAD_flags_offset = 16;
369constexpr int HEAD_unitsPerEm_offset = 18;
370constexpr int HEAD_created_offset = 20;
371constexpr int HEAD_xMin_offset = 36;
372constexpr int HEAD_yMin_offset = 38;
373constexpr int HEAD_xMax_offset = 40;
374constexpr int HEAD_yMax_offset = 42;
375constexpr int HEAD_macStyle_offset = 44;
376constexpr int HEAD_lowestRecPPEM_offset = 46;
380
381/*
382 Some table maxp consts
383 cf https://docs.microsoft.com/fr-fr/typography/opentype/spec/maxp
384 For 0.5 version
385 TYPE NAME FROM BYTE
386 Fixed version 0
387 uint16 numGlyphs 4
388
389 For 1.0 Version
390 Fixed version 0
391 uint16 numGlyphs 4
392 uint16 maxPoints 6
393 uint16 maxContours 8
394 uint16 maxCompositePoints 10
395 uint16 maxCompositeContours 12
396 ...
397
398*/
399constexpr int MAXP_Version1Length = 32;
400
401constexpr int MAXP_numGlyphs_offset = 4;
402constexpr int MAXP_maxPoints_offset = 6;
403constexpr int MAXP_maxContours_offset = 8;
406
407/*
408 Some table glyf consts
409 cf https://docs.microsoft.com/fr-fr/typography/opentype/spec/glyf
410 For 0.5 version
411 TYPE NAME FROM BYTE
412 int16 numberOfContours 0
413 int16 xMin 2
414 int16 yMin 4
415 int16 xMax 6
416 int16 yMax 8
417
418 END 10
419
420 => length glyf table = 10 bytes
421
422*/
423constexpr int GLYF_Length = 10;
424
426constexpr int GLYF_xMin_offset = 2;
427constexpr int GLYF_yMin_offset = 4;
428constexpr int GLYF_xMax_offset = 6;
429constexpr int GLYF_yMax_offset = 8;
430
431constexpr sal_uInt32 T_true = 0x74727565; /* 'true' */
432constexpr sal_uInt32 T_ttcf = 0x74746366; /* 'ttcf' */
433constexpr sal_uInt32 T_otto = 0x4f54544f; /* 'OTTO' */
434
435// standard TrueType table tags
436constexpr sal_uInt32 T_maxp = 0x6D617870;
437constexpr sal_uInt32 T_glyf = 0x676C7966;
438constexpr sal_uInt32 T_head = 0x68656164;
439constexpr sal_uInt32 T_loca = 0x6C6F6361;
440constexpr sal_uInt32 T_name = 0x6E616D65;
441constexpr sal_uInt32 T_hhea = 0x68686561;
442constexpr sal_uInt32 T_hmtx = 0x686D7478;
443constexpr sal_uInt32 T_cmap = 0x636D6170;
444constexpr sal_uInt32 T_vhea = 0x76686561;
445constexpr sal_uInt32 T_vmtx = 0x766D7478;
446constexpr sal_uInt32 T_OS2 = 0x4F532F32;
447constexpr sal_uInt32 T_post = 0x706F7374;
448constexpr sal_uInt32 T_cvt = 0x63767420;
449constexpr sal_uInt32 T_prep = 0x70726570;
450constexpr sal_uInt32 T_fpgm = 0x6670676D;
451constexpr sal_uInt32 T_CFF = 0x43464620;
452
454class TrueTypeFont;
455
466 int CountTTCFonts(const char* fname);
467
480 SFErrCodes VCL_DLLPUBLIC OpenTTFontBuffer(const void* pBuffer, sal_uInt32 nLen, sal_uInt32 facenum,
481 TrueTypeFont** ttf, const FontCharMapRef xCharMap = nullptr);
482#if !defined(_WIN32)
495 SFErrCodes VCL_DLLPUBLIC OpenTTFontFile(const char *fname, sal_uInt32 facenum, TrueTypeFont** ttf,
496 const FontCharMapRef xCharMap = nullptr);
497#endif
498
500 std::optional<std::bitset<UnicodeCoverage::MAX_UC_ENUM>> & rUnicodeCoverage,
501 std::optional<std::bitset<CodePageCoverage::MAX_CP_ENUM>> & rCodePageCoverage,
502 const unsigned char* pTable, size_t nLength);
503
509
523 int GetTTGlyphPoints(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID, std::vector<ControlPoint>& pointArray);
524
537 std::unique_ptr<GlyphData> GetTTRawGlyphData(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID);
538
554 int GetTTGlyphComponents(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID, std::vector< sal_uInt32 >& glyphlist);
555
566 void GetTTNameRecords(AbstractTrueTypeFont const *ttf, std::vector<NameRecord>& nr);
567
585 SFErrCodes CreateT3FromTTGlyphs(TrueTypeFont *ttf, SvStream *outf, const char *fname, sal_uInt16 const *glyphArray, sal_uInt8 *encoding, int nGlyphs, int wmode);
586
605 std::vector<sal_uInt8>& rOutBuffer,
606 sal_uInt16 const *glyphArray,
607 sal_uInt8 const *encoding,
608 int nGlyphs);
609
611 std::vector<sal_uInt8>& rOutBuffer,
612 const sal_GlyphId* pGlyphIds,
613 const sal_uInt8* pEncoding,
614 int nGlyphCount);
615
616 VCL_DLLPUBLIC bool CreateCFFfontSubset(const unsigned char* pFontBytes,
617 int nByteLength,
618 std::vector<sal_uInt8>& rOutBuffer,
619 const OUString& rPSName,
620 const sal_GlyphId* pGlyphIds,
621 const sal_uInt8* pEncoding,
622 int nGlyphCount, FontSubsetInfo& rInfo);
623
625 FontSubsetInfo& rInfo);
647 SvStream *outf,
648 const char *psname,
649 sal_uInt16 const *glyphArray,
650 sal_uInt8 *encoding,
651 int nGlyphs);
652
663
678 VCL_DLLPUBLIC bool GetTTGlobalFontHeadInfo(const AbstractTrueTypeFont *ttf, int& xMin, int& yMin, int& xMax, int& yMax, sal_uInt16& macStyle);
679
680/*- private definitions */
681
682/* indexes into TrueTypeFont::tables[] and TrueTypeFont::tlens[] */
683constexpr int O_maxp = 0;
684constexpr int O_glyf = 1; /* 'glyf' */
685constexpr int O_head = 2; /* 'head' */
686constexpr int O_loca = 3; /* 'loca' */
687constexpr int O_name = 4; /* 'name' */
688constexpr int O_hhea = 5; /* 'hhea' */
689constexpr int O_hmtx = 6; /* 'hmtx' */
690constexpr int O_cmap = 7; /* 'cmap' */
691constexpr int O_vhea = 8; /* 'vhea' */
692constexpr int O_vmtx = 9; /* 'vmtx' */
693constexpr int O_OS2 = 10; /* 'OS/2' */
694constexpr int O_post = 11; /* 'post' */
695constexpr int O_cvt = 12; /* 'cvt_' - only used in TT->TT generation */
696constexpr int O_prep = 13; /* 'prep' - only used in TT->TT generation */
697constexpr int O_fpgm = 14; /* 'fpgm' - only used in TT->TT generation */
698constexpr int O_CFF = 15; /* 'CFF' */
699constexpr int NUM_TAGS = 16;
700
702{
703 std::string m_sFileName;
704 sal_uInt32 m_nGlyphs;
705 sal_uInt32 m_nHorzMetrics;
706 sal_uInt32 m_nVertMetrics; /* if not 0 => font has vertical metrics information */
707 sal_uInt32 m_nUnitsPerEm;
708 std::vector<sal_uInt32> m_aGlyphOffsets;
711
712protected:
713 SFErrCodes indexGlyphData();
714
715public:
716 AbstractTrueTypeFont(const char* fileName = nullptr, const FontCharMapRef xCharMap = nullptr);
717 virtual ~AbstractTrueTypeFont();
718
719 SFErrCodes initialize();
720
721 std::string const & fileName() const { return m_sFileName; }
722 sal_uInt32 glyphCount() const { return m_nGlyphs; }
723 sal_uInt32 glyphOffset(sal_uInt32 glyphID) const;
724 sal_uInt32 horzMetricCount() const { return m_nHorzMetrics; }
725 sal_uInt32 vertMetricCount() const { return m_nVertMetrics; }
726 sal_uInt32 unitsPerEm() const { return m_nUnitsPerEm; }
727 bool IsMicrosoftSymbolEncoded() const { return m_bMicrosoftSymbolEncoded; }
728
729 virtual bool hasTable(sal_uInt32 ord) const = 0;
730 virtual const sal_uInt8* table(sal_uInt32 ord, sal_uInt32& size) const = 0;
731
732 OString psname;
733 OString family;
734 OUString ufamily;
735 OString subfamily;
736 OUString usubfamily;
737};
738
740{
742 {
743 const sal_uInt8* pData = nullptr; /* pointer to a raw subtable in the SFNT file */
744 sal_uInt32 nSize = 0; /* table size */
745 };
746
747 std::array<struct TTFontTable_, NUM_TAGS> m_aTableList;
748
749public:
750 sal_Int32 fsize;
752 sal_uInt32 ntables;
753
754 TrueTypeFont(const char* pFileName = nullptr, const FontCharMapRef xCharMap = nullptr);
755 ~TrueTypeFont() override;
756
757 SFErrCodes open(sal_uInt32 facenum);
758
759 bool hasTable(sal_uInt32 ord) const override { return m_aTableList[ord].pData != nullptr; }
760 inline const sal_uInt8* table(sal_uInt32 ord, sal_uInt32& size) const override;
761};
762
763const sal_uInt8* TrueTypeFont::table(sal_uInt32 ord, sal_uInt32& size) const
764{
765 if (ord >= NUM_TAGS)
766 {
767 size = 0;
768 return nullptr;
769 }
770
771 auto& rTable = m_aTableList[ord];
772 size = rTable.nSize;
773 return rTable.pData;
774}
775
776} // namespace vcl
777
778#endif // INCLUDED_VCL_INC_SFT_HXX
779
780/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool hasTable(sal_uInt32 ord) const =0
sal_uInt32 m_nHorzMetrics
Definition: sft.hxx:705
sal_uInt32 vertMetricCount() const
Definition: sft.hxx:725
std::string const & fileName() const
Definition: sft.hxx:721
bool m_bMicrosoftSymbolEncoded
Definition: sft.hxx:710
sal_uInt32 horzMetricCount() const
Definition: sft.hxx:724
sal_uInt32 m_nVertMetrics
Definition: sft.hxx:706
virtual const sal_uInt8 * table(sal_uInt32 ord, sal_uInt32 &size) const =0
sal_uInt32 m_nUnitsPerEm
Definition: sft.hxx:707
sal_uInt32 glyphCount() const
Definition: sft.hxx:722
sal_uInt32 m_nGlyphs
Definition: sft.hxx:704
bool IsMicrosoftSymbolEncoded() const
Definition: sft.hxx:727
FontCharMapRef m_xCharMap
Definition: sft.hxx:709
std::string m_sFileName
Definition: sft.hxx:703
std::vector< sal_uInt32 > m_aGlyphOffsets
Definition: sft.hxx:708
sal_uInt32 unitsPerEm() const
Definition: sft.hxx:726
const sal_uInt8 * table(sal_uInt32 ord, sal_uInt32 &size) const override
Definition: sft.hxx:763
~TrueTypeFont() override
Definition: sft.cxx:1206
sal_uInt8 * ptr
Definition: sft.hxx:751
sal_Int32 fsize
Definition: sft.hxx:750
bool hasTable(sal_uInt32 ord) const override
Definition: sft.hxx:759
TrueTypeFont(const char *pFileName=nullptr, const FontCharMapRef xCharMap=nullptr)
Definition: sft.cxx:1198
sal_uInt32 ntables
Definition: sft.hxx:752
SFErrCodes open(sal_uInt32 facenum)
Definition: sft.cxx:1298
std::array< struct TTFontTable_, NUM_TAGS > m_aTableList
Definition: sft.hxx:747
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
uint32_t sal_GlyphId
Definition: glyphid.hxx:24
SFErrCodes CreateTTFromTTGlyphs(AbstractTrueTypeFont *ttf, std::vector< sal_uInt8 > &rOutBuffer, sal_uInt16 const *glyphArray, sal_uInt8 const *encoding, int nGlyphs)
Generates a new TrueType font and dumps it to outf file.
Definition: sft.cxx:1702
void GetTTGlobalFontInfo(AbstractTrueTypeFont *ttf, TTGlobalFontInfo *info)
Returns global font information about the TrueType font.
Definition: sft.cxx:2198
SFErrCodes OpenTTFontBuffer(const void *pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTypeFont **ttf, const FontCharMapRef xCharMap)
TrueTypeFont constructor.
Definition: sft.cxx:1150
int CountTTCFonts(const char *fname)
Get the number of fonts contained in a TrueType collection.
Definition: sft.cxx:1074
int GetTTGlyphPoints(AbstractTrueTypeFont *ttf, sal_uInt32 glyphID, std::vector< ControlPoint > &pointArray)
Extracts TrueType control points, and stores them in an allocated array pointed to by *pointArray.
Definition: sft.cxx:1438
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:2180
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:1443
void CloseTTFont(TrueTypeFont *ttf)
TrueTypeFont destructor.
Definition: sft.cxx:1214
std::unique_ptr< 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:2274
SFErrCodes CreateT42FromTTGlyphs(TrueTypeFont *ttf, SvStream *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:2048
void GetTTNameRecords(AbstractTrueTypeFont const *ttf, std::vector< NameRecord > &nr)
Extracts all Name Records from the font and stores them in an allocated array of NameRecord structs.
Definition: sft.cxx:2364
SFErrCodes OpenTTFontFile(const char *fname, sal_uInt32 facenum, TrueTypeFont **ttf, const FontCharMapRef xCharMap)
TrueTypeFont constructor.
Definition: sft.cxx:1090
SFErrCodes CreateT3FromTTGlyphs(TrueTypeFont *ttf, SvStream *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:1520
size
constexpr int HHEA_ascender_offset
Definition: sft.hxx:313
constexpr int OS2_ulCodePageRange1_offset
Definition: sft.hxx:281
constexpr int HEAD_glyphDataFormat_offset
Definition: sft.hxx:379
constexpr int OS2_ulUnicodeRange4_offset
Definition: sft.hxx:274
constexpr int OS2_fsType_offset
Definition: sft.hxx:268
constexpr sal_uInt32 T_ttcf
Definition: sft.hxx:432
constexpr int O_vmtx
Definition: sft.hxx:692
constexpr int O_prep
Definition: sft.hxx:696
constexpr int O_fpgm
Definition: sft.hxx:697
constexpr int HHEA_lineGap_offset
Definition: sft.hxx:315
constexpr int OS2_typoDescender_offset
Definition: sft.hxx:277
constexpr int HEAD_lowestRecPPEM_offset
Definition: sft.hxx:376
constexpr int OS2_Legacy_length
Definition: sft.hxx:262
constexpr int OS2_usWeightClass_offset
Definition: sft.hxx:266
constexpr int HEAD_fontRevision_offset
Definition: sft.hxx:366
constexpr sal_uInt32 T_post
Definition: sft.hxx:447
constexpr sal_uInt32 T_cvt
Definition: sft.hxx:448
constexpr sal_uInt32 T_vhea
Definition: sft.hxx:444
constexpr sal_uInt32 T_loca
Definition: sft.hxx:439
constexpr int HEAD_majorVersion_offset
Definition: sft.hxx:365
constexpr int HHEA_Length
Definition: sft.hxx:311
constexpr int OS2_winAscent_offset
Definition: sft.hxx:279
constexpr int HEAD_yMax_offset
Definition: sft.hxx:374
constexpr int HHEA_caretSlopeRise_offset
Definition: sft.hxx:316
constexpr sal_uInt32 T_otto
Definition: sft.hxx:433
constexpr int GLYF_xMax_offset
Definition: sft.hxx:428
SFErrCodes
Return value of OpenTTFont() and CreateT3FromTTGlyphs()
Definition: sft.hxx:65
@ 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:276
constexpr int MAXP_maxCompositePoints_offset
Definition: sft.hxx:404
constexpr int GLYF_Length
Definition: sft.hxx:423
struct TTGlobalFontInfo_ TTGlobalFontInfo
Return value of GetTTGlobalFontInfo()
Definition: salgdi.hxx:61
constexpr int OS2_typoLineGap_offset
Definition: sft.hxx:278
constexpr sal_uInt32 T_true
Definition: sft.hxx:431
constexpr sal_uInt32 T_prep
Definition: sft.hxx:449
constexpr sal_uInt32 T_glyf
Definition: sft.hxx:437
constexpr int O_OS2
Definition: sft.hxx:693
constexpr int O_vhea
Definition: sft.hxx:691
constexpr int OS2_ulUnicodeRange3_offset
Definition: sft.hxx:273
constexpr int MAXP_Version1Length
Definition: sft.hxx:399
constexpr int GLYF_numberOfContours_offset
Definition: sft.hxx:425
bool CreateTTFfontSubset(vcl::AbstractTrueTypeFont &rTTF, std::vector< sal_uInt8 > &rOutBuffer, const sal_GlyphId *pGlyphIds, const sal_uInt8 *pEncoding, const int nOrigGlyphCount)
Definition: sft.cxx:1812
constexpr int O_hhea
Definition: sft.hxx:688
constexpr int OS2_ulCodePageRange2_offset
Definition: sft.hxx:282
constexpr sal_uInt32 T_hhea
Definition: sft.hxx:441
constexpr int MAXP_maxCompositeContours_offset
Definition: sft.hxx:405
constexpr int OS2_panoseNbBytes_offset
Definition: sft.hxx:270
constexpr int NUM_TAGS
Definition: sft.hxx:699
constexpr int MAXP_maxPoints_offset
Definition: sft.hxx:402
constexpr int OS2_fsSelection_offset
Definition: sft.hxx:275
constexpr int OS2_ulUnicodeRange2_offset
Definition: sft.hxx:272
constexpr int HEAD_created_offset
Definition: sft.hxx:370
constexpr int GLYF_yMax_offset
Definition: sft.hxx:429
constexpr int HHEA_caretSlopeRun_offset
Definition: sft.hxx:317
constexpr int O_cmap
Definition: sft.hxx:690
constexpr int HEAD_flags_offset
Definition: sft.hxx:368
constexpr int HEAD_unitsPerEm_offset
Definition: sft.hxx:369
constexpr int O_post
Definition: sft.hxx:694
WidthClass
Value of the width member of the TTGlobalFontInfo struct.
Definition: sft.hxx:92
@ FWIDTH_CONDENSED
75% of normal
Definition: sft.hxx:95
@ FWIDTH_ULTRA_CONDENSED
50% of normal
Definition: sft.hxx:93
@ FWIDTH_SEMI_EXPANDED
112.5% of normal
Definition: sft.hxx:98
@ FWIDTH_EXTRA_EXPANDED
150% of normal
Definition: sft.hxx:100
@ FWIDTH_EXPANDED
125% of normal
Definition: sft.hxx:99
@ FWIDTH_EXTRA_CONDENSED
62.5% of normal
Definition: sft.hxx:94
@ FWIDTH_ULTRA_EXPANDED
200% of normal
Definition: sft.hxx:101
@ FWIDTH_NORMAL
Medium, 100%
Definition: sft.hxx:97
@ FWIDTH_SEMI_CONDENSED
87.5% of normal
Definition: sft.hxx:96
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:2442
constexpr int O_loca
Definition: sft.hxx:686
constexpr int HEAD_xMax_offset
Definition: sft.hxx:373
constexpr sal_uInt32 T_head
Definition: sft.hxx:438
constexpr int HEAD_yMin_offset
Definition: sft.hxx:372
constexpr int MAXP_maxContours_offset
Definition: sft.hxx:403
constexpr int HEAD_fontDirectionHint_offset
Definition: sft.hxx:377
constexpr int HEAD_xMin_offset
Definition: sft.hxx:371
bool CreateCFFfontSubset(const unsigned char *pFontBytes, int nByteLength, std::vector< sal_uInt8 > &rOutBuffer, const OUString &rPSName, const sal_GlyphId *pGlyphIds, const sal_uInt8 *pEncoding, int nGlyphCount, FontSubsetInfo &rInfo)
Definition: sft.cxx:1870
constexpr int MAXP_numGlyphs_offset
Definition: sft.hxx:401
constexpr int O_CFF
Definition: sft.hxx:698
constexpr int POST_isFixedPitch_offset
Definition: sft.hxx:334
constexpr int POST_underlinePosition_offset
Definition: sft.hxx:332
constexpr int GLYF_yMin_offset
Definition: sft.hxx:427
constexpr int HEAD_magicNumber_offset
Definition: sft.hxx:367
constexpr int OS2_V1_length
Definition: sft.hxx:264
constexpr int POST_italicAngle_offset
Definition: sft.hxx:331
constexpr sal_uInt32 T_maxp
Definition: sft.hxx:436
void FillFontSubsetInfo(AbstractTrueTypeFont *ttf, FontSubsetInfo &rInfo)
Definition: sft.cxx:2249
constexpr sal_uInt32 T_OS2
Definition: sft.hxx:446
constexpr sal_uInt32 T_CFF
Definition: sft.hxx:451
constexpr int GLYF_xMin_offset
Definition: sft.hxx:426
constexpr int HEAD_indexToLocFormat_offset
Definition: sft.hxx:378
constexpr sal_uInt32 T_hmtx
Definition: sft.hxx:442
constexpr sal_uInt32 T_name
Definition: sft.hxx:440
constexpr int O_maxp
Definition: sft.hxx:683
constexpr int HEAD_macStyle_offset
Definition: sft.hxx:375
constexpr sal_uInt32 T_fpgm
Definition: sft.hxx:450
constexpr int O_cvt
Definition: sft.hxx:695
constexpr int POST_underlineThickness_offset
Definition: sft.hxx:333
constexpr int HHEA_descender_offset
Definition: sft.hxx:314
constexpr int OS2_ulUnicodeRange1_offset
Definition: sft.hxx:271
constexpr int HEAD_Length
Definition: sft.hxx:363
constexpr int O_name
Definition: sft.hxx:687
constexpr int O_glyf
Definition: sft.hxx:684
constexpr int OS2_panose_offset
Definition: sft.hxx:269
constexpr int O_head
Definition: sft.hxx:685
constexpr sal_uInt32 T_cmap
Definition: sft.hxx:443
constexpr sal_uInt32 T_vmtx
Definition: sft.hxx:445
constexpr int OS2_winDescent_offset
Definition: sft.hxx:280
WeightClass
Value of the weight member of the TTGlobalFontInfo struct.
Definition: sft.hxx:78
@ FW_THIN
Thin
Definition: sft.hxx:79
@ FW_LIGHT
Light
Definition: sft.hxx:81
@ FW_SEMIBOLD
Semi-bold (Demi-bold)
Definition: sft.hxx:84
@ FW_NORMAL
Normal (Regular)
Definition: sft.hxx:82
@ FW_EXTRALIGHT
Extra-light (Ultra-light)
Definition: sft.hxx:80
@ FW_BLACK
Black (Heavy)
Definition: sft.hxx:87
@ FW_EXTRABOLD
Extra-bold (Ultra-bold)
Definition: sft.hxx:86
@ FW_BOLD
Bold
Definition: sft.hxx:85
@ FW_MEDIUM
Medium
Definition: sft.hxx:83
constexpr int OS2_usWidthClass_offset
Definition: sft.hxx:267
CompositeFlags
Composite glyph flags definition.
Definition: sft.hxx:105
@ WE_HAVE_A_TWO_BY_TWO
Definition: sft.hxx:112
@ ARG_1_AND_2_ARE_WORDS
Definition: sft.hxx:106
@ ROUND_XY_TO_GRID
Definition: sft.hxx:108
@ WE_HAVE_A_SCALE
Definition: sft.hxx:109
@ WE_HAVE_INSTRUCTIONS
Definition: sft.hxx:113
@ MORE_COMPONENTS
Definition: sft.hxx:110
@ WE_HAVE_AN_X_AND_Y_SCALE
Definition: sft.hxx:111
@ OVERLAP_COMPOUND
Definition: sft.hxx:115
@ USE_MY_METRICS
Definition: sft.hxx:114
@ ARGS_ARE_XY_VALUES
Definition: sft.hxx:107
constexpr int O_hmtx
Definition: sft.hxx:689
sal_Int32 F16Dot16
fixed: 16.16
Definition: sft.hxx:61
constexpr int OS2_V0_length
Definition: sft.hxx:263
@ Memory
ControlPoint structure used by GetTTGlyphPoints()
Definition: sft.hxx:181
sal_Int16 y
Y coordinate in EmSquare units
Definition: sft.hxx:187
sal_Int16 x
X coordinate in EmSquare units
Definition: sft.hxx:186
sal_uInt32 flags
00000000 00000000 e0000000 bbbbbbbb
Definition: sft.hxx:182
Structure used by the TrueType Creator and GetRawGlyphData()
Definition: sft.hxx:126
sal_uInt32 glyphID
glyph ID
Definition: sft.hxx:127
bool compflag
false- if non-composite
Definition: sft.hxx:132
sal_uInt16 ncontours
number of contours
Definition: sft.hxx:134
sal_uInt16 npoints
number of points
Definition: sft.hxx:133
sal_uInt16 aw
advance width
Definition: sft.hxx:130
sal_uInt32 newID
used internally by the TTCR
Definition: sft.hxx:136
sal_uInt16 nbytes
number of bytes in glyph data
Definition: sft.hxx:128
sal_Int16 lsb
left sidebearing
Definition: sft.hxx:131
std::unique_ptr< sal_uInt8[]> ptr
pointer to glyph data
Definition: sft.hxx:129
Structure used by the TrueType Creator and CreateTTFromTTGlyphs()
Definition: sft.hxx:140
sal_uInt16 encodingID
Platform-specific encoding ID
Definition: sft.hxx:142
LanguageType languageID
Language ID
Definition: sft.hxx:143
sal_uInt16 platformID
Platform ID
Definition: sft.hxx:141
std::vector< sal_uInt8 > sptr
string data (not zero-terminated!)
Definition: sft.hxx:145
sal_uInt16 nameID
Name ID
Definition: sft.hxx:144
Return value of GetTTGlobalFontInfo()
Definition: sft.hxx:150
int italicAngle
in counter-clockwise degrees * 65536
Definition: sft.hxx:160
OString family
family name
Definition: sft.hxx:151
int ascender
typographic ascent.
Definition: sft.hxx:165
int typoDescender
OS/2 portable typographic descender
Definition: sft.hxx:170
int yMin
global bounding box: yMin
Definition: sft.hxx:162
int winAscent
ascender metric for Windows
Definition: sft.hxx:172
int xMin
global bounding box: xMin
Definition: sft.hxx:161
int typoAscender
OS/2 portable typographic ascender
Definition: sft.hxx:169
sal_uInt8 panose[10]
PANOSE classification number
Definition: sft.hxx:175
int width
value of WidthClass or 0 if can't be determined
Definition: sft.hxx:158
int typoLineGap
OS/2 portable typographic line gap
Definition: sft.hxx:171
int weight
value of WeightClass or 0 if can't be determined
Definition: sft.hxx:157
int xMax
global bounding box: xMax
Definition: sft.hxx:163
sal_uInt32 typeFlags
type flags (copyright bits)
Definition: sft.hxx:176
OUString usubfamily
subfamily name UCS2
Definition: sft.hxx:154
int winDescent
descender metric for Windows
Definition: sft.hxx:173
OString psname
PostScript name
Definition: sft.hxx:155
int linegap
typographic line gap. Negative values are treated as zero in Win 3.1, System 6 and System 7.
Definition: sft.hxx:167
int descender
typographic descent.
Definition: sft.hxx:166
OUString ufamily
family name UCS2
Definition: sft.hxx:152
bool microsoftSymbolEncoded
true: MS symbol encoded
Definition: sft.hxx:174
int pitch
0: proportional font, otherwise: monospaced
Definition: sft.hxx:159
sal_uInt16 fsSelection
OS/2 fsSelection.
Definition: sft.hxx:177
sal_uInt16 macStyle
macstyle bits from 'HEAD' table
Definition: sft.hxx:156
OString subfamily
subfamily name
Definition: sft.hxx:153
int yMax
global bounding box: yMax
Definition: sft.hxx:164
Structure used by GetTTSimpleCharMetrics() functions.
Definition: sft.hxx:119
sal_Int16 sb
left or top sidebearing
Definition: sft.hxx:121
sal_uInt16 adv
advance width or height
Definition: sft.hxx:120
const sal_uInt8 * pData
Definition: sft.hxx:743
unsigned char sal_uInt8