PageRenderTime 51ms CodeModel.GetById 23ms RepoModel.GetById 1ms app.codeStats 0ms

/OOO330_m20/vcl/inc/sft.hxx

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