PageRenderTime 57ms CodeModel.GetById 26ms RepoModel.GetById 0ms app.codeStats 0ms

/vcl/inc/sft.hxx

https://bitbucket.org/markjenkins/libreoffice_ubuntu-debian-fixes
C++ Header | 614 lines | 243 code | 75 blank | 296 comment | 0 complexity | 847824892aee7dc9f7496db0f957a602 MD5 | raw file
Possible License(s): GPL-3.0, LGPL-3.0, MPL-2.0-no-copyleft-exception, LGPL-2.1, BSD-3-Clause-No-Nuclear-License-2014
  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. /**
  20. * @file sft.h
  21. * @brief Sun Font Tools
  22. * @author Alexander Gelfenbain
  23. */
  24. /*
  25. * If NO_MAPPERS is defined, MapChar() and MapString() and consequently GetTTSimpleCharMetrics()
  26. * don't get compiled in. This is done to avoid including a large chunk of code (TranslateXY() from
  27. * xlat.c in the projects that don't require it.
  28. *
  29. * If NO_TYPE3 is defined CreateT3FromTTGlyphs() does not get compiled in.
  30. * If NO_TYPE42 is defined Type42-related code is excluded
  31. * If NO_TTCR is defined TrueType creation related code is excluded\
  32. */
  33. /*
  34. * Generated fonts contain an XUID entry in the form of:
  35. *
  36. * 103 0 T C1 N C2 C3
  37. *
  38. * 103 - Sun's Adobe assigned XUID number. Contact person: Alexander Gelfenbain <gelf@eng.sun.com>
  39. *
  40. * T - font type. 0: Type 3, 1: Type 42
  41. * C1 - CRC-32 of the entire source TrueType font
  42. * N - number of glyphs in the subset
  43. * C2 - CRC-32 of the array of glyph IDs used to generate the subset
  44. * C3 - CRC-32 of the array of encoding numbers used to generate the subset
  45. *
  46. */
  47. #ifndef __SUBFONT_H
  48. #define __SUBFONT_H
  49. #ifdef UNX
  50. #include <sys/types.h>
  51. #include <unistd.h>
  52. #endif
  53. #include <stdio.h>
  54. #include <sal/types.h>
  55. #include "vcl/dllapi.h"
  56. #include <vector>
  57. #include "vcl/fontcapabilities.hxx"
  58. namespace vcl
  59. {
  60. /*@{*/
  61. typedef sal_Int16 F2Dot14; /**< fixed: 2.14 */
  62. typedef sal_Int32 F16Dot16; /**< fixed: 16.16 */
  63. /*@}*/
  64. typedef struct {
  65. sal_uInt16 s;
  66. sal_uInt16 d;
  67. } sal_uInt16pair;
  68. /** Return value of OpenTTFont() and CreateT3FromTTGlyphs() */
  69. enum SFErrCodes {
  70. SF_OK, /**< no error */
  71. SF_BADFILE, /**< file not found */
  72. SF_FILEIO, /**< file I/O error */
  73. SF_MEMORY, /**< memory allocation error */
  74. SF_GLYPHNUM, /**< incorrect number of glyphs */
  75. SF_BADARG, /**< incorrect arguments */
  76. SF_TTFORMAT, /**< incorrect TrueType font format */
  77. SF_TABLEFORMAT, /**< incorrect format of a TrueType table */
  78. SF_FONTNO /**< incorrect logical font number of a TTC font */
  79. };
  80. #ifndef FW_THIN /* WIN32 compilation would conflict */
  81. /** Value of the weight member of the TTGlobalFontInfo struct */
  82. enum WeightClass {
  83. FW_THIN = 100, /**< Thin */
  84. FW_EXTRALIGHT = 200, /**< Extra-light (Ultra-light) */
  85. FW_LIGHT = 300, /**< Light */
  86. FW_NORMAL = 400, /**< Normal (Regular) */
  87. FW_MEDIUM = 500, /**< Medium */
  88. FW_SEMIBOLD = 600, /**< Semi-bold (Demi-bold) */
  89. FW_BOLD = 700, /**< Bold */
  90. FW_EXTRABOLD = 800, /**< Extra-bold (Ultra-bold) */
  91. FW_BLACK = 900 /**< Black (Heavy) */
  92. };
  93. /** Value of the width member of the TTGlobalFontInfo struct */
  94. enum WidthClass {
  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 */
  104. };
  105. #endif /* FW_THIN */
  106. /** Type of the 'kern' table, stored in _TrueTypeFont::kerntype */
  107. enum KernType {
  108. KT_NONE = 0, /**< no kern table */
  109. KT_APPLE_NEW = 1, /**< new Apple kern table */
  110. KT_MICROSOFT = 2 /**< Microsoft table */
  111. };
  112. /* Composite glyph flags definition */
  113. enum CompositeFlags {
  114. ARG_1_AND_2_ARE_WORDS = 1,
  115. ARGS_ARE_XY_VALUES = 1<<1,
  116. ROUND_XY_TO_GRID = 1<<2,
  117. WE_HAVE_A_SCALE = 1<<3,
  118. MORE_COMPONENTS = 1<<5,
  119. WE_HAVE_AN_X_AND_Y_SCALE = 1<<6,
  120. WE_HAVE_A_TWO_BY_TWO = 1<<7,
  121. WE_HAVE_INSTRUCTIONS = 1<<8,
  122. USE_MY_METRICS = 1<<9,
  123. OVERLAP_COMPOUND = 1<<10
  124. };
  125. #ifndef NO_TTCR
  126. /** Flags for TrueType generation */
  127. enum TTCreationFlags {
  128. TTCF_AutoName = 1, /**< Automatically generate a compact 'name' table.
  129. If this flag is not set, name table is generated
  130. either from an array of NameRecord structs passed as
  131. arguments or if the array is NULL, 'name' table
  132. of the generated TrueType file will be a copy
  133. of the name table of the original file.
  134. If this flag is set the array of NameRecord structs
  135. is ignored and a very compact 'name' table is automatically
  136. generated. */
  137. TTCF_IncludeOS2 = 2 /** If this flag is set OS/2 table from the original font will be
  138. copied to the subset */
  139. };
  140. #endif
  141. /** Structure used by GetTTSimpleGlyphMetrics() and GetTTSimpleCharMetrics() functions */
  142. typedef struct {
  143. sal_uInt16 adv; /**< advance width or height */
  144. sal_Int16 sb; /**< left or top sidebearing */
  145. } TTSimpleGlyphMetrics;
  146. /** Structure used by the TrueType Creator and GetRawGlyphData() */
  147. typedef struct {
  148. sal_uInt32 glyphID; /**< glyph ID */
  149. sal_uInt16 nbytes; /**< number of bytes in glyph data */
  150. sal_uInt8 *ptr; /**< pointer to glyph data */
  151. sal_uInt16 aw; /**< advance width */
  152. sal_Int16 lsb; /**< left sidebearing */
  153. sal_uInt16 compflag; /**< 0- if non-composite, 1- otherwise */
  154. sal_uInt16 npoints; /**< number of points */
  155. sal_uInt16 ncontours; /**< number of contours */
  156. /* */
  157. sal_uInt32 newID; /**< used internally by the TTCR */
  158. } GlyphData;
  159. /** Structure used by the TrueType Creator and CreateTTFromTTGlyphs() */
  160. typedef struct {
  161. sal_uInt16 platformID; /**< Platform ID */
  162. sal_uInt16 encodingID; /**< Platform-specific encoding ID */
  163. sal_uInt16 languageID; /**< Language ID */
  164. sal_uInt16 nameID; /**< Name ID */
  165. sal_uInt16 slen; /**< String length in bytes */
  166. sal_uInt8 *sptr; /**< Pointer to string data (not zero-terminated!) */
  167. } NameRecord;
  168. /** Return value of GetTTGlobalFontInfo() */
  169. typedef struct {
  170. char *family; /**< family name */
  171. sal_uInt16 *ufamily; /**< family name UCS2 */
  172. char *subfamily; /**< subfamily name */
  173. sal_uInt16 *usubfamily; /**< subfamily name UCS2 */
  174. char *psname; /**< PostScript name */
  175. sal_uInt16 macStyle; /**< macstyle bits from 'HEAD' table */
  176. int weight; /**< value of WeightClass or 0 if can't be determined */
  177. int width; /**< value of WidthClass or 0 if can't be determined */
  178. int pitch; /**< 0: proportianal font, otherwise: monospaced */
  179. int italicAngle; /**< in counter-clockwise degrees * 65536 */
  180. int xMin; /**< global bounding box: xMin */
  181. int yMin; /**< global bounding box: yMin */
  182. int xMax; /**< global bounding box: xMax */
  183. int yMax; /**< global bounding box: yMax */
  184. int ascender; /**< typographic ascent. */
  185. int descender; /**< typographic descent. */
  186. int linegap; /**< typographic line gap.\ Negative values are treated as
  187. zero in Win 3.1, System 6 and System 7. */
  188. int vascent; /**< typographic ascent for vertical writing mode */
  189. int vdescent; /**< typographic descent for vertical writing mode */
  190. int typoAscender; /**< OS/2 portable typographic ascender */
  191. int typoDescender; /**< OS/2 portable typographic descender */
  192. int typoLineGap; /**< OS/2 portable typographc line gap */
  193. int winAscent; /**< ascender metric for Windows */
  194. int winDescent; /**< descender metric for Windows */
  195. int symbolEncoded; /**< 1: MS symbol encoded 0: not symbol encoded */
  196. int rangeFlag; /**< if set to 1 Unicode Range flags are applicable */
  197. sal_uInt32 ur1; /**< bits 0 - 31 of Unicode Range flags */
  198. sal_uInt32 ur2; /**< bits 32 - 63 of Unicode Range flags */
  199. sal_uInt32 ur3; /**< bits 64 - 95 of Unicode Range flags */
  200. sal_uInt32 ur4; /**< bits 96 - 127 of Unicode Range flags */
  201. sal_uInt8 panose[10]; /**< PANOSE classification number */
  202. sal_uInt32 typeFlags; /**< type flags (copyright bits + PS-OpenType flag) */
  203. } TTGlobalFontInfo;
  204. #define TYPEFLAG_INVALID 0x8000000
  205. #define TYPEFLAG_COPYRIGHT_MASK 0x000000E
  206. #define TYPEFLAG_PS_OPENTYPE 0x0010000
  207. /** Structure used by KernGlyphs() */
  208. typedef struct {
  209. int x; /**< positive: right, negative: left */
  210. int y; /**< positive: up, negative: down */
  211. } KernData;
  212. /** ControlPoint structure used by GetTTGlyphPoints() */
  213. typedef struct {
  214. sal_uInt32 flags; /**< 00000000 00000000 e0000000 bbbbbbbb */
  215. /**< b - byte flags from the glyf array */
  216. /**< e == 0 - regular point */
  217. /**< e == 1 - end contour */
  218. sal_Int16 x; /**< X coordinate in EmSquare units */
  219. sal_Int16 y; /**< Y coordinate in EmSquare units */
  220. } ControlPoint;
  221. typedef struct _TrueTypeFont TrueTypeFont;
  222. /**
  223. * @defgroup sft Sun Font Tools Exported Functions
  224. */
  225. /**
  226. * Get the number of fonts contained in a TrueType collection
  227. * @param fname - file name
  228. * @return number of fonts or zero, if file is not a TTC file.
  229. * @ingroup sft
  230. */
  231. int CountTTCFonts(const char* fname);
  232. /**
  233. * TrueTypeFont constructor.
  234. * The font file has to be provided as a memory buffer and length
  235. * @param facenum - logical font number within a TTC file. This value is ignored
  236. * for TrueType fonts
  237. * @return value of SFErrCodes enum
  238. * @ingroup sft
  239. */
  240. int VCL_DLLPUBLIC OpenTTFontBuffer(void* pBuffer, sal_uInt32 nLen, sal_uInt32 facenum, TrueTypeFont** ttf); /*FOLD01*/
  241. #if !defined(WIN32)
  242. /**
  243. * TrueTypeFont constructor.
  244. * Reads the font file and allocates the memory for the structure.
  245. * on WIN32 the font has to be provided as a memory buffer and length
  246. * @param facenum - logical font number within a TTC file. This value is ignored
  247. * for TrueType fonts
  248. * @return value of SFErrCodes enum
  249. * @ingroup sft
  250. */
  251. int VCL_DLLPUBLIC OpenTTFontFile(const char *fname, sal_uInt32 facenum, TrueTypeFont** ttf);
  252. #endif
  253. void getTTScripts(std::vector< sal_uInt32 > &rScriptTags, const unsigned char* pTable, size_t nLength);
  254. bool getTTCoverage(
  255. boost::dynamic_bitset<sal_uInt32> &rUnicodeCoverage,
  256. boost::dynamic_bitset<sal_uInt32> &rCodePageCoverage,
  257. const unsigned char* pTable, size_t nLength);
  258. /**
  259. * TrueTypeFont destructor. Deallocates the memory.
  260. * @ingroup sft
  261. */
  262. void VCL_DLLPUBLIC CloseTTFont(TrueTypeFont *);
  263. /**
  264. * Extracts TrueType control points, and stores them in an allocated array pointed to
  265. * by *pointArray. This function returns the number of extracted points.
  266. *
  267. * @param ttf pointer to the TrueTypeFont structure
  268. * @param glyphID Glyph ID
  269. * @param pointArray Return value - address of the pointer to the first element of the array
  270. * of points allocated by the function
  271. * @return Returns the number of points in *pointArray or -1 if glyphID is
  272. * invalid.
  273. * @ingroup sft
  274. *
  275. */
  276. int GetTTGlyphPoints(TrueTypeFont *ttf, sal_uInt32 glyphID, ControlPoint **pointArray);
  277. /**
  278. * Extracts raw glyph data from the 'glyf' table and returns it in an allocated
  279. * GlyphData structure.
  280. *
  281. * @param ttf pointer to the TrueTypeFont structure
  282. * @param glyphID Glyph ID
  283. *
  284. * @return pointer to an allocated GlyphData structure or NULL if
  285. * glyphID is not present in the font
  286. * @ingroup sft
  287. *
  288. */
  289. GlyphData *GetTTRawGlyphData(TrueTypeFont *ttf, sal_uInt32 glyphID);
  290. /**
  291. * For a specified glyph adds all component glyphs IDs to the list and
  292. * return their number. If the glyph is a single glyph it has one component
  293. * glyph (which is added to the list) and the function returns 1.
  294. * For a composite glyphs it returns the number of component glyphs
  295. * and adds all of them to the list.
  296. *
  297. * @param ttf pointer to the TrueTypeFont structure
  298. * @param glyphID Glyph ID
  299. * @param glyphlist list of glyphs
  300. *
  301. * @return number of component glyphs
  302. * @ingroup sft
  303. *
  304. */
  305. int GetTTGlyphComponents(TrueTypeFont *ttf, sal_uInt32 glyphID, std::vector< sal_uInt32 >& glyphlist);
  306. /**
  307. * Extracts all Name Records from the font and stores them in an allocated
  308. * array of NameRecord structs
  309. *
  310. * @param ttf pointer to the TrueTypeFont struct
  311. * @param nr pointer to the array of NameRecord structs
  312. *
  313. * @return number of NameRecord structs
  314. * @ingroup sft
  315. */
  316. int GetTTNameRecords(TrueTypeFont *ttf, NameRecord **nr);
  317. /**
  318. * Deallocates previously allocated array of NameRecords.
  319. *
  320. * @param nr array of NameRecord structs
  321. * @param n number of elements in the array
  322. *
  323. * @ingroup sft
  324. */
  325. void DisposeNameRecords(NameRecord* nr, int n);
  326. #ifndef NO_TYPE3
  327. /**
  328. * Generates a new PostScript Type 3 font and dumps it to <b>outf</b> file.
  329. * This functions subsititues glyph 0 for all glyphIDs that are not found in the font.
  330. * @param ttf pointer to the TrueTypeFont structure
  331. * @param outf the resulting font is written to this stream
  332. * @param fname font name for the new font. If it is NULL the PostScript name of the
  333. * original font will be used
  334. * @param glyphArray pointer to an array of glyphs that are to be extracted from ttf
  335. * @param encoding array of encoding values. encoding[i] specifies the position of the glyph
  336. * glyphArray[i] in the encoding vector of the resulting Type3 font
  337. * @param nGlyphs number of glyph IDs in glyphArray and encoding values in encoding
  338. * @param wmode writing mode for the output file: 0 - horizontal, 1 - vertical
  339. * @return return the value of SFErrCodes enum
  340. * @see SFErrCodes
  341. * @ingroup sft
  342. *
  343. */
  344. int CreateT3FromTTGlyphs(TrueTypeFont *ttf, FILE *outf, const char *fname, sal_uInt16 *glyphArray, sal_uInt8 *encoding, int nGlyphs, int wmode);
  345. #endif
  346. #ifndef NO_TTCR
  347. /**
  348. * Generates a new TrueType font and dumps it to <b>outf</b> file.
  349. * This functions subsititues glyph 0 for all glyphIDs that are not found in the font.
  350. * @param ttf pointer to the TrueTypeFont structure
  351. * @param fname file name for the output TrueType font file
  352. * @param glyphArray pointer to an array of glyphs that are to be extracted from ttf. The first
  353. * element of this array has to be glyph 0 (default glyph)
  354. * @param encoding array of encoding values. encoding[i] specifies character code for
  355. * the glyphID glyphArray[i]. Character code 0 usually points to a default
  356. * glyph (glyphID 0)
  357. * @param nGlyphs number of glyph IDs in glyphArray and encoding values in encoding
  358. * @param nNameRecs number of NameRecords for the font, if 0 the name table from the
  359. * original font will be used
  360. * @param nr array of NameRecords
  361. * @param flags or'ed TTCreationFlags
  362. * @return return the value of SFErrCodes enum
  363. * @see SFErrCodes
  364. * @ingroup sft
  365. *
  366. */
  367. int CreateTTFromTTGlyphs(TrueTypeFont *ttf,
  368. const char *fname,
  369. sal_uInt16 *glyphArray,
  370. sal_uInt8 *encoding,
  371. int nGlyphs,
  372. int nNameRecs,
  373. NameRecord *nr,
  374. sal_uInt32 flags);
  375. #endif
  376. #ifndef NO_TYPE42
  377. /**
  378. * Generates a new PostScript Type42 font and dumps it to <b>outf</b> file.
  379. * This functions subsititues glyph 0 for all glyphIDs that are not found in the font.
  380. * @param ttf pointer to the TrueTypeFont structure
  381. * @param outf output stream for a resulting font
  382. * @param psname PostScript name of the resulting font
  383. * @param glyphArray pointer to an array of glyphs that are to be extracted from ttf. The first
  384. * element of this array has to be glyph 0 (default glyph)
  385. * @param encoding array of encoding values. encoding[i] specifies character code for
  386. * the glyphID glyphArray[i]. Character code 0 usually points to a default
  387. * glyph (glyphID 0)
  388. * @param nGlyphs number of glyph IDs in glyphArray and encoding values in encoding
  389. * @return SF_OK - no errors
  390. * SF_GLYPHNUM - too many glyphs (> 255)
  391. * SF_TTFORMAT - corrupted TrueType fonts
  392. *
  393. * @see SFErrCodes
  394. * @ingroup sft
  395. *
  396. */
  397. int CreateT42FromTTGlyphs(TrueTypeFont *ttf,
  398. FILE *outf,
  399. const char *psname,
  400. sal_uInt16 *glyphArray,
  401. sal_uInt8 *encoding,
  402. int nGlyphs);
  403. #endif
  404. /**
  405. * Queries glyph metrics. Allocates an array of TTSimpleGlyphMetrics structs and returns it.
  406. *
  407. * @param ttf pointer to the TrueTypeFont structure
  408. * @param glyphArray pointer to an array of glyphs that are to be extracted from ttf
  409. * @param nGlyphs number of glyph IDs in glyphArray and encoding values in encoding
  410. * @param mode writing mode: 0 - horizontal, 1 - vertical
  411. * @ingroup sft
  412. *
  413. */
  414. TTSimpleGlyphMetrics *GetTTSimpleGlyphMetrics(TrueTypeFont *ttf, sal_uInt16 *glyphArray, int nGlyphs, int mode);
  415. #ifndef NO_MAPPERS
  416. /**
  417. * Queries glyph metrics. Allocates an array of TTSimpleGlyphMetrics structs and returns it.
  418. * This function behaves just like GetTTSimpleGlyphMetrics() but it takes a range of Unicode
  419. * characters instead of an array of glyphs.
  420. *
  421. * @param ttf pointer to the TrueTypeFont structure
  422. * @param firstChar Unicode value of the first character in the range
  423. * @param nChars number of Unicode characters in the range
  424. * @param mode writing mode: 0 - horizontal, 1 - vertical
  425. *
  426. * @see GetTTSimpleGlyphMetrics
  427. * @ingroup sft
  428. *
  429. */
  430. TTSimpleGlyphMetrics *GetTTSimpleCharMetrics(TrueTypeFont *ttf, sal_uInt16 firstChar, int nChars, int mode);
  431. /**
  432. * Maps a Unicode (UCS-2) string to a glyph array. Returns the number of glyphs in the array,
  433. * which for TrueType fonts is always the same as the number of input characters.
  434. *
  435. * @param ttf pointer to the TrueTypeFont structure
  436. * @param str pointer to a UCS-2 string
  437. * @param nchars number of characters in <b>str</b>
  438. * @param glyphArray pointer to the glyph array where glyph IDs are to be recorded.
  439. *
  440. * @return MapString() returns -1 if the TrueType font has no usable 'cmap' tables.
  441. * Otherwise it returns the number of characters processed: <b>nChars</b>
  442. *
  443. * glyphIDs of TrueType fonts are 2 byte positive numbers. glyphID of 0 denotes a missing
  444. * glyph and traditionally defaults to an empty square.
  445. * glyphArray should be at least sizeof(sal_uInt16) * nchars bytes long. If glyphArray is NULL
  446. * MapString() replaces the UCS-2 characters in str with glyphIDs.
  447. * @ingroup sft
  448. */
  449. int VCL_DLLPUBLIC MapString(TrueTypeFont *ttf, sal_uInt16 *str, int nchars, sal_uInt16 *glyphArray, int bvertical);
  450. /**
  451. * Maps a Unicode (UCS-2) character to a glyph ID and returns it. Missing glyph has
  452. * a glyphID of 0 so this function can be used to test if a character is encoded in the font.
  453. *
  454. * @param ttf pointer to the TrueTypeFont structure
  455. * @param ch Unicode (UCS-2) character
  456. * @return glyph ID, if the character is missing in the font, the return value is 0.
  457. * @ingroup sft
  458. */
  459. sal_uInt16 MapChar(TrueTypeFont *ttf, sal_uInt16 ch, int bvertical);
  460. /**
  461. * Returns 0 when the font does not substitute vertical glyphs
  462. *
  463. * @param ttf pointer to the TrueTypeFont structure
  464. */
  465. int DoesVerticalSubstitution( TrueTypeFont *ttf, int bvertical);
  466. #endif
  467. /**
  468. * Returns global font information about the TrueType font.
  469. * @see TTGlobalFontInfo
  470. *
  471. * @param ttf pointer to a TrueTypeFont structure
  472. * @param info pointer to a TTGlobalFontInfo structure
  473. * @ingroup sft
  474. *
  475. */
  476. void GetTTGlobalFontInfo(TrueTypeFont *ttf, TTGlobalFontInfo *info);
  477. /**
  478. * Returns nonzero if font is a symbol encoded font
  479. */
  480. int CheckSymbolEncoding(TrueTypeFont* ttf);
  481. /**
  482. * returns the number of glyphs in a font
  483. */
  484. int GetTTGlyphCount( TrueTypeFont* ttf );
  485. /**
  486. * provide access to the raw data of a SFNT-container's subtable
  487. */
  488. bool GetSfntTable( TrueTypeFont* ttf, int nSubtableIndex,
  489. const sal_uInt8** ppRawBytes, int* pRawLength );
  490. /*- private definitions */ /*FOLD00*/
  491. struct _TrueTypeFont {
  492. sal_uInt32 tag;
  493. char *fname;
  494. sal_Int32 fsize;
  495. sal_uInt8 *ptr;
  496. char *psname;
  497. char *family;
  498. sal_uInt16 *ufamily;
  499. char *subfamily;
  500. sal_uInt16 *usubfamily;
  501. sal_uInt32 ntables;
  502. sal_uInt32 *goffsets;
  503. sal_uInt32 nglyphs;
  504. sal_uInt32 unitsPerEm;
  505. sal_uInt32 numberOfHMetrics;
  506. sal_uInt32 numOfLongVerMetrics; /* if this number is not 0, font has vertical metrics information */
  507. const sal_uInt8* cmap;
  508. int cmapType;
  509. sal_uInt32 (*mapper)(const sal_uInt8 *, sal_uInt32); /* character to glyphID translation function */
  510. const sal_uInt8 **tables; /* array of pointers to raw subtables in SFNT file */
  511. sal_uInt32 *tlens; /* array of table lengths */
  512. int kerntype; /* Defined in the KernType enum */
  513. sal_uInt32 nkern; /* number of kern subtables */
  514. const sal_uInt8** kerntables; /* array of pointers to kern subtables */
  515. void *pGSubstitution; /* info provided by GSUB for UseGSUB() */
  516. };
  517. /* indexes into _TrueTypeFont::tables[] and _TrueTypeFont::tlens[] */
  518. #define O_maxp 0 /* 'maxp' */
  519. #define O_glyf 1 /* 'glyf' */
  520. #define O_head 2 /* 'head' */
  521. #define O_loca 3 /* 'loca' */
  522. #define O_name 4 /* 'name' */
  523. #define O_hhea 5 /* 'hhea' */
  524. #define O_hmtx 6 /* 'hmtx' */
  525. #define O_cmap 7 /* 'cmap' */
  526. #define O_vhea 8 /* 'vhea' */
  527. #define O_vmtx 9 /* 'vmtx' */
  528. #define O_OS2 10 /* 'OS/2' */
  529. #define O_post 11 /* 'post' */
  530. #define O_kern 12 /* 'kern' */
  531. #define O_cvt 13 /* 'cvt_' - only used in TT->TT generation */
  532. #define O_prep 14 /* 'prep' - only used in TT->TT generation */
  533. #define O_fpgm 15 /* 'fpgm' - only used in TT->TT generation */
  534. #define O_gsub 16 /* 'GSUB' */
  535. #define O_CFF 17 /* 'CFF' */
  536. #define NUM_TAGS 18
  537. } // namespace vcl
  538. #endif /* __SUBFONT_H */
  539. /* vim:set shiftwidth=4 softtabstop=4 expandtab: */