ReactOS 0.4.15-dev-8145-ga541a46
cffdecode.c File Reference
#include <ft2build.h>
#include "cffdecode.h"
#include "psobjs.h"
#include "psauxerr.h"
Include dependency graph for cffdecode.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define FT_COMPONENT   trace_cffdecode
 

Functions

static FT_Int cff_compute_bias (FT_Int in_charstring_type, FT_UInt num_subrs)
 
 cff_lookup_glyph_by_stdcharcode (CFF_Font cff, FT_Int charcode)
 
 cff_decoder_init (CFF_Decoder *decoder, TT_Face face, CFF_Size size, CFF_GlyphSlot slot, FT_Bool hinting, FT_Render_Mode hint_mode, CFF_Decoder_Get_Glyph_Callback get_callback, CFF_Decoder_Free_Glyph_Callback free_callback)
 
 cff_decoder_prepare (CFF_Decoder *decoder, CFF_Size size, FT_UInt glyph_index)
 

Macro Definition Documentation

◆ FT_COMPONENT

#define FT_COMPONENT   trace_cffdecode

Definition at line 38 of file cffdecode.c.

Function Documentation

◆ cff_compute_bias()

static FT_Int cff_compute_bias ( FT_Int  in_charstring_type,
FT_UInt  num_subrs 
)
static

Definition at line 399 of file cffdecode.c.

401 {
403
404
405 if ( in_charstring_type == 1 )
406 result = 0;
407 else if ( num_subrs < 1240 )
408 result = 107;
409 else if ( num_subrs < 33900U )
410 result = 1131;
411 else
412 result = 32768U;
413
414 return result;
415 }
signed int FT_Int
Definition: fttypes.h:220
GLuint64EXT * result
Definition: glext.h:11304

Referenced by cff_decoder_init(), and cff_decoder_prepare().

◆ cff_decoder_init()

cff_decoder_init ( CFF_Decoder decoder,
TT_Face  face,
CFF_Size  size,
CFF_GlyphSlot  slot,
FT_Bool  hinting,
FT_Render_Mode  hint_mode,
CFF_Decoder_Get_Glyph_Callback  get_callback,
CFF_Decoder_Free_Glyph_Callback  free_callback 
)

Definition at line 2277 of file cffdecode.c.

2285 {
2286 CFF_Font cff = (CFF_Font)face->extra.data;
2287
2288
2289 /* clear everything */
2290 FT_ZERO( decoder );
2291
2292 /* initialize builder */
2293 cff_builder_init( &decoder->builder, face, size, slot, hinting );
2294
2295 /* initialize Type2 decoder */
2296 decoder->cff = cff;
2297 decoder->num_globals = cff->global_subrs_index.count;
2298 decoder->globals = cff->global_subrs;
2299 decoder->globals_bias = cff_compute_bias(
2301 decoder->num_globals );
2302
2303 decoder->hint_mode = hint_mode;
2304
2306 decoder->free_glyph_callback = free_callback;
2307 }
static HRESULT get_callback(IBindCtx *pbc, IBindStatusCallback **callback)
Definition: binding.c:1411
static FT_Int cff_compute_bias(FT_Int in_charstring_type, FT_UInt num_subrs)
Definition: cffdecode.c:399
CFF_Font cff
Definition: cffdrivr.c:695
struct CFF_FontRec_ * CFF_Font
Definition: cfftypes.h:152
#define FT_ZERO(p)
Definition: ftmemory.h:237
GLsizeiptr size
Definition: glext.h:5919
GLenum GLuint GLint GLenum face
Definition: glext.h:7025
cff_builder_init(CFF_Builder *builder, TT_Face face, CFF_Size size, CFF_GlyphSlot glyph, FT_Bool hinting)
Definition: psobjs.c:1793
CFF_Builder builder
Definition: psaux.h:1104
CFF_Decoder_Get_Glyph_Callback get_glyph_callback
Definition: psaux.h:1143
FT_UInt num_globals
Definition: psaux.h:1126
CFF_Font cff
Definition: psaux.h:1105
FT_Render_Mode hint_mode
Definition: psaux.h:1137
FT_Int globals_bias
Definition: psaux.h:1129
FT_Byte ** globals
Definition: psaux.h:1132
CFF_Decoder_Free_Glyph_Callback free_glyph_callback
Definition: psaux.h:1144
FT_Int charstring_type
Definition: cfftypes.h:193
FT_Byte ** global_subrs
Definition: cfftypes.h:365
CFF_SubFontRec top_font
Definition: cfftypes.h:373
CFF_IndexRec global_subrs_index
Definition: cfftypes.h:352
CFF_FontRecDictRec font_dict
Definition: cfftypes.h:300
Definition: vfat.h:185

◆ cff_decoder_prepare()

cff_decoder_prepare ( CFF_Decoder decoder,
CFF_Size  size,
FT_UInt  glyph_index 
)

Definition at line 2313 of file cffdecode.c.

