OpenGLES---加载文字

来源:互联网 发布:淘宝店铺如何暂时关闭 编辑:程序博客网 时间:2024/06/06 00:27

用的是这个https://www.freetype.org/

{1:加载库文件2:freetype简单用法}


{1:加载库文件\depends\lib\windows\x86freetype.lib 库文件depends\includefreetype  文件夹ft2build.h  头文件}

{2:freetype简单用法1:初始化字体库FT_Init_FreeType( &_library );2:装载一个字体//FT_New_Face(FT_Library library,const char* filepathname,FT_Long face_index,FT_Face *aface); FT_Error error = FT_New_Memory_Face((FT_Library)_library,(const FT_Byte *)_fontBuffer,length,0,(FT_Face*)&_face);3:设置当前象素尺寸(设置字体大小)FT_Set_Char_Size((FT_Face)_face, ftSize, 0, 72, 72); //FT_Set_Pixel_Sizes( FT_Face face,FT_UInt pixel_width,FT_UInt  pixel_height );4:装载一个字形图像FT_UInt index= FT_Get_Char_Index(_face, ch );// 得到字符的索引FT_Load_Glyph( _face,index, FT_LOAD_DEFAULT );//加载一个字符FT_Glyph glyph;FT_Get_Glyph( FT_Face(_face)->glyph, &glyph );FT_Glyph_To_Bitmap( &glyph, ft_render_mode_normal, 0, 1 ); //渲染字符ft_render_mode_normal 渲染为256级灰度图(默认)ft_render_mode_mono   是黑白位图}

源码地址

http://pan.baidu.com/s/1geVargZ    OpenGL_ES(6.8).zip





0 0