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