summaryrefslogtreecommitdiff
path: root/TTF.h
blob: 2513cc10f6b7ec6fcab32f5cb40dd076f4fa3765 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// TTF.h
//////////////////////////////////////////////////////////////////////////////////////////////////////
// Macros for TrueType portability
#define FS_2BYTE(p)  ( ((unsigned short)((p)[0]) << 8) |  (p)[1])
#define FS_4BYTE(p)  ( FS_2BYTE((p)+2) | ( (FS_2BYTE(p)+0L) << 16) )
#define SWAPW(a)        ((short) FS_2BYTE( (unsigned char *)(&a) ))
#define SWAPL(a)        ((long) FS_4BYTE( (unsigned char *)(&a) ))


typedef short int16;
typedef unsigned short uint16;
typedef long int32;
typedef unsigned long uint32;
typedef long sfnt_TableTag;

typedef struct {
    uint16 platformID;
    uint16 specificID;
    uint16 languageID;
    uint16 nameID;
    uint16 length;
    uint16 offset;
} sfnt_NameRecord;

typedef struct {
    uint16 format;
    uint16 count;
    uint16 stringOffset;
} sfnt_NamingTable;

typedef struct {
    sfnt_TableTag   tag;
    uint32          checkSum;
    uint32          offset;
    uint32          length;
} sfnt_DirectoryEntry;

typedef struct {
    int32 version;                  /* 0x10000 (1.0) */
    uint16 numOffsets;              /* number of tables */
    uint16 searchRange;             /* (max2 <= numOffsets)*16 */
    uint16 entrySelector;           /* log2 (max2 <= numOffsets) */
    uint16 rangeShift;              /* numOffsets*16-searchRange*/
    sfnt_DirectoryEntry table[1];   /* table[numOffsets] */
} sfnt_OffsetTable;

#define OFFSETTABLESIZE     12  /* not including any entries */
#define tag_NamingTable         0x656d616e        /* 'name' */

namespace TTF
{
	enum 
		{	AppleUnicode	= 0,
			Macintosh		= 1,
			ISO				= 2,
			Microsoft		= 3 };

	enum
		{	Copyright		= 0,
			Family			= 1,
			Subfamily		= 2,
			ID					= 3,
			Name				= 4,
			Version			= 5,
			PostscriptName	= 6,
			Trademark		= 7 };
};