summaryrefslogtreecommitdiff
path: root/Build/source/libs/freetype/freetype-1.5/lib/ttcmap.h
blob: ea16554c9d2e65fd7d495bd9ddaab9920b265984 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*******************************************************************
 *
 *  ttcmap.h
 *
 *    TrueType Character Mappings
 *
 *  Copyright 1996-2002 by
 *  David Turner, Robert Wilhelm, and Werner Lemberg.
 *
 *  This file is part of the FreeType project, and may only be used
 *  modified and distributed under the terms of the FreeType project
 *  license, LICENSE.TXT.  By continuing to use, modify, or distribute
 *  this file you indicate that you have read the license and
 *  understand and accept it fully.
 *
 *
 ******************************************************************/

#ifndef TTCMAP_H
#define TTCMAP_H

#include "ttconfig.h"
#include "tttypes.h"


#ifdef __cplusplus
  extern "C" {
#endif

  /* format 0 */

  struct  TCMap0_
  {
    PByte  glyphIdArray;
  };

  typedef struct TCMap0_  TCMap0;
  typedef TCMap0*         PCMap0;


  /* format 2 */

  struct  TCMap2SubHeader_
  {
    UShort  firstCode;      /* first valid low byte         */
    UShort  entryCount;     /* number of valid low bytes    */
    Short   idDelta;        /* delta value to glyphIndex    */
    UShort  idRangeOffset;  /* offset from here to 1st code */
  };

  typedef struct TCMap2SubHeader_  TCMap2SubHeader;
  typedef TCMap2SubHeader*         PCMap2SubHeader;

  struct  TCMap2_
  {
    PUShort subHeaderKeys;
    /* high byte mapping table     */
    /* value = subHeader index * 8 */

    PCMap2SubHeader  subHeaders;
    PUShort          glyphIdArray;
    UShort           numGlyphId;        /* control value */
  };

  typedef struct TCMap2_  TCMap2;
  typedef TCMap2*         PCMap2;


  /* format 4 */

  struct  TCMap4Segment_
  {
    UShort  endCount;
    UShort  startCount;
    Short   idDelta;        /* in the specs defined as UShort but the
                               example there gives negative values... */
    UShort  idRangeOffset;
  };

  typedef struct TCMap4Segment_  TCMap4Segment;
  typedef TCMap4Segment*         PCMap4Segment;

  struct  TCMap4_
  {
    UShort  segCountX2;     /* number of segments * 2       */
    UShort  searchRange;    /* these parameters can be used */
    UShort  entrySelector;  /* for a binary search          */
    UShort  rangeShift;

    PCMap4Segment  segments;
    PUShort        glyphIdArray;
    UShort         numGlyphId;          /* control value */
  };

  typedef struct TCMap4_  TCMap4;
  typedef TCMap4*         PCMap4;


  /* format 6 */

  struct  TCMap6_
  {
    UShort   firstCode;      /* first character code of subrange      */
    UShort   entryCount;     /* number of character codes in subrange */

    PUShort  glyphIdArray;
  };

  typedef struct TCMap6_  TCMap6;
  typedef TCMap6*         PCMap6;


  /* formats 8 & 12 */

  /* auxiliary table for format 8 and 12 */

  struct  TCMapGroup_
  {
    ULong  startCharCode;
    ULong  endCharCode;
    ULong  startGlyphID;
  };

  typedef struct TCMapGroup_  TCMapGroup;
  typedef TCMapGroup*         PCMapGroup;

  /* FreeType handles format 8 and 12 identically.  It is not necessary to
     cover mixed 16bit and 32bit codes since FreeType always uses ULong
     for input character codes -- converting Unicode surrogates to 32bit
     character codes must be done by the application.                      */

  struct  TCMap8_12_
  {
    ULong       nGroups;
    PCMapGroup  groups;

    PCMapGroup  last_group;      /* last used group; this is a small    */
                                 /* cache to potentially increase speed */
  };
    
  typedef struct TCMap8_12_  TCMap8_12;
  typedef TCMap8_12*         PCMap8_12;


  /* charmap table */

  struct  TCMapTable_
  {
    UShort  platformID;
    UShort  platformEncodingID;
    UShort  format;
    UShort  length;
    UShort  version;

    Bool    loaded;
    ULong   offset;

    union
    {
      TCMap0     cmap0;
      TCMap2     cmap2;
      TCMap4     cmap4;
      TCMap6     cmap6;
      TCMap8_12  cmap8_12;
    } c;
  };

  typedef struct TCMapTable_  TCMapTable;
  typedef TCMapTable*         PCMapTable;



  /* Load character mappings directory when face is loaded. */
  /* The mappings themselves are only loaded on demand.     */

  FT_INTERNAL_DEF( TT_Error )
  CharMap_Load( PCMapTable  table,
                TT_Stream  input );


  /* Destroy one character mapping table */

  FT_INTERNAL_DEF( TT_Error )
  CharMap_Free( PCMapTable  table );


  /* Use character mapping table to perform mapping */

  FT_INTERNAL_DEF( UShort )
  CharMap_Index( PCMapTable  cmap,
                 ULong       charCode );

  /* NOTE: The PFace type isn't defined at this point */

#ifdef __cplusplus
  }
#endif

#endif /* TTCMAP_H */


/* END */