1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 * @brief Sun Font Tools
26 * Generated fonts contain an XUID entry in the form of:
30 * 103 - Sun's Adobe assigned XUID number. Contact person: Alexander Gelfenbain <gelf@eng.sun.com>
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
40 #ifndef INCLUDED_VCL_INC_SFT_HXX
41 #define INCLUDED_VCL_INC_SFT_HXX
43 #include <config_options.h>
44 #include <rtl/ustring.hxx>
45 #include <vcl/dllapi.h>
46 #include <vcl/fontcapabilities.hxx>
47 #include <vcl/fontcharmap.hxx>
48 #include <i18nlangtag/lang.h>
50 #include "fontsubset.hxx"
51 #include "glyphid.hxx"
63 typedef sal_Int32 F16Dot16
; /**< fixed: 16.16 */
66 /** Return value of OpenTTFont() */
67 enum class SFErrCodes
{
69 BadFile
, /**< file not found */
70 FileIo
, /**< file I/O error */
71 Memory
, /**< memory allocation error */
72 GlyphNum
, /**< incorrect number of glyphs */
73 BadArg
, /**< incorrect arguments */
74 TtFormat
, /**< incorrect TrueType font format */
75 FontNo
/**< incorrect logical font number of a TTC font */
78 #ifndef FW_THIN /* WIN32 compilation would conflict */
79 /** Value of the weight member of the TTGlobalFontInfo struct */
81 FW_THIN
= 100, /**< Thin */
82 FW_EXTRALIGHT
= 200, /**< Extra-light (Ultra-light) */
83 FW_LIGHT
= 300, /**< Light */
84 FW_NORMAL
= 400, /**< Normal (Regular) */
85 FW_MEDIUM
= 500, /**< Medium */
86 FW_SEMIBOLD
= 600, /**< Semi-bold (Demi-bold) */
87 FW_BOLD
= 700, /**< Bold */
88 FW_EXTRABOLD
= 800, /**< Extra-bold (Ultra-bold) */
89 FW_BLACK
= 900 /**< Black (Heavy) */
93 /** Value of the width member of the TTGlobalFontInfo struct */
95 FWIDTH_ULTRA_CONDENSED
= 1, /**< 50% of normal */
96 FWIDTH_EXTRA_CONDENSED
= 2, /**< 62.5% of normal */
97 FWIDTH_CONDENSED
= 3, /**< 75% of normal */
98 FWIDTH_SEMI_CONDENSED
= 4, /**< 87.5% of normal */
99 FWIDTH_NORMAL
= 5, /**< Medium, 100% */
100 FWIDTH_SEMI_EXPANDED
= 6, /**< 112.5% of normal */
101 FWIDTH_EXPANDED
= 7, /**< 125% of normal */
102 FWIDTH_EXTRA_EXPANDED
= 8, /**< 150% of normal */
103 FWIDTH_ULTRA_EXPANDED
= 9 /**< 200% of normal */
106 /** Composite glyph flags definition */
107 enum CompositeFlags
{
108 ARG_1_AND_2_ARE_WORDS
= 1,
109 ARGS_ARE_XY_VALUES
= 1<<1,
110 ROUND_XY_TO_GRID
= 1<<2,
111 WE_HAVE_A_SCALE
= 1<<3,
112 MORE_COMPONENTS
= 1<<5,
113 WE_HAVE_AN_X_AND_Y_SCALE
= 1<<6,
114 WE_HAVE_A_TWO_BY_TWO
= 1<<7,
115 WE_HAVE_INSTRUCTIONS
= 1<<8,
116 USE_MY_METRICS
= 1<<9,
117 OVERLAP_COMPOUND
= 1<<10
120 /** Structure used by GetTTSimpleCharMetrics() functions */
122 sal_uInt16 adv
; /**< advance width or height */
123 sal_Int16 sb
; /**< left or top sidebearing */
124 } TTSimpleGlyphMetrics
;
126 /** Structure used by the TrueType Creator and GetRawGlyphData() */
129 sal_uInt32 glyphID
; /**< glyph ID */
130 sal_uInt16 nbytes
; /**< number of bytes in glyph data */
131 std::unique_ptr
<sal_uInt8
[]> ptr
; /**< pointer to glyph data */
132 sal_uInt16 aw
; /**< advance width */
133 sal_Int16 lsb
; /**< left sidebearing */
134 bool compflag
; /**< false- if non-composite */
135 sal_uInt16 npoints
; /**< number of points */
136 sal_uInt16 ncontours
; /**< number of contours */
138 sal_uInt32 newID
; /**< used internally by the TTCR */
141 /** Structure used by the TrueType Creator and CreateTTFromTTGlyphs() */
143 sal_uInt16 platformID
; /**< Platform ID */
144 sal_uInt16 encodingID
; /**< Platform-specific encoding ID */
145 LanguageType languageID
; /**< Language ID */
146 sal_uInt16 nameID
; /**< Name ID */
147 std::vector
<sal_uInt8
> sptr
; /**< string data (not zero-terminated!) */
150 /** Return value of GetTTGlobalFontInfo() */
152 typedef struct TTGlobalFontInfo_
{
153 OString family
; /**< family name */
154 OUString ufamily
; /**< family name UCS2 */
155 OString subfamily
; /**< subfamily name */
156 OUString usubfamily
; /**< subfamily name UCS2 */
157 OString psname
; /**< PostScript name */
158 sal_uInt16 macStyle
= 0; /**< macstyle bits from 'HEAD' table */
159 int weight
= 0; /**< value of WeightClass or 0 if can't be determined */
160 int width
= 0; /**< value of WidthClass or 0 if can't be determined */
161 int pitch
= 0; /**< 0: proportional font, otherwise: monospaced */
162 int italicAngle
= 0; /**< in counter-clockwise degrees * 65536 */
163 int xMin
= 0; /**< global bounding box: xMin */
164 int yMin
= 0; /**< global bounding box: yMin */
165 int xMax
= 0; /**< global bounding box: xMax */
166 int yMax
= 0; /**< global bounding box: yMax */
167 int ascender
= 0; /**< typographic ascent. */
168 int descender
= 0; /**< typographic descent. */
169 int linegap
= 0; /**< typographic line gap.\ Negative values are treated as
170 zero in Win 3.1, System 6 and System 7. */
171 int typoAscender
= 0; /**< OS/2 portable typographic ascender */
172 int typoDescender
= 0; /**< OS/2 portable typographic descender */
173 int typoLineGap
= 0; /**< OS/2 portable typographic line gap */
174 int winAscent
= 0; /**< ascender metric for Windows */
175 int winDescent
= 0; /**< descender metric for Windows */
176 bool microsoftSymbolEncoded
= false; /**< true: MS symbol encoded */
177 sal_uInt8 panose
[10] = {}; /**< PANOSE classification number */
178 sal_uInt32 typeFlags
= 0; /**< type flags (copyright bits) */
179 sal_uInt16 fsSelection
= 0; /**< OS/2 fsSelection */
182 /** ControlPoint structure used by GetTTGlyphPoints() */
184 sal_uInt32 flags
; /**< 00000000 00000000 e0000000 bbbbbbbb */
185 /**< b - byte flags from the glyf array */
186 /**< e == 0 - regular point */
187 /**< e == 1 - end contour */
188 sal_Int16 x
; /**< X coordinate in EmSquare units */
189 sal_Int16 y
; /**< Y coordinate in EmSquare units */
194 Some table OS/2 consts
196 OpenType has been created from TrueType
197 - original TrueType had an OS/2 table with a length of 68 bytes
198 (cf https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6OS2.html)
199 - There have been 6 versions (from version 0 to 5)
200 (cf https://docs.microsoft.com/en-us/typography/opentype/otspec140/os2ver0)
203 // From Initial TrueType version
206 int16 xAvgCharWidth 2
207 uint16 usWeightClass 4
208 uint16 usWidthClass 6
210 int16 ySubscriptXSize 10
211 int16 ySubscriptYSize 12
212 int16 ySubscriptXOffset 14
213 int16 ySubscriptYOffset 16
214 int16 ySuperscriptXSize 18
215 int16 ySuperscriptYSize 20
216 int16 ySuperscriptXOffset 22
217 int16 ySuperscriptYOffset 24
218 int16 yStrikeoutSize 26
219 int16 yStrikeoutPosition 28
220 int16 sFamilyClass 30
222 uint32 ulUnicodeRange1 42
223 uint32 ulUnicodeRange2 46
224 uint32 ulUnicodeRange3 50
225 uint32 ulUnicodeRange4 54
227 uint16 fsSelection 62
228 uint16 usFirstCharIndex 64
229 uint16 usLastCharIndex 66
231 // From Version 0 of OpenType
232 int16 sTypoAscender 68
233 int16 sTypoDescender 70
234 int16 sTypoLineGap 72
235 uint16 usWinAscent 74
236 uint16 usWinDescent 76
238 => length for OpenType version 0 = 78 bytes
240 // From Version 1 of OpenType
241 uint32 ulCodePageRange1 78
242 uint32 ulCodePageRange2 82
244 => length for OpenType version 1 = 86 bytes
246 // From Version 2 of OpenType
247 // (idem for Versions 3 and 4)
250 uint16 usDefaultChar 90
251 uint16 usBreakChar 92
252 uint16 usMaxContext 94
254 => length for OpenType version 2, 3 and 4 = 96 bytes
256 // From Version 5 of OpenType
257 uint16 usLowerOpticalPointSize 96
258 uint16 usUpperOpticalPointSize 98
261 => length for OS/2 table version 5 = 100 bytes
264 constexpr int OS2_Legacy_length
= 68;
265 constexpr int OS2_V0_length
= 78;
266 constexpr int OS2_V1_length
= 86;
268 constexpr int OS2_usWeightClass_offset
= 4;
269 constexpr int OS2_usWidthClass_offset
= 6;
270 constexpr int OS2_fsType_offset
= 8;
271 constexpr int OS2_panose_offset
= 32;
272 constexpr int OS2_panoseNbBytes_offset
= 10;
273 constexpr int OS2_ulUnicodeRange1_offset
= 42;
274 constexpr int OS2_ulUnicodeRange2_offset
= 46;
275 constexpr int OS2_ulUnicodeRange3_offset
= 50;
276 constexpr int OS2_ulUnicodeRange4_offset
= 54;
277 constexpr int OS2_fsSelection_offset
= 62;
278 constexpr int OS2_typoAscender_offset
= 68;
279 constexpr int OS2_typoDescender_offset
= 70;
280 constexpr int OS2_typoLineGap_offset
= 72;
281 constexpr int OS2_winAscent_offset
= 74;
282 constexpr int OS2_winDescent_offset
= 76;
283 constexpr int OS2_ulCodePageRange1_offset
= 78;
284 constexpr int OS2_ulCodePageRange2_offset
= 82;
287 Some table hhea consts
288 cf https://docs.microsoft.com/fr-fr/typography/opentype/spec/hhea
290 uint16 majorVersion 0
291 uint16 minorVersion 2
295 UFWORD advanceWidthMax 10
296 FWORD minLeftSideBearing 12
297 FWORD minRightSideBearing 14
299 int16 caretSlopeRise 18
300 int16 caretSlopeRun 20
306 int16 metricDataFormat 32
307 uint16 numberOfHMetrics 34
310 => length for hhea table = 36 bytes
313 constexpr int HHEA_Length
= 36;
315 constexpr int HHEA_ascender_offset
= 4;
316 constexpr int HHEA_descender_offset
= 6;
317 constexpr int HHEA_lineGap_offset
= 8;
318 constexpr int HHEA_caretSlopeRise_offset
= 18;
319 constexpr int HHEA_caretSlopeRun_offset
= 20;
322 Some table post consts
323 cf https://docs.microsoft.com/fr-fr/typography/opentype/spec/post
327 FWord underlinePosition 8
328 FWord underlineThickness 10
329 uint32 isFixedPitch 12
333 constexpr int POST_italicAngle_offset
= 4;
334 constexpr int POST_underlinePosition_offset
= 8;
335 constexpr int POST_underlineThickness_offset
= 10;
336 constexpr int POST_isFixedPitch_offset
= 12;
339 Some table head consts
340 cf https://docs.microsoft.com/fr-fr/typography/opentype/spec/head
345 uint32 checkSumAdjustment 8
346 uint32 magicNumber 12 (= 0x5F0F3CF5)
349 LONGDATETIME created 20
350 LONGDATETIME modified 28
356 uint16 lowestRecPPEM 46
357 int16 fontDirectionHint 48
358 int16 indexToLocFormat 50
359 int16 glyphDataFormat 52
363 => length head table = 54 bytes
365 constexpr int HEAD_Length
= 54;
367 constexpr int HEAD_majorVersion_offset
= 0;
368 constexpr int HEAD_fontRevision_offset
= 4;
369 constexpr int HEAD_magicNumber_offset
= 12;
370 constexpr int HEAD_flags_offset
= 16;
371 constexpr int HEAD_unitsPerEm_offset
= 18;
372 constexpr int HEAD_created_offset
= 20;
373 constexpr int HEAD_xMin_offset
= 36;
374 constexpr int HEAD_yMin_offset
= 38;
375 constexpr int HEAD_xMax_offset
= 40;
376 constexpr int HEAD_yMax_offset
= 42;
377 constexpr int HEAD_macStyle_offset
= 44;
378 constexpr int HEAD_lowestRecPPEM_offset
= 46;
379 constexpr int HEAD_fontDirectionHint_offset
= 48;
380 constexpr int HEAD_indexToLocFormat_offset
= 50;
381 constexpr int HEAD_glyphDataFormat_offset
= 52;
384 Some table maxp consts
385 cf https://docs.microsoft.com/fr-fr/typography/opentype/spec/maxp
396 uint16 maxCompositePoints 10
397 uint16 maxCompositeContours 12
401 constexpr int MAXP_Version1Length
= 32;
403 constexpr int MAXP_numGlyphs_offset
= 4;
404 constexpr int MAXP_maxPoints_offset
= 6;
405 constexpr int MAXP_maxContours_offset
= 8;
406 constexpr int MAXP_maxCompositePoints_offset
= 10;
407 constexpr int MAXP_maxCompositeContours_offset
= 12;
410 Some table glyf consts
411 cf https://docs.microsoft.com/fr-fr/typography/opentype/spec/glyf
414 int16 numberOfContours 0
422 => length glyf table = 10 bytes
425 constexpr int GLYF_Length
= 10;
427 constexpr int GLYF_numberOfContours_offset
= 0;
428 constexpr int GLYF_xMin_offset
= 2;
429 constexpr int GLYF_yMin_offset
= 4;
430 constexpr int GLYF_xMax_offset
= 6;
431 constexpr int GLYF_yMax_offset
= 8;
433 constexpr sal_uInt32 T_true
= 0x74727565; /* 'true' */
434 constexpr sal_uInt32 T_ttcf
= 0x74746366; /* 'ttcf' */
435 constexpr sal_uInt32 T_otto
= 0x4f54544f; /* 'OTTO' */
437 // standard TrueType table tags
438 constexpr sal_uInt32 T_maxp
= 0x6D617870;
439 constexpr sal_uInt32 T_glyf
= 0x676C7966;
440 constexpr sal_uInt32 T_head
= 0x68656164;
441 constexpr sal_uInt32 T_loca
= 0x6C6F6361;
442 constexpr sal_uInt32 T_name
= 0x6E616D65;
443 constexpr sal_uInt32 T_hhea
= 0x68686561;
444 constexpr sal_uInt32 T_hmtx
= 0x686D7478;
445 constexpr sal_uInt32 T_cmap
= 0x636D6170;
446 constexpr sal_uInt32 T_vhea
= 0x76686561;
447 constexpr sal_uInt32 T_vmtx
= 0x766D7478;
448 constexpr sal_uInt32 T_OS2
= 0x4F532F32;
449 constexpr sal_uInt32 T_post
= 0x706F7374;
450 constexpr sal_uInt32 T_cvt
= 0x63767420;
451 constexpr sal_uInt32 T_prep
= 0x70726570;
452 constexpr sal_uInt32 T_fpgm
= 0x6670676D;
453 constexpr sal_uInt32 T_CFF
= 0x43464620;
455 class AbstractTrueTypeFont
;
459 * @defgroup sft Sun Font Tools Exported Functions
463 * Get the number of fonts contained in a TrueType collection
464 * @param fname - file name
465 * @return number of fonts or zero, if file is not a TTC file.
468 int CountTTCFonts(const char* fname
);
471 * TrueTypeFont constructor.
472 * The font file has to be provided as a memory buffer and length
473 * @param pBuffer - memory buffer
474 * @param nLen - size of memory buffer
475 * @param facenum - logical font number within a TTC file. This value is ignored
477 * @param ttf - returns the opened TrueTypeFont
478 * @param xCharMap - optional parsed character map
479 * @return value of SFErrCodes enum
482 SFErrCodes VCL_DLLPUBLIC
OpenTTFontBuffer(const void* pBuffer
, sal_uInt32 nLen
, sal_uInt32 facenum
,
483 TrueTypeFont
** ttf
, const FontCharMapRef xCharMap
= nullptr);
486 * TrueTypeFont constructor.
487 * Reads the font file and allocates the memory for the structure.
488 * on WIN32 the font has to be provided as a memory buffer and length
489 * @param fname - name of TrueType font file
490 * @param facenum - logical font number within a TTC file. This value is ignored
492 * @param ttf - returns the opened TrueTypeFont
493 * @param xCharMap - optional parsed character map
494 * @return value of SFErrCodes enum
497 SFErrCodes VCL_DLLPUBLIC
OpenTTFontFile(const char *fname
, sal_uInt32 facenum
, TrueTypeFont
** ttf
,
498 const FontCharMapRef xCharMap
= nullptr);
501 bool VCL_DLLPUBLIC
getTTCoverage(
502 std::optional
<std::bitset
<UnicodeCoverage::MAX_UC_ENUM
>> & rUnicodeCoverage
,
503 std::optional
<std::bitset
<CodePageCoverage::MAX_CP_ENUM
>> & rCodePageCoverage
,
504 const unsigned char* pTable
, size_t nLength
);
507 * TrueTypeFont destructor. Deallocates the memory.
510 void VCL_DLLPUBLIC
CloseTTFont(TrueTypeFont
*);
513 * Extracts TrueType control points, and stores them in an allocated array pointed to
514 * by *pointArray. This function returns the number of extracted points.
516 * @param ttf pointer to the TrueTypeFont structure
517 * @param glyphID Glyph ID
518 * @param pointArray Return value - address of the pointer to the first element of the array
519 * of points allocated by the function
520 * @return Returns the number of points in *pointArray or -1 if glyphID is
525 int GetTTGlyphPoints(AbstractTrueTypeFont
*ttf
, sal_uInt32 glyphID
, std::vector
<ControlPoint
>& pointArray
);
528 * Extracts raw glyph data from the 'glyf' table and returns it in an allocated
529 * GlyphData structure.
531 * @param ttf pointer to the TrueTypeFont structure
532 * @param glyphID Glyph ID
534 * @return pointer to an allocated GlyphData structure or NULL if
535 * glyphID is not present in the font
539 std::unique_ptr
<GlyphData
> GetTTRawGlyphData(AbstractTrueTypeFont
*ttf
, sal_uInt32 glyphID
);
542 * For a specified glyph adds all component glyphs IDs to the list and
543 * return their number. If the glyph is a single glyph it has one component
544 * glyph (which is added to the list) and the function returns 1.
545 * For a composite glyphs it returns the number of component glyphs
546 * and adds all of them to the list.
548 * @param ttf pointer to the TrueTypeFont structure
549 * @param glyphID Glyph ID
550 * @param glyphlist list of glyphs
552 * @return number of component glyphs
556 int GetTTGlyphComponents(AbstractTrueTypeFont
*ttf
, sal_uInt32 glyphID
, std::vector
< sal_uInt32
>& glyphlist
);
559 * Extracts all Name Records from the font and stores them in an allocated
560 * array of NameRecord structs
562 * @param ttf pointer to the TrueTypeFont struct
563 * @param nr reference to the vector of NameRecord structs
568 void GetTTNameRecords(AbstractTrueTypeFont
const *ttf
, std::vector
<NameRecord
>& nr
);
571 * Generates a new TrueType font and dumps it to <b>outf</b> file.
572 * This function substitutes glyph 0 for all glyphIDs that are not found in the font.
573 * @param ttf pointer to the TrueTypeFont structure
574 * @param fname file name for the output TrueType font file
575 * @param glyphArray pointer to an array of glyphs that are to be extracted from ttf. The first
576 * element of this array has to be glyph 0 (default glyph)
577 * @param encoding array of encoding values. encoding[i] specifies character code for
578 * the glyphID glyphArray[i]. Character code 0 usually points to a default
580 * @param nGlyphs number of glyph IDs in glyphArray and encoding values in encoding
581 * @param flags or'ed TTCreationFlags
582 * @return return the value of SFErrCodes enum
587 VCL_DLLPUBLIC SFErrCodes
CreateTTFromTTGlyphs(AbstractTrueTypeFont
*ttf
,
588 std::vector
<sal_uInt8
>& rOutBuffer
,
589 sal_uInt16
const *glyphArray
,
590 sal_uInt8
const *encoding
,
593 VCL_DLLPUBLIC
bool CreateTTFfontSubset(AbstractTrueTypeFont
& aTTF
,
594 std::vector
<sal_uInt8
>& rOutBuffer
,
595 const sal_GlyphId
* pGlyphIds
,
596 const sal_uInt8
* pEncoding
,
597 int nGlyphCount
, FontSubsetInfo
& rInfo
);
600 * Returns global font information about the TrueType font.
601 * @see TTGlobalFontInfo
603 * @param ttf pointer to a TrueTypeFont structure
604 * @param info pointer to a TTGlobalFontInfo structure
608 void GetTTGlobalFontInfo(AbstractTrueTypeFont
*ttf
, TTGlobalFontInfo
*info
);
611 * Returns part of the head table info, normally collected by GetTTGlobalFontInfo.
613 * Just implemented separate, because this info not available via Qt API.
615 * @param ttf pointer to a AbstractTrueTypeFont structure
616 * @param xMin global glyph bounding box min X
617 * @param yMin global glyph bounding box min Y
618 * @param xMax global glyph bounding box max X
619 * @param yMax global glyph bounding box max Y
620 * @param macStyle encoded Mac style flags of the font
621 * @return true, if table data could be decoded
624 bool GetTTGlobalFontHeadInfo(const AbstractTrueTypeFont
*ttf
, int& xMin
, int& yMin
, int& xMax
, int& yMax
, sal_uInt16
& macStyle
);
626 /*- private definitions */
628 /* indexes into TrueTypeFont::tables[] and TrueTypeFont::tlens[] */
629 constexpr int O_maxp
= 0;
630 constexpr int O_glyf
= 1; /* 'glyf' */
631 constexpr int O_head
= 2; /* 'head' */
632 constexpr int O_loca
= 3; /* 'loca' */
633 constexpr int O_name
= 4; /* 'name' */
634 constexpr int O_hhea
= 5; /* 'hhea' */
635 constexpr int O_hmtx
= 6; /* 'hmtx' */
636 constexpr int O_cmap
= 7; /* 'cmap' */
637 constexpr int O_vhea
= 8; /* 'vhea' */
638 constexpr int O_vmtx
= 9; /* 'vmtx' */
639 constexpr int O_OS2
= 10; /* 'OS/2' */
640 constexpr int O_post
= 11; /* 'post' */
641 constexpr int O_cvt
= 12; /* 'cvt_' - only used in TT->TT generation */
642 constexpr int O_prep
= 13; /* 'prep' - only used in TT->TT generation */
643 constexpr int O_fpgm
= 14; /* 'fpgm' - only used in TT->TT generation */
644 constexpr int O_CFF
= 15; /* 'CFF' */
645 constexpr int NUM_TAGS
= 16;
647 class UNLESS_MERGELIBS(VCL_DLLPUBLIC
) AbstractTrueTypeFont
649 std::string m_sFileName
;
650 sal_uInt32 m_nGlyphs
;
651 sal_uInt32 m_nHorzMetrics
;
652 sal_uInt32 m_nVertMetrics
; /* if not 0 => font has vertical metrics information */
653 sal_uInt32 m_nUnitsPerEm
;
654 std::vector
<sal_uInt32
> m_aGlyphOffsets
;
655 FontCharMapRef m_xCharMap
;
656 bool m_bMicrosoftSymbolEncoded
;
659 SFErrCodes
indexGlyphData();
662 AbstractTrueTypeFont(const char* fileName
= nullptr, const FontCharMapRef xCharMap
= nullptr);
663 virtual ~AbstractTrueTypeFont();
665 SFErrCodes
initialize();
667 std::string
const & fileName() const { return m_sFileName
; }
668 sal_uInt32
glyphCount() const { return m_nGlyphs
; }
669 sal_uInt32
glyphOffset(sal_uInt32 glyphID
) const;
670 sal_uInt32
horzMetricCount() const { return m_nHorzMetrics
; }
671 sal_uInt32
vertMetricCount() const { return m_nVertMetrics
; }
672 sal_uInt32
unitsPerEm() const { return m_nUnitsPerEm
; }
673 bool IsMicrosoftSymbolEncoded() const { return m_bMicrosoftSymbolEncoded
; }
675 virtual bool hasTable(sal_uInt32 ord
) const = 0;
676 virtual const sal_uInt8
* table(sal_uInt32 ord
, sal_uInt32
& size
) const = 0;
685 class TrueTypeFont final
: public AbstractTrueTypeFont
689 const sal_uInt8
* pData
= nullptr; /* pointer to a raw subtable in the SFNT file */
690 sal_uInt32 nSize
= 0; /* table size */
693 std::array
<struct TTFontTable_
, NUM_TAGS
> m_aTableList
;
700 TrueTypeFont(const char* pFileName
= nullptr, const FontCharMapRef xCharMap
= nullptr);
701 ~TrueTypeFont() override
;
703 SFErrCodes
open(sal_uInt32 facenum
);
705 bool hasTable(sal_uInt32 ord
) const override
{ return m_aTableList
[ord
].pData
!= nullptr; }
706 inline const sal_uInt8
* table(sal_uInt32 ord
, sal_uInt32
& size
) const override
;
709 const sal_uInt8
* TrueTypeFont::table(sal_uInt32 ord
, sal_uInt32
& size
) const
717 auto& rTable
= m_aTableList
[ord
];
724 #endif // INCLUDED_VCL_INC_SFT_HXX
726 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */