⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tft_font.c

📁 用OV7720制作摄像头的详细电路原理图
💻 C
字号:
//====================================================================================//文 件 名:TFT_Font.c//功能描述: TFT字库管理//维护记录: 2007年8月20日//			2007.08.20			更新日志//								First Version//====================================================================================#include "TFT_Config.h"#include "TFT_Font.h"STR_FONT g_SysAsciiFontList[TFT_MAXFONT];STR_FONT g_SysChineseFontList[TFT_MAXFONT];//=============================================================//语法格式:	static FONT TFT_AllocChineseFont(void)//实现功能:	申请可用的英文字体信息//参数:		无//返回值:		字体编号//=============================================================static FONT TFT_AllocAsciiFont(void){	int i;	for(i = 0; i < TFT_MAXFONT; i++)	{		if(g_SysAsciiFontList[i].FontBuf == FONT_UNUSE_FLAG)		{			g_SysAsciiFontList[i].FontBuf = FONT_USE_FLAG;			return i;		}	}	return NO_FREE_FONT;}//=============================================================//语法格式:	static FONT TFT_AllocChineseFont(void)//实现功能:	申请可用的中文字体信息//参数:		无//返回值:		字体编号//=============================================================static FONT TFT_AllocChineseFont(void){	int i;	for(i = 0; i < TFT_MAXFONT; i++)	{		if(g_SysChineseFontList[i].FontBuf == FONT_UNUSE_FLAG)		{			g_SysChineseFontList[i].FontBuf = FONT_USE_FLAG;			return i;		}	}	return NO_FREE_FONT;}//=============================================================//语法格式:	static void TFT_FreeAsciiFont(FONT Handle)//实现功能:	销毁英文字体信息//参数:		Handle	 - 字体编号//返回值:		无//=============================================================static void TFT_FreeAsciiFont(FONT Handle){	if((Handle >= 0) && (Handle < TFT_MAXFONT))	{		g_SysAsciiFontList[Handle].FontBuf = FONT_UNUSE_FLAG;		g_SysAsciiFontList[Handle].CharWidth = 		g_SysAsciiFontList[Handle].CharHeight = 0;	}}//=============================================================//语法格式:	static void TFT_FreeChineseFont(FONT Handle)//实现功能:	销毁中文字体信息//参数:		Handle	 - 字体编号//返回值:		无//=============================================================static void TFT_FreeChineseFont(FONT Handle){	if((Handle >= 0) && (Handle < TFT_MAXFONT))	{		g_SysChineseFontList[Handle].FontBuf = FONT_UNUSE_FLAG;		g_SysChineseFontList[Handle].CharWidth = 		g_SysChineseFontList[Handle].CharHeight = 0;	}}//=============================================================//语法格式:	void TFT_FontInit(void)//实现功能:	初始化字库//参数:		无//返回值:		无//=============================================================void TFT_FontInit(void){	int i;	for(i = 0; i < TFT_MAXFONT; i++)	{		g_SysChineseFontList[i].FontBuf = g_SysAsciiFontList[i].FontBuf = FONT_UNUSE_FLAG;		g_SysChineseFontList[i].CharWidth = g_SysAsciiFontList[i].CharWidth = 		g_SysChineseFontList[i].CharHeight = g_SysAsciiFontList[i].CharHeight = 0;	}}//=============================================================//语法格式:	unsigned short TFT_GetAsciiFontWidth(FONT Handle)//实现功能:	获取英文字体宽度//参数:		Handle	 - 字体编号//返回值:		字体宽度//=============================================================unsigned short TFT_GetAsciiFontWidth(FONT Handle){	if(g_SysAsciiFontList[Handle].FontBuf != FONT_UNUSE_FLAG)		return g_SysAsciiFontList[Handle].CharWidth;	return 0;}//=============================================================//语法格式:	unsigned short TFT_GetChineseFontWidth(FONT Handle)//实现功能:	获取中文字体宽度//参数:		Handle	 - 字体编号//返回值:		字体宽度//=============================================================unsigned short TFT_GetChineseFontWidth(FONT Handle){	if(g_SysChineseFontList[Handle].FontBuf != FONT_UNUSE_FLAG)		return g_SysChineseFontList[Handle].CharWidth;	return 0;}//=============================================================//语法格式:	unsigned short TFT_GetAsciiFontHeight(FONT Handle)//实现功能:	获取英文字体高度//参数:		Handle	 - 字体编号//返回值:		字体高度//=============================================================unsigned short TFT_GetAsciiFontHeight(FONT Handle){	if(g_SysAsciiFontList[Handle].FontBuf != FONT_UNUSE_FLAG)		return g_SysAsciiFontList[Handle].CharHeight;	return 0;}//=============================================================//语法格式:	unsigned short TFT_GetChineseFontHeight(FONT Handle)//实现功能:	获取中文字体高度//参数:		Handle	 - 字体编号//返回值:		字体高度//=============================================================unsigned short TFT_GetChineseFontHeight(FONT Handle){	if(g_SysChineseFontList[Handle].FontBuf != FONT_UNUSE_FLAG)		return g_SysChineseFontList[Handle].CharHeight;	return 0;}//=============================================================//语法格式:	unsigned char *TFT_GetAsciiFontBuf(FONT Handle)//实现功能:	获取英文字体缓冲区地址//参数:		Handle	 - 字体编号//返回值:		缓冲区地址//=============================================================unsigned char *TFT_GetAsciiFontBuf(FONT Handle){	return g_SysAsciiFontList[Handle].FontBuf;}//=============================================================//语法格式:	unsigned char *TFT_GetChineseFontBuf(FONT Handle)//实现功能:	获取中文字体缓冲区地址//参数:		Handle	 - 字体编号//返回值:		缓冲区地址//=============================================================unsigned char *TFT_GetChineseFontBuf(FONT Handle){	return g_SysChineseFontList[Handle].FontBuf;}//=============================================================//语法格式:	int TFT_GetAsciiFontInfo(FONT Handle, STR_FONT *FontInfo)//实现功能:	获取英文字体信息//参数:		Handle	 - 字体编号//				FontInfo - 字库信息结构体地址//返回值:		1:成功;  0:失败//=============================================================int TFT_GetAsciiFontInfo(FONT Handle, STR_FONT *FontInfo){	if(g_SysAsciiFontList[Handle].FontBuf == FONT_UNUSE_FLAG)		return 0;	FontInfo->FontBuf = g_SysAsciiFontList[Handle].FontBuf;	FontInfo->CharWidth = g_SysAsciiFontList[Handle].CharWidth;	FontInfo->CharHeight = g_SysAsciiFontList[Handle].CharHeight;	return 1;}//=============================================================//语法格式:	int TFT_GetChineseFontInfo(FONT Handle, STR_FONT *FontInfo)//实现功能:	获取中文字体信息//参数:		Handle	 - 字体编号//				FontInfo - 字库信息结构体地址//返回值:		1:成功;  0:失败//=============================================================int TFT_GetChineseFontInfo(FONT Handle, STR_FONT *FontInfo){	if(g_SysChineseFontList[Handle].FontBuf == FONT_UNUSE_FLAG)		return 0;	FontInfo->FontBuf = g_SysChineseFontList[Handle].FontBuf;	FontInfo->CharWidth = g_SysChineseFontList[Handle].CharWidth;	FontInfo->CharHeight = g_SysChineseFontList[Handle].CharHeight;	return 1;}//=============================================================//语法格式:	short TFT_LoadAsciiFont(STR_FONT *FontInfo)//实现功能:	加载英文字库//参数:		FontInfo - 字库信息结构体地址//返回值:		新添加的字库序号, -1表示加载失败//=============================================================FONT TFT_LoadAsciiFont(STR_FONT *FontInfo){	FONT Handle;	if((Handle = TFT_AllocAsciiFont()) == NO_FREE_FONT)		return NO_FREE_FONT;	g_SysAsciiFontList[Handle].FontBuf = FontInfo->FontBuf;	g_SysAsciiFontList[Handle].CharWidth = FontInfo->CharWidth;	g_SysAsciiFontList[Handle].CharHeight = FontInfo->CharHeight;	return Handle;}//=============================================================//语法格式:	FONT TFT_LoadChineseFont(STR_FONT *FontInfo)//实现功能:	加载中文字库//参数:		FontInfo - 字库信息结构体地址//返回值:		新添加的字库序号, -1表示加载失败//=============================================================FONT TFT_LoadChineseFont(STR_FONT *FontInfo){	FONT Handle;	if((Handle = TFT_AllocChineseFont()) == NO_FREE_FONT)		return NO_FREE_FONT;	g_SysChineseFontList[Handle].FontBuf = FontInfo->FontBuf;	g_SysChineseFontList[Handle].CharWidth = FontInfo->CharWidth;	g_SysChineseFontList[Handle].CharHeight = FontInfo->CharHeight;	return Handle;}//=============================================================//语法格式:	void TFT_UnLoadAsciiFont(unsigned short FontID)//实现功能:	卸载指定序号的英文字库//参数:		FontID - 字库序号//返回值:		无//=============================================================void TFT_UnLoadAsciiFont(FONT Handle){	if(g_SysAsciiFontList[Handle].FontBuf == FONT_UNUSE_FLAG)		return;	TFT_FreeAsciiFont(Handle);}//=============================================================//语法格式:	void TFT_UnLoadChineseFont(unsigned short FontID)//实现功能:	卸载指定序号的中文字库//参数:		FontID - 字库序号//返回值:		无//=============================================================void TFT_UnLoadChineseFont(FONT Handle){	if(g_SysChineseFontList[Handle].FontBuf == FONT_UNUSE_FLAG)		return;	TFT_FreeChineseFont(Handle);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -