?? ftobjs.c
字號:
} /* documentation is in freetype.h */#ifdef FT_CONFIG_OPTION_USE_CMAPS FT_EXPORT_DEF( FT_UInt ) FT_Get_Char_Index( FT_Face face, FT_ULong charcode ) { FT_UInt result = 0; if ( face && face->charmap ) { FT_CMap cmap = FT_CMAP( face->charmap ); result = cmap->clazz->char_index( cmap, charcode ); } return result; }#else /* !FT_CONFIG_OPTION_USE_CMAPS */ FT_EXPORT_DEF( FT_UInt ) FT_Get_Char_Index( FT_Face face, FT_ULong charcode ) { FT_UInt result = 0; FT_Driver driver; if ( face && face->charmap ) { driver = face->driver; result = driver->clazz->get_char_index( face->charmap, charcode ); } return result; }#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ /* documentation is in freetype.h */ FT_EXPORT_DEF( FT_ULong ) FT_Get_First_Char( FT_Face face, FT_UInt *agindex ) { FT_ULong result = 0; FT_UInt gindex = 0; if ( face && face->charmap ) { gindex = FT_Get_Char_Index( face, 0 ); if ( gindex == 0 ) result = FT_Get_Next_Char( face, 0, &gindex ); } if ( agindex ) *agindex = gindex; return result; } /* documentation is in freetype.h */#ifdef FT_CONFIG_OPTION_USE_CMAPS FT_EXPORT_DEF( FT_ULong ) FT_Get_Next_Char( FT_Face face, FT_ULong charcode, FT_UInt *agindex ) { FT_ULong result = 0; FT_UInt gindex = 0; if ( face && face->charmap ) { FT_UInt32 code = (FT_UInt32)charcode; FT_CMap cmap = FT_CMAP( face->charmap ); gindex = cmap->clazz->char_next( cmap, &code ); result = ( gindex == 0 ) ? 0 : code; } if ( agindex ) *agindex = gindex; return result; }#else /* !FT_CONFIG_OPTION_USE_CMAPS */ FT_EXPORT_DEF( FT_ULong ) FT_Get_Next_Char( FT_Face face, FT_ULong charcode, FT_UInt *agindex ) { FT_ULong result = 0; FT_UInt gindex = 0; FT_Driver driver; if ( face && face->charmap ) { driver = face->driver; result = driver->clazz->get_next_char( face->charmap, charcode ); if ( result != 0 ) { gindex = driver->clazz->get_char_index( face->charmap, result ); if ( gindex == 0 ) result = 0; } } if ( agindex ) *agindex = gindex; return result; }#endif /* !FT_CONFIG_OPTION_USE_CMAPS */ /* documentation is in freetype.h */ FT_EXPORT_DEF( FT_UInt ) FT_Get_Name_Index( FT_Face face, FT_String* glyph_name ) { FT_UInt result = 0; if ( face && FT_HAS_GLYPH_NAMES( face ) ) { /* now, lookup for glyph name */ FT_Driver driver = face->driver; FT_Module_Class* clazz = FT_MODULE_CLASS( driver ); if ( clazz->get_interface ) { FT_Face_GetGlyphNameIndexFunc requester; requester = (FT_Face_GetGlyphNameIndexFunc)clazz->get_interface( FT_MODULE( driver ), "name_index" ); if ( requester ) result = requester( face, glyph_name ); } } return result; } /* documentation is in freetype.h */ FT_EXPORT_DEF( FT_Error ) FT_Get_Glyph_Name( FT_Face face, FT_UInt glyph_index, FT_Pointer buffer, FT_UInt buffer_max ) { FT_Error error = FT_Err_Invalid_Argument; /* clean up buffer */ if ( buffer && buffer_max > 0 ) ((FT_Byte*)buffer)[0] = 0; if ( face && glyph_index <= (FT_UInt)face->num_glyphs && FT_HAS_GLYPH_NAMES( face ) ) { /* now, lookup for glyph name */ FT_Driver driver = face->driver; FT_Module_Class* clazz = FT_MODULE_CLASS( driver ); if ( clazz->get_interface ) { FT_Face_GetGlyphNameFunc requester; requester = (FT_Face_GetGlyphNameFunc)clazz->get_interface( FT_MODULE( driver ), "glyph_name" ); if ( requester ) error = requester( face, glyph_index, buffer, buffer_max ); } } return error; } /* documentation is in freetype.h */ FT_EXPORT_DEF( const char* ) FT_Get_Postscript_Name( FT_Face face ) { const char* result = NULL; if ( !face ) goto Exit; result = face->internal->postscript_name; if ( !result ) { /* now, look up glyph name */ FT_Driver driver = face->driver; FT_Module_Class* clazz = FT_MODULE_CLASS( driver ); if ( clazz->get_interface ) { FT_Face_GetPostscriptNameFunc requester; requester = (FT_Face_GetPostscriptNameFunc)clazz->get_interface( FT_MODULE( driver ), "postscript_name" ); if ( requester ) result = requester( face ); } } Exit: return result; } /* documentation is in tttables.h */ FT_EXPORT_DEF( void* ) FT_Get_Sfnt_Table( FT_Face face, FT_Sfnt_Tag tag ) { void* table = 0; FT_Get_Sfnt_Table_Func func; FT_Driver driver; if ( !face || !FT_IS_SFNT( face ) ) goto Exit; driver = face->driver; func = (FT_Get_Sfnt_Table_Func)driver->root.clazz->get_interface( FT_MODULE( driver ), "get_sfnt" ); if ( func ) table = func( face, tag ); Exit: return table; } FT_EXPORT_DEF( FT_Error ) FT_Activate_Size( FT_Size size ) { FT_Face face; if ( size == NULL ) return FT_Err_Bad_Argument; face = size->face; if ( face == NULL || face->driver == NULL ) return FT_Err_Bad_Argument; /* we don't need anything more complex than that; all size objects */ /* are already listed by the face */ face->size = size; return FT_Err_Ok; } /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /**** ****/ /**** ****/ /**** R E N D E R E R S ****/ /**** ****/ /**** ****/ /*************************************************************************/ /*************************************************************************/ /*************************************************************************/ /* lookup a renderer by glyph format in the library's list */ FT_BASE_DEF( FT_Renderer ) FT_Lookup_Renderer( FT_Library library, FT_Glyph_Format format, FT_ListNode* node ) { FT_ListNode cur; FT_Renderer result = 0; if ( !library ) goto Exit; cur = library->renderers.head; if ( node ) { if ( *node ) cur = (*node)->next; *node = 0; } while ( cur ) { FT_Renderer renderer = FT_RENDERER( cur->data ); if ( renderer->glyph_format == format ) { if ( node ) *node = cur; result = renderer; break; } cur = cur->next; } Exit: return result; } static FT_Renderer ft_lookup_glyph_renderer( FT_GlyphSlot slot ) { FT_Face face = slot->face; FT_Library library = FT_FACE_LIBRARY( face ); FT_Renderer result = library->cur_renderer; if ( !result || result->glyph_format != slot->format ) result = FT_Lookup_Renderer( library, slot->format, 0 ); return result; } static void ft_set_current_renderer( FT_Library library ) { FT_Renderer renderer; renderer = FT_Lookup_Renderer( library, ft_glyph_format_outline, 0 ); library->cur_renderer = renderer; } static FT_Error ft_add_renderer( FT_Module module ) { FT_Library library = module->library; FT_Memory memory = library->memory; FT_Error error; FT_ListNode node; if ( FT_NEW( node ) ) goto Exit; { FT_Renderer render = FT_RENDERER( module ); FT_Renderer_Class* clazz = (FT_Renderer_Class*)module->clazz; render->clazz = clazz; render->glyph_format = clazz->glyph_format; /* allocate raster object if needed */ if ( clazz->glyph_format == ft_glyph_format_outline && clazz->raster_class->raster_new ) { error = clazz->raster_class->raster_new( memory, &render->raster ); if ( error ) goto Fail; render->raster_render = clazz->raster_class->raster_render; render->render = clazz->render_glyph; } /* add to list */ node->data = module; FT_List_Add( &library->renderers, node ); ft_set_current_renderer( library ); } Fail: if ( error ) FT_FREE( node ); Exit: return error; } static void ft_remove_renderer( FT_Module module ) { FT_Library library = module->library; FT_Memory memory = library->memory; FT_ListNode node; node = FT_List_Find( &library->renderers, module ); if ( node ) { FT_Renderer render = FT_RENDERER( module ); /* release raster object, if any */ if ( render->raster ) render->clazz->raster_class->raster_done( render->raster ); /* remove from list */ FT_List_Remove( &library->renderers, node ); FT_FREE( node ); ft_set_current_renderer( library ); } } /* documentation is in ftrender.h */ FT_EXPORT_DEF( FT_Renderer ) FT_Get_Renderer( FT_Library library, FT_Glyph_Format format ) { /* test for valid `library' delayed to FT_Lookup_Renderer() */ return FT_Lookup_Renderer( library, format, 0 ); } /* documentation is in ftrender.h */ FT_EXPORT_DEF( FT_Error ) FT_Set_Renderer( FT_Library library, FT_Renderer renderer, FT_UInt num_params, FT_Parameter* parameters ) { FT_ListNode node; FT_Error error = FT_Err_Ok; if ( !library ) return FT_Err_Invalid_Library_Handle; if ( !renderer ) return FT_Err_Invalid_Argument; node = FT_List_Find( &library->renderers, renderer ); if ( !node ) { error = FT_Err_Invalid_Argument; goto Exit; } FT_List_Up( &library->renderers, node ); if ( renderer->glyph_format == ft_glyph_format_outline ) library->cur_renderer = renderer; if ( num_params > 0 ) { FTRenderer_setMode set_mode = renderer->clazz->set_mode; for ( ; num_params > 0; num_params-- ) { error = set_mode( renderer, parameters->tag, parameters->data ); if ( error ) break; } } Exit: return error; }
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -