?? ftobjs.c
字號(hào):
slot->linearHoriAdvance = FT_MulDiv( slot->linearHoriAdvance, (FT_Long)metrics->x_ppem << 16, EM ); slot->linearVertAdvance = FT_MulDiv( slot->linearVertAdvance, (FT_Long)metrics->y_ppem << 16, EM ); } if ( ( load_flags & FT_LOAD_IGNORE_TRANSFORM ) == 0 ) { FT_Face_Internal internal = face->internal; /* now, transform the glyph image if needed */ if ( internal->transform_flags ) { /* get renderer */ FT_Renderer renderer = ft_lookup_glyph_renderer( slot ); if ( renderer ) error = renderer->clazz->transform_glyph( renderer, slot, &internal->transform_matrix, &internal->transform_delta ); /* transform advance */ FT_Vector_Transform( &slot->advance, &internal->transform_matrix ); } } /* do we need to render the image now? */ if ( !error && slot->format != ft_glyph_format_bitmap && slot->format != ft_glyph_format_composite && load_flags & FT_LOAD_RENDER ) { error = FT_Render_Glyph( slot, ( load_flags & FT_LOAD_MONOCHROME ) ? ft_render_mode_mono : ft_render_mode_normal ); } Exit: return error; } /* documentation is in freetype.h */ FT_EXPORT_DEF( FT_Error ) FT_Load_Char( FT_Face face, FT_ULong char_code, FT_Int load_flags ) { FT_UInt glyph_index; if ( !face ) return FT_Err_Invalid_Face_Handle; glyph_index = (FT_UInt)char_code; if ( face->charmap ) glyph_index = FT_Get_Char_Index( face, char_code ); return FT_Load_Glyph( face, glyph_index, load_flags ); } /* destructor for sizes list */ static void destroy_size( FT_Memory memory, FT_Size size, FT_Driver driver ) { /* finalize client-specific data */ if ( size->generic.finalizer ) size->generic.finalizer( size ); /* finalize format-specific stuff */ if ( driver->clazz->done_size ) driver->clazz->done_size( size ); FT_FREE( size->internal ); FT_FREE( size ); } /* destructor for faces list */ static void destroy_face( FT_Memory memory, FT_Face face, FT_Driver driver ) { FT_Driver_Class clazz = driver->clazz; /* discard auto-hinting data */ if ( face->autohint.finalizer ) face->autohint.finalizer( face->autohint.data ); /* Discard glyph slots for this face. */ /* Beware! FT_Done_GlyphSlot() changes the field `face->glyph' */ while ( face->glyph ) FT_Done_GlyphSlot( face->glyph ); /* discard all sizes for this face */ FT_List_Finalize( &face->sizes_list, (FT_List_Destructor)destroy_size, memory, driver ); face->size = 0; /* now discard client data */ if ( face->generic.finalizer ) face->generic.finalizer( face );#ifdef FT_CONFIG_OPTION_USE_CMAPS /* discard charmaps */ { FT_Int n; for ( n = 0; n < face->num_charmaps; n++ ) { FT_CMap cmap = FT_CMAP( face->charmaps[n] ); FT_CMap_Done( cmap ); face->charmaps[n] = NULL; } FT_FREE( face->charmaps ); face->num_charmaps = 0; }#endif /* FT_CONFIG_OPTION_USE_CMAPS */ /* finalize format-specific stuff */ if ( clazz->done_face ) clazz->done_face( face ); /* close the stream for this face if needed */ ft_input_stream_free( face->stream, ( face->face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) != 0 ); face->stream = 0; /* get rid of it */ if ( face->internal ) { FT_FREE( face->internal->postscript_name ); } FT_FREE( face ); } static void Destroy_Driver( FT_Driver driver ) { FT_List_Finalize( &driver->faces_list, (FT_List_Destructor)destroy_face, driver->root.memory, driver ); /* check whether we need to drop the driver's glyph loader */ if ( FT_DRIVER_USES_OUTLINES( driver ) ) FT_GlyphLoader_Done( driver->glyph_loader ); } /*************************************************************************/ /* */ /* <Function> */ /* open_face */ /* */ /* <Description> */ /* This function does some work for FT_Open_Face(). */ /* */ static FT_Error open_face( FT_Driver driver, FT_Stream stream, FT_Long face_index, FT_Int num_params, FT_Parameter* params, FT_Face* aface ) { FT_Memory memory; FT_Driver_Class clazz; FT_Face face = 0; FT_Error error; FT_Face_Internal internal; clazz = driver->clazz; memory = driver->root.memory; /* allocate the face object and perform basic initialization */ if ( FT_ALLOC( face, clazz->face_object_size ) ) goto Fail; if ( FT_NEW( internal ) ) goto Fail; face->internal = internal; face->driver = driver; face->memory = memory; face->stream = stream; error = clazz->init_face( stream, face, face_index, num_params, params ); if ( error ) goto Fail; *aface = face; Fail: if ( error ) { clazz->done_face( face ); FT_FREE( face->internal ); FT_FREE( face ); *aface = 0; } return error; } /* there's a Mac-specific extended implementation of FT_New_Face() */ /* in src/base/ftmac.c */#ifndef FT_MACINTOSH /* documentation is in freetype.h */ FT_EXPORT_DEF( FT_Error ) FT_New_Face( FT_Library library, const char* pathname, FT_Long face_index, FT_Face *aface ) { FT_Open_Args args; /* test for valid `library' and `aface' delayed to FT_Open_Face() */ if ( !pathname ) return FT_Err_Invalid_Argument; args.flags = ft_open_pathname; args.pathname = (char*)pathname; return FT_Open_Face( library, &args, face_index, aface ); }#endif /* !FT_MACINTOSH */ /* documentation is in freetype.h */ FT_EXPORT_DEF( FT_Error ) FT_New_Memory_Face( FT_Library library, const FT_Byte* file_base, FT_Long file_size, FT_Long face_index, FT_Face *aface ) { FT_Open_Args args; /* test for valid `library' and `face' delayed to FT_Open_Face() */ if ( !file_base ) return FT_Err_Invalid_Argument; args.flags = ft_open_memory; args.memory_base = file_base; args.memory_size = file_size; return FT_Open_Face( library, &args, face_index, aface ); } /* documentation is in freetype.h */ FT_EXPORT_DEF( FT_Error ) FT_Open_Face( FT_Library library, FT_Open_Args* args, FT_Long face_index, FT_Face *aface ) { FT_Error error; FT_Driver driver; FT_Memory memory; FT_Stream stream; FT_Face face = 0; FT_ListNode node = 0; FT_Bool external_stream; /* test for valid `library' delayed to */ /* ft_input_stream_new() */ if ( !aface || !args ) return FT_Err_Invalid_Argument; *aface = 0; external_stream = FT_BOOL( ( args->flags & ft_open_stream ) && args->stream ); /* create input stream */ error = ft_input_stream_new( library, args, &stream ); if ( error ) goto Exit; memory = library->memory; /* If the font driver is specified in the `args' structure, use */ /* it. Otherwise, we scan the list of registered drivers. */ if ( ( args->flags & ft_open_driver ) && args->driver ) { driver = FT_DRIVER( args->driver ); /* not all modules are drivers, so check... */ if ( FT_MODULE_IS_DRIVER( driver ) ) { FT_Int num_params = 0; FT_Parameter* params = 0; if ( args->flags & ft_open_params ) { num_params = args->num_params; params = args->params; } error = open_face( driver, stream, face_index, num_params, params, &face ); if ( !error ) goto Success; } else error = FT_Err_Invalid_Handle; ft_input_stream_free( stream, external_stream ); goto Fail; } else { /* check each font driver for an appropriate format */ FT_Module* cur = library->modules; FT_Module* limit = cur + library->num_modules; for ( ; cur < limit; cur++ ) { /* not all modules are font drivers, so check... */ if ( FT_MODULE_IS_DRIVER( cur[0] ) ) { FT_Int num_params = 0; FT_Parameter* params = 0; driver = FT_DRIVER( cur[0] ); if ( args->flags & ft_open_params ) { num_params = args->num_params; params = args->params; } error = open_face( driver, stream, face_index, num_params, params, &face ); if ( !error ) goto Success; if ( FT_ERROR_BASE( error ) != FT_Err_Unknown_File_Format ) goto Fail2; } } /* no driver is able to handle this format */ error = FT_Err_Unknown_File_Format; Fail2: ft_input_stream_free( stream, external_stream ); goto Fail; } Success: FT_TRACE4(( "FT_Open_Face: New face object, adding to list\n" )); /* set the FT_FACE_FLAG_EXTERNAL_STREAM bit for FT_Done_Face */ if ( external_stream ) face->face_flags |= FT_FACE_FLAG_EXTERNAL_STREAM; /* add the face object to its driver's list */ if ( FT_NEW( node ) ) goto Fail; node->data = face; /* don't assume driver is the same as face->driver, so use */ /* face->driver instead. */ FT_List_Add( &face->driver->faces_list, node ); /* now allocate a glyph slot object for the face */ { FT_GlyphSlot slot; FT_TRACE4(( "FT_Open_Face: Creating glyph slot\n" )); error = FT_New_GlyphSlot( face, &slot ); if ( error ) goto Fail; face->glyph = slot; } /* finally, allocate a size object for the face */ { FT_Size size; FT_TRACE4(( "FT_Open_Face: Creating size object\n" )); error = FT_New_Size( face, &size ); if ( error ) goto Fail; face->size = size; } /* initialize internal face data */ { FT_Face_Internal internal = face->internal; internal->transform_matrix.xx = 0x10000L; internal->transform_matrix.xy = 0; internal->transform_matrix.yx = 0; internal->transform_matrix.yy = 0x10000L; internal->transform_delta.x = 0; internal->transform_delta.y = 0; } *aface = face; goto Exit; Fail: FT_Done_Face( face ); Exit: FT_TRACE4(( "FT_Open_Face: Return %d\n", error )); return error; } /* documentation is in freetype.h */ FT_EXPORT_DEF( FT_Error ) FT_Attach_File( FT_Face face, const char* filepathname ) { FT_Open_Args open; /* test for valid `face' delayed to FT_Attach_Stream() */ if ( !filepathname ) return FT_Err_Invalid_Argument; open.flags = ft_open_pathname; open.pathname = (char*)filepathname; return FT_Attach_Stream( face, &open ); } /* documentation is in freetype.h */ FT_EXPORT_DEF( FT_Error ) FT_Attach_Stream( FT_Face face, FT_Open_Args* parameters ) { FT_Stream stream; FT_Error error; FT_Driver driver; FT_Driver_Class clazz;
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -