?? tft_font.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 + -