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