ReactOS 0.4.16-dev-979-g79f281e
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 (C) 2002-2019 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
38 {
40 CFF_Font cff = (CFF_Font)face->extra.data;
42
44
45
46 cmap->gids = encoding->codes;
47
48 return 0;
49 }
50
51
52 FT_CALLBACK_DEF( void )
54 {
55 cmap->gids = NULL;
56 }
57
58
61 FT_UInt32 char_code )
62 {
63 FT_UInt result = 0;
64
65
66 if ( char_code < 256 )
67 result = cmap->gids[char_code];
68
69 return result;
70 }
71
72
73 FT_CALLBACK_DEF( FT_UInt32 )
75 FT_UInt32 *pchar_code )
76 {
77 FT_UInt result = 0;
78 FT_UInt32 char_code = *pchar_code;
79
80
81 *pchar_code = 0;
82
83 if ( char_code < 255 )
84 {
85 FT_UInt code = (FT_UInt)(char_code + 1);
86
87
88 for (;;)
89 {
90 if ( code >= 256 )
91 break;
92
93 result = cmap->gids[code];
94 if ( result != 0 )
95 {
96 *pchar_code = code;
97 break;
98 }
99
100 code++;
101 }
102 }
103 return result;
104 }
105
106
108 cff_cmap_encoding_class_rec,
109
110 sizeof ( CFF_CMapStdRec ),
111
116
117 (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
118 (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
119 (FT_CMap_VariantListFunc) NULL, /* variant_list */
120 (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
121 (FT_CMap_VariantCharListFunc) NULL /* variantchar_list */
122 )
123
124
125 /*************************************************************************/
126 /*************************************************************************/
127 /***** *****/
128 /***** CFF SYNTHETIC UNICODE ENCODING CMAP *****/
129 /***** *****/
130 /*************************************************************************/
131 /*************************************************************************/
132
133 FT_CALLBACK_DEF( const char* )
134 cff_sid_to_glyph_name( TT_Face face,
136 {
137 CFF_Font cff = (CFF_Font)face->extra.data;
140
141
143 }
144
145
149 {
150 TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes );
152 CFF_Font cff = (CFF_Font)face->extra.data;
154 FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames;
155
157
158
159 /* can't build Unicode map for CID-keyed font */
160 /* because we don't know glyph names. */
161 if ( !charset->sids )
162 return FT_THROW( No_Unicode_Glyph_Name );
163
164 if ( !psnames->unicodes_init )
165 return FT_THROW( Unimplemented_Feature );
166
167 return psnames->unicodes_init( memory,
168 unicodes,
170 (PS_GetGlyphNameFunc)&cff_sid_to_glyph_name,
172 (FT_Pointer)face );
173 }
174
175
176 FT_CALLBACK_DEF( void )
178 {
179 FT_Face face = FT_CMAP_FACE( unicodes );
181
182
183 FT_FREE( unicodes->maps );
184 unicodes->num_maps = 0;
185 }
186
187
190 FT_UInt32 char_code )
191 {
192 TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes );
193 CFF_Font cff = (CFF_Font)face->extra.data;
194 FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames;
195
196
197 return psnames->unicodes_char_index( unicodes, char_code );
198 }
199
200
201 FT_CALLBACK_DEF( FT_UInt32 )
203 FT_UInt32 *pchar_code )
204 {
205 TT_Face face = (TT_Face)FT_CMAP_FACE( unicodes );
206 CFF_Font cff = (CFF_Font)face->extra.data;
207 FT_Service_PsCMaps psnames = (FT_Service_PsCMaps)cff->psnames;
208
209
210 return psnames->unicodes_char_next( unicodes, pchar_code );
211 }
212
213
215 cff_cmap_unicode_class_rec,
216
217 sizeof ( PS_UnicodesRec ),
218
223
224 (FT_CMap_CharVarIndexFunc) NULL, /* char_var_index */
225 (FT_CMap_CharVarIsDefaultFunc)NULL, /* char_var_default */
226 (FT_CMap_VariantListFunc) NULL, /* variant_list */
227 (FT_CMap_CharVariantListFunc) NULL, /* charvariant_list */
228 (FT_CMap_VariantCharListFunc) NULL /* variantchar_list */
229 )
230
231
232/* END */
cff_cmap_encoding_init(CFF_CMapStd cmap, FT_Pointer pointer)
Definition: cffcmap.c:36
cff_cmap_encoding_char_index(CFF_CMapStd cmap, FT_UInt32 char_code)
Definition: cffcmap.c:60
cff_cmap_unicode_char_index(PS_Unicodes unicodes, FT_UInt32 char_code)
Definition: cffcmap.c:189
cff_cmap_encoding_done(CFF_CMapStd cmap)
Definition: cffcmap.c:53
FT_UInt sid
Definition: cffcmap.c:139
cff_cmap_unicode_done(PS_Unicodes unicodes)
Definition: cffcmap.c:177
return cff_index_get_sid_string(cff, sid)
cff_cmap_encoding_char_next(CFF_CMapStd cmap, FT_UInt32 *pchar_code)
Definition: cffcmap.c:74
cff_cmap_unicode_char_next(PS_Unicodes unicodes, FT_UInt32 *pchar_code)
Definition: cffcmap.c:202
cff_cmap_unicode_init(PS_Unicodes unicodes, FT_Pointer pointer)
Definition: cffcmap.c:147
FT_UInt idx
Definition: cffcmap.c:136
CFF_Charset charset
Definition: cffcmap.c:138
typedefFT_BEGIN_HEADER struct CFF_CMapStdRec_ * CFF_CMapStd
Definition: cffcmap.h:36
CFF_Font cff
Definition: cffdrivr.c:702
struct CFF_FontRec_ * CFF_Font
Definition: cfftypes.h:157
#define NULL
Definition: types.h:112
#define FT_CALLBACK_DEF(x)
Definition: ftconfig.h:544
#define FT_UNUSED(arg)
Definition: ftconfig.h:100
#define FT_THROW(e)
Definition: ftdebug.h:241
#define FT_FREE(ptr)
Definition: ftmemory.h:328
FT_UInt(* FT_CMap_CharNextFunc)(FT_CMap cmap, FT_UInt32 *achar_code)
Definition: ftobjs.h:179
FT_UInt(* FT_CMap_CharVarIndexFunc)(FT_CMap cmap, FT_CMap unicode_cmap, FT_UInt32 char_code, FT_UInt32 variant_selector)
Definition: ftobjs.h:183
FT_UInt32 *(* FT_CMap_CharVariantListFunc)(FT_CMap cmap, FT_Memory mem, FT_UInt32 char_code)
Definition: ftobjs.h:198
FT_Int(* FT_CMap_CharVarIsDefaultFunc)(FT_CMap cmap, FT_UInt32 char_code, FT_UInt32 variant_selector)
Definition: ftobjs.h:189
#define FT_FACE_MEMORY(x)
Definition: ftobjs.h:605
#define FT_DEFINE_CMAP_CLASS( class_, size_, init_, done_, char_index_, char_next_, char_var_index_, char_var_default_, variant_list_, charvariant_list_, variantchar_list_)
Definition: ftobjs.h:232
FT_UInt32 *(* FT_CMap_VariantCharListFunc)(FT_CMap cmap, FT_Memory mem, FT_UInt32 variant_selector)
Definition: ftobjs.h:203
FT_UInt32 *(* FT_CMap_VariantListFunc)(FT_CMap cmap, FT_Memory mem)
Definition: ftobjs.h:194
FT_Error(* FT_CMap_InitFunc)(FT_CMap cmap, FT_Pointer init_data)
Definition: ftobjs.h:168
void(* FT_CMap_DoneFunc)(FT_CMap cmap)
Definition: ftobjs.h:172
FT_UInt(* FT_CMap_CharIndexFunc)(FT_CMap cmap, FT_UInt32 char_code)
Definition: ftobjs.h:175
#define FT_CMAP_FACE(x)
Definition: ftobjs.h:163
typedefFT_BEGIN_HEADER struct FT_MemoryRec_ * FT_Memory
Definition: ftsystem.h:65
int FT_Error
Definition: fttypes.h:299
unsigned int FT_UInt
Definition: fttypes.h:231
GLsizei const GLvoid * pointer
Definition: glext.h:5848
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
GLuint64EXT * result
Definition: glext.h:11304
static char memory[1024 *256]
Definition: process.c:116
FT_UShort * sids
Definition: cfftypes.h:103
FT_Service_PsCMaps psnames
Definition: cfftypes.h:388
CFF_CharsetRec charset
Definition: cfftypes.h:360
CFF_EncodingRec encoding
Definition: cfftypes.h:359
FT_UInt num_glyphs
Definition: cfftypes.h:345
Definition: inflate.c:139
const char *(* PS_GetGlyphNameFunc)(FT_Pointer data, FT_UInt string_index)
Definition: svpscmap.h:77
void(* PS_FreeGlyphNameFunc)(FT_Pointer data, const char *name)
Definition: svpscmap.h:85
struct TT_FaceRec_ * TT_Face
Definition: tttypes.h:1064
static char * encoding
Definition: xmllint.c:155