Visualization Library 2.0.0-b5

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
cffcmap.c
Go to the documentation of this file.
1 /***************************************************************************/
2 /* */
3 /* cffcmap.c */
4 /* */
5 /* CFF character mapping table (cmap) support (body). */
6 /* */
7 /* Copyright 2002-2007, 2010, 2013 by */
8 /* David Turner, Robert Wilhelm, and Werner Lemberg. */
9 /* */
10 /* This file is part of the FreeType project, and may only be used, */
11 /* modified, and distributed under the terms of the FreeType project */
12 /* license, LICENSE.TXT. By continuing to use, modify, or distribute */
13 /* this file you indicate that you have read the license and */
14 /* understand and accept it fully. */
15 /* */
16 /***************************************************************************/
17 
18 
19 #include <ft2build.h>
20 #include FT_INTERNAL_DEBUG_H
21 #include "cffcmap.h"
22 #include "cffload.h"
23 
24 #include "cfferrs.h"
25 
26 
27  /*************************************************************************/
28  /*************************************************************************/
29  /***** *****/
30  /***** CFF STANDARD (AND EXPERT) ENCODING CMAPS *****/
31  /***** *****/
32  /*************************************************************************/
33  /*************************************************************************/
34 
37  {
38  TT_Face face = (TT_Face)FT_CMAP_FACE( cmap );
39  CFF_Font cff = (CFF_Font)face->extra.data;
40  CFF_Encoding encoding = &cff->encoding;
41 
42 
43  cmap->gids = encoding->codes;
44 
45  return 0;
46  }
47 
48 
49  FT_CALLBACK_DEF( void )
51  {
52  cmap->gids = NULL;
53  }
54 
55 
58  FT_UInt32 char_code )
59  {
60  FT_UInt result = 0;
61 
62 
63  if ( char_code < 256 )
64  result = cmap->gids[char_code];
65 
66  return result;
67  }
68 
69 
72  FT_UInt32 *pchar_code )
73  {
74  FT_UInt result = 0;
75  FT_UInt32 char_code = *pchar_code;
76 
77 
78  *pchar_code = 0;
79 
80  if ( char_code < 255 )
81  {
82  FT_UInt code = (FT_UInt)(char_code + 1);
83 
84 
85  for (;;)
86  {
87  if ( code >= 256 )
88  break;
89 
90  result = cmap->gids[code];
91  if ( result != 0 )
92  {
93  *pchar_code = code;
94  break;
95  }
96 
97  code++;
98  }
99  }
100  return result;
101  }
102 
103 
104  FT_DEFINE_CMAP_CLASS(cff_cmap_encoding_class_rec,
105  sizeof ( CFF_CMapStdRec ),
106 
111 
112  NULL, NULL, NULL, NULL, NULL
113  )
114 
115 
116  /*************************************************************************/
117  /*************************************************************************/
118  /***** *****/
119  /***** CFF SYNTHETIC UNICODE ENCODING CMAP *****/
120  /***** *****/
121  /*************************************************************************/
122  /*************************************************************************/
123 
124  FT_CALLBACK_DEF( const char* )
125  cff_sid_to_glyph_name( TT_Face face,
126  FT_UInt idx )
127  {
128  CFF_Font cff = (CFF_Font)face->extra.data;
131 
132 
133  return cff_index_get_sid_string( cff, sid );
134  }
135 
136 
139  {
140  TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes );
141  FT_Memory memory = FT_FACE_MEMORY( face );
142  CFF_Font cff = (CFF_Font)face->extra.data;
143  CFF_Charset charset = &cff->charset;
144  FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames;
145 
146 
147  /* can't build Unicode map for CID-keyed font */
148  /* because we don't know glyph names. */
149  if ( !charset->sids )
150  return FT_THROW( No_Unicode_Glyph_Name );
151 
152  return psnames->unicodes_init( memory,
153  unicodes,
154  cff->num_glyphs,
155  (PS_GetGlyphNameFunc)&cff_sid_to_glyph_name,
157  (FT_Pointer)face );
158  }
159 
160 
161  FT_CALLBACK_DEF( void )
163  {
164  FT_Face face = FT_CMAP_FACE( unicodes );
165  FT_Memory memory = FT_FACE_MEMORY( face );
166 
167 
168  FT_FREE( unicodes->maps );
169  unicodes->num_maps = 0;
170  }
171 
172 
175  FT_UInt32 char_code )
176  {
177  TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes );
178  CFF_Font cff = (CFF_Font)face->extra.data;
179  FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames;
180 
181 
182  return psnames->unicodes_char_index( unicodes, char_code );
183  }
184 
185 
188  FT_UInt32 *pchar_code )
189  {
190  TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes );
191  CFF_Font cff = (CFF_Font)face->extra.data;
192  FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames;
193 
194 
195  return psnames->unicodes_char_next( unicodes, pchar_code );
196  }
197 
198 
199  FT_DEFINE_CMAP_CLASS(cff_cmap_unicode_class_rec,
200  sizeof ( PS_UnicodesRec ),
201 
206 
207  NULL, NULL, NULL, NULL, NULL
208  )
209 
210 /* END */
int FT_Error
Definition: fttypes.h:296
CFF_Charset charset
Definition: cffcmap.c:129
#define FT_CMAP_FACE(x)
Definition: ftobjs.h:145
FT_UInt(* FT_CMap_CharIndexFunc)(FT_CMap cmap, FT_UInt32 char_code)
Definition: ftobjs.h:157
cff_cmap_encoding_done(CFF_CMapStd cmap)
Definition: cffcmap.c:50
#define NULL
Definition: ftobjs.h:61
cff_cmap_unicode_done(PS_Unicodes unicodes)
Definition: cffcmap.c:162
cff_cmap_unicode_char_next(PS_Unicodes unicodes, FT_UInt32 *pchar_code)
Definition: cffcmap.c:187
return FT_THROW(Missing_Property)
void(* FT_CMap_DoneFunc)(FT_CMap cmap)
Definition: ftobjs.h:154
FT_UInt sid
Definition: cffcmap.c:130
struct CFF_FontRec_ * CFF_Font
cff_cmap_unicode_init(PS_Unicodes unicodes)
Definition: cffcmap.c:138
unsigned int FT_UInt32
Definition: ftconfig.h:133
CFF_EncodingRec encoding
Definition: cfftypes.h:236
typedefFT_BEGIN_HEADER struct CFF_CMapStdRec_ * CFF_CMapStd
Definition: cffcmap.h:36
cff_cmap_unicode_char_index(PS_Unicodes unicodes, FT_UInt32 char_code)
Definition: cffcmap.c:174
FT_UShort codes[256]
Definition: cfftypes.h:85
return cff_index_get_sid_string(cff, sid)
FT_Service_PsCMaps psnames
Definition: cfftypes.h:264
GLenum GLuint GLint GLenum face
cff_cmap_encoding_init(CFF_CMapStd cmap)
Definition: cffcmap.c:36
CFF_Font cff
Definition: cffdrivr.c:454
#define FT_FREE(ptr)
Definition: ftmemory.h:286
struct TT_FaceRec_ * TT_Face
Definition: tttypes.h:951
FT_UInt idx
Definition: cffcmap.c:127
const char *(* PS_GetGlyphNameFunc)(FT_Pointer data, FT_UInt string_index)
Definition: svpscmap.h:78
void * FT_Pointer
Definition: fttypes.h:307
void(* PS_FreeGlyphNameFunc)(FT_Pointer data, const char *name)
Definition: svpscmap.h:86
#define FT_CALLBACK_DEF(x)
Definition: ftconfig.h:323
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
Definition: inftree9.h:24
void * data
Definition: fttypes.h:457
FT_Generic extra
Definition: tttypes.h:1382
#define FT_FACE_MEMORY(x)
Definition: ftobjs.h:563
FT_DEFINE_CMAP_CLASS(cff_cmap_encoding_class_rec, sizeof(CFF_CMapStdRec),(FT_CMap_InitFunc) cff_cmap_encoding_init,(FT_CMap_DoneFunc) cff_cmap_encoding_done,(FT_CMap_CharIndexFunc) cff_cmap_encoding_char_index,(FT_CMap_CharNextFunc) cff_cmap_encoding_char_next, NULL, NULL, NULL, NULL, NULL) cff_sid_to_glyph_name(TT_Face face
GLuint64EXT * result
unsigned int FT_UInt
Definition: fttypes.h:227
cff_cmap_encoding_char_next(CFF_CMapStd cmap, FT_UInt32 *pchar_code)
Definition: cffcmap.c:71
FT_UInt(* FT_CMap_CharNextFunc)(FT_CMap cmap, FT_UInt32 *achar_code)
Definition: ftobjs.h:161
FT_UInt num_glyphs
Definition: cfftypes.h:224
local int * code
Definition: enough.c:174
FT_UShort * sids
Definition: cfftypes.h:96
FT_Error(* FT_CMap_InitFunc)(FT_CMap cmap, FT_Pointer init_data)
Definition: ftobjs.h:150
CFF_CharsetRec charset
Definition: cfftypes.h:237
cff_cmap_encoding_char_index(CFF_CMapStd cmap, FT_UInt32 char_code)
Definition: cffcmap.c:57