zenilib  0.5.3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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, 2003, 2004, 2005, 2006, 2007, 2010 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 "cffcmap.h"
20 #include "cffload.h"
21 
22 #include "cfferrs.h"
23 
24 
25  /*************************************************************************/
26  /*************************************************************************/
27  /***** *****/
28  /***** CFF STANDARD (AND EXPERT) ENCODING CMAPS *****/
29  /***** *****/
30  /*************************************************************************/
31  /*************************************************************************/
32 
35  {
36  TT_Face face = (TT_Face)FT_CMAP_FACE( cmap );
37  CFF_Font cff = (CFF_Font)face->extra.data;
38  CFF_Encoding encoding = &cff->encoding;
39 
40 
41  cmap->gids = encoding->codes;
42 
43  return 0;
44  }
45 
46 
47  FT_CALLBACK_DEF( void )
49  {
50  cmap->gids = NULL;
51  }
52 
53 
56  FT_UInt32 char_code )
57  {
58  FT_UInt result = 0;
59 
60 
61  if ( char_code < 256 )
62  result = cmap->gids[char_code];
63 
64  return result;
65  }
66 
67 
68  FT_CALLBACK_DEF( FT_UInt32 )
70  FT_UInt32 *pchar_code )
71  {
72  FT_UInt result = 0;
73  FT_UInt32 char_code = *pchar_code;
74 
75 
76  *pchar_code = 0;
77 
78  if ( char_code < 255 )
79  {
80  FT_UInt code = (FT_UInt)(char_code + 1);
81 
82 
83  for (;;)
84  {
85  if ( code >= 256 )
86  break;
87 
88  result = cmap->gids[code];
89  if ( result != 0 )
90  {
91  *pchar_code = code;
92  break;
93  }
94 
95  code++;
96  }
97  }
98  return result;
99  }
100 
101 
102  FT_DEFINE_CMAP_CLASS(cff_cmap_encoding_class_rec,
103  sizeof ( CFF_CMapStdRec ),
104 
109 
110  NULL, NULL, NULL, NULL, NULL
111  )
112 
113 
114  /*************************************************************************/
115  /*************************************************************************/
116  /***** *****/
117  /***** CFF SYNTHETIC UNICODE ENCODING CMAP *****/
118  /***** *****/
119  /*************************************************************************/
120  /*************************************************************************/
121 
122  FT_CALLBACK_DEF( const char* )
123  cff_sid_to_glyph_name( TT_Face face,
124  FT_UInt idx )
125  {
126  CFF_Font cff = (CFF_Font)face->extra.data;
129 
130 
131  return cff_index_get_sid_string( cff, sid );
132  }
133 
134 
137  {
138  TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes );
139  FT_Memory memory = FT_FACE_MEMORY( face );
140  CFF_Font cff = (CFF_Font)face->extra.data;
141  CFF_Charset charset = &cff->charset;
142  FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames;
143 
144 
145  /* can't build Unicode map for CID-keyed font */
146  /* because we don't know glyph names. */
147  if ( !charset->sids )
148  return CFF_Err_No_Unicode_Glyph_Name;
149 
150  return psnames->unicodes_init( memory,
151  unicodes,
152  cff->num_glyphs,
153  (PS_GetGlyphNameFunc)&cff_sid_to_glyph_name,
155  (FT_Pointer)face );
156  }
157 
158 
159  FT_CALLBACK_DEF( void )
161  {
162  FT_Face face = FT_CMAP_FACE( unicodes );
163  FT_Memory memory = FT_FACE_MEMORY( face );
164 
165 
166  FT_FREE( unicodes->maps );
167  unicodes->num_maps = 0;
168  }
169 
170 
173  FT_UInt32 char_code )
174  {
175  TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes );
176  CFF_Font cff = (CFF_Font)face->extra.data;
177  FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames;
178 
179 
180  return psnames->unicodes_char_index( unicodes, char_code );
181  }
182 
183 
184  FT_CALLBACK_DEF( FT_UInt32 )
186  FT_UInt32 *pchar_code )
187  {
188  TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes );
189  CFF_Font cff = (CFF_Font)face->extra.data;
190  FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames;
191 
192 
193  return psnames->unicodes_char_next( unicodes, pchar_code );
194  }
195 
196 
197  FT_DEFINE_CMAP_CLASS(cff_cmap_unicode_class_rec,
198  sizeof ( PS_UnicodesRec ),
199 
204 
205  NULL, NULL, NULL, NULL, NULL
206  )
207 
208 /* END */
int FT_Error
Definition: fttypes.h:296
CFF_Charset charset
Definition: cffcmap.c:127
#define FT_CMAP_FACE(x)
Definition: ftobjs.h:145
cff_cmap_encoding_done(CFF_CMapStd cmap)
Definition: cffcmap.c:48
#define NULL
Definition: ftobjs.h:61
FT_UInt(* FT_CMap_CharIndexFunc)(FT_CMap cmap, FT_UInt32 char_code)
Definition: ftobjs.h:157
cff_cmap_unicode_done(PS_Unicodes unicodes)
Definition: cffcmap.c:160
cff_cmap_unicode_char_next(PS_Unicodes unicodes, FT_UInt32 *pchar_code)
Definition: cffcmap.c:185
FT_UInt sid
Definition: cffcmap.c:128
struct CFF_FontRec_ * CFF_Font
cff_cmap_unicode_init(PS_Unicodes unicodes)
Definition: cffcmap.c:136
FT_UInt(* FT_CMap_CharNextFunc)(FT_CMap cmap, FT_UInt32 *achar_code)
Definition: ftobjs.h:161
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:172
FT_UShort codes[256]
Definition: cfftypes.h:85
return cff_index_get_sid_string(cff, sid)
FT_Service_PsCMaps psnames
Definition: cfftypes.h:264
cff_cmap_encoding_init(CFF_CMapStd cmap)
Definition: cffcmap.c:34
void(* FT_CMap_DoneFunc)(FT_CMap cmap)
Definition: ftobjs.h:154
CFF_Font cff
Definition: cffdrivr.c:448
const char *(* PS_GetGlyphNameFunc)(FT_Pointer data, FT_UInt string_index)
Definition: svpscmap.h:78
#define FT_FREE(ptr)
Definition: ftmemory.h:286
GLuint64EXT * result
Definition: glew.h:12708
struct TT_FaceRec_ * TT_Face
Definition: tttypes.h:951
FT_UInt idx
Definition: cffcmap.c:125
Colormap cmap
void * FT_Pointer
Definition: fttypes.h:307
GLenum face
Definition: gl2ext.h:1490
#define FT_CALLBACK_DEF(x)
Definition: ftconfig.h:554
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:66
void(* PS_FreeGlyphNameFunc)(FT_Pointer data, const char *name)
Definition: svpscmap.h:86
Definition: inftrees.h:24
void * data
Definition: fttypes.h:457
FT_Generic extra
Definition: tttypes.h:1382
#define FT_FACE_MEMORY(x)
Definition: ftobjs.h:529
#define const
Definition: zconf.h:91
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
unsigned int FT_UInt
Definition: fttypes.h:227
cff_cmap_encoding_char_next(CFF_CMapStd cmap, FT_UInt32 *pchar_code)
Definition: cffcmap.c:69
FT_Error(* FT_CMap_InitFunc)(FT_CMap cmap, FT_Pointer init_data)
Definition: ftobjs.h:150
FT_UInt num_glyphs
Definition: cfftypes.h:224
FT_UShort * sids
Definition: cfftypes.h:96
CFF_CharsetRec charset
Definition: cfftypes.h:237
cff_cmap_encoding_char_index(CFF_CMapStd cmap, FT_UInt32 char_code)
Definition: cffcmap.c:55