获得位图之freetype

本文介绍了如何使用freetype库来获取位图,包括初始化库、打开字体文件、设置点阵大小以及通过FT_Load_Char加载字符来获取字体的位图。freetype的坐标系统可能较为复杂,建议结合示例图进行理解。
摘要由CSDN通过智能技术生成

freetype只获得位图步骤有:1.初始化freetype库,2..打开字体文件3.设置点阵大小(用默认的也行)4.用FT_Load_Char来获得字体的点阵,就像gbk或点阵用索引来的得到位图一样。不过freetype的坐标挺复杂下面上传一张图来对应程序理解就容易了。

#include <config.h>
#include <fonts_manager.h>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H

static int FreeTypeFontInit(char *pcFontFile, unsigned int dwFontSize);
static int FreeTypeGetFontBitmap(unsigned int dwCode, PT_FontBitMap ptFontBitMap);

static T_FontOpr g_tFreeTypeFontOpr = {
	.name          = "freetype",
	.FontInit      = FreeTypeFontInit,
	.GetFontBitmap = FreeTypeGetFontBitmap,
};

static FT_Library g_tLibrary;
static FT_Face g_tFace;
static FT_GlyphSlot g_tSlot;

static int FreeTypeFontInit(char *pcFontFile, unsigned int dwFontSize)
{
	int iError;

	/* 显示矢量字体 */
	iError = FT_Init_Free
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值