2316 {
2317 CFF_Builder *builder = &decoder->builder;
2318 CFF_Font cff = (CFF_Font)builder->face->extra.data;
2319 CFF_SubFont sub = &cff->top_font;
2321
2322 FT_Service_CFFLoad cffload = (FT_Service_CFFLoad)cff->cffload;
2323
2324
2325 /* manage CID fonts */
2326 if ( cff->num_subfonts )
2327 {
2328 FT_Byte fd_index = cffload->fd_select_get( &cff->fd_select,
2329 glyph_index );
2330
2331
2332 if ( fd_index >= cff->num_subfonts )
2333 {
2334 FT_TRACE4(( "cff_decoder_prepare: invalid CID subfont index\n" ));
2335 error = FT_THROW( Invalid_File_Format );
2336 goto Exit;
2337 }
2338
2339 FT_TRACE3(( " in subfont %d:\n", fd_index ));
2340
2341 sub = cff->subfonts[fd_index];
2342
2343 if ( builder->hints_funcs && size )
2344 {
2345 FT_Size ftsize = FT_SIZE( size );
2347
2348
2349 /* for CFFs without subfonts, this value has already been set */
2350 builder->hints_globals = (void *)internal->subfonts[fd_index];
2351 }
2352 }
2353
2354 decoder->num_locals = sub->local_subrs_index.count;
2355 decoder->locals = sub->local_subrs;
2356 decoder->locals_bias = cff_compute_bias(
2358 decoder->num_locals );
2359
2360 decoder->glyph_width = sub->private_dict.default_width;
2361 decoder->nominal_width = sub->private_dict.nominal_width;
2362
2363 decoder->current_subfont = sub;
2364
2365 Exit:
2366 return error;
2367 }
ios_base &_STLP_CALL internal(ios_base &__s)
Definition: _ios_base.h:311
struct CFF_InternalRec_ * CFF_Internal
return FT_Err_Ok
Definition: ftbbox.c:511
#define FT_TRACE3(varformat)
Definition: ftdebug.h:160
#define FT_THROW(e)
Definition: ftdebug.h:213
#define FT_TRACE4(varformat)
Definition: ftdebug.h:161
#define FT_SIZE(x)
Definition: ftobjs.h:631
unsigned char FT_Byte
Definition: fttypes.h:154
int FT_Error
Definition: fttypes.h:300
#define error(str)
Definition: mkdosfs.c:1605
static void Exit(void)
Definition: sock.c:1330
TT_Face face
Definition: psaux.h:1046
void * hints_globals
Definition: psaux.h:1067
void * hints_funcs
Definition: psaux.h:1066
FT_Pos glyph_width
Definition: psaux.h:1117
FT_Int locals_bias
Definition: psaux.h:1128
FT_Pos nominal_width
Definition: psaux.h:1118
FT_Byte ** locals
Definition: psaux.h:1131
CFF_SubFont current_subfont
Definition: psaux.h:1141
FT_UInt num_locals
Definition: psaux.h:1125
FT_UInt num_subfonts
Definition: cfftypes.h:374
CFF_SubFont subfonts[CFF_MAX_CID_FONTS]
Definition: cfftypes.h:375
CFF_FDSelectRec fd_select
Definition: cfftypes.h:377
const void * cffload
Definition: cfftypes.h:386
void * data
Definition: fttypes.h:461
FT_Size_Internal internal
Definition: freetype.h:1678
void * module_data
Definition: ftobjs.h:497
FT_Generic extra
Definition: tttypes.h:1498

◆ cff_lookup_glyph_by_stdcharcode()

cff_lookup_glyph_by_stdcharcode ( CFF_Font  cff,
FT_Int  charcode 
)

Definition at line 419 of file cffdecode.c.

421 {
422 FT_UInt n;
423 FT_UShort glyph_sid;
424
425 FT_Service_CFFLoad cffload;
426
427
428 /* CID-keyed fonts don't have glyph names */
429 if ( !cff->charset.sids )
430 return -1;
431
432 /* check range of standard char code */
433 if ( charcode < 0 || charcode > 255 )
434 return -1;
435
436#if 0
437 /* retrieve cffload from list of current modules */
438 FT_Service_CFFLoad cffload;
439
440
441 FT_FACE_FIND_GLOBAL_SERVICE( face, cffload, CFF_LOAD );
442 if ( !cffload )
443 {
444 FT_ERROR(( "cff_lookup_glyph_by_stdcharcode:"
445 " the `cffload' module is not available\n" ));
446 return FT_THROW( Unimplemented_Feature );
447 }
448#endif
449
450 cffload = (FT_Service_CFFLoad)cff->cffload;
451
452 /* Get code to SID mapping from `cff_standard_encoding'. */
453 glyph_sid = cffload->get_standard_encoding( (FT_UInt)charcode );
454
455 for ( n = 0; n < cff->num_glyphs; n++ )
456 {
457 if ( cff->charset.sids[n] == glyph_sid )
458 return (FT_Int)n;
459 }
460
461 return -1;
462 }
#define FT_ERROR(varformat)
Definition: ftdebug.h:181
#define FT_FACE_FIND_GLOBAL_SERVICE(face, ptr, id)
Definition: ftserv.h:125
unsigned short FT_UShort
Definition: fttypes.h:209
unsigned int FT_UInt
Definition: fttypes.h:231
GLdouble n
Definition: glext.h:7729
FT_UShort * sids
Definition: cfftypes.h:98
CFF_CharsetRec charset
Definition: cfftypes.h:355
FT_UInt num_glyphs
Definition: cfftypes.h:340

Referenced by cf2_getSeacComponent().