找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 9928|回復(fù): 2
打印 上一主題 下一主題
收起左側(cè)

STemWIN顯示中文字體

[復(fù)制鏈接]
跳轉(zhuǎn)到指定樓層
樓主
ID:75926 發(fā)表于 2015-4-10 17:22 | 只看該作者 回帖獎勵 |倒序瀏覽 |閱讀模式
想讓STemWIN顯示中文字體首先要移植了文件系統(tǒng)和STemWIN才行.
#include"GUI.h"
#include "ff.h"

GUI_XBF_DATA XBF_Data;
GUI_FONT     XBF_Font;
FIL          Fontfile;//定義文件
FRESULT result;//文件操作標準
uint32_t br,bw;//
FATFSfatfs;//定義文件系統(tǒng)
/*
*********************************************************************************************************
*
*       _cbGetData
*
* Function description
*   Callback function for getting font data
*
* Parameters:
*   Off      - Position of XBF file to be read文件內(nèi)偏移量
*   NumBytes - Number of requested bytes需要讀取的文件數(shù)量
*   pVoid    - Application defined pointer//文件指針
*   pBuffer  - Pointer to buffer to be filled by the function讀出來的文件數(shù)據(jù)緩沖區(qū)
*
* Return value:
*   0 on success, 1 on error
*********************************************************************************************************
*/
static int _cbGetData(U32 Off, U16 NumBytes, void * pVoid, void * pBuffer)
{
FIL *FontFile;
/* The pVoid pointer may be used to get a file handle */
FontFile = (FIL *)pVoid;
/*
* Set file pointer to the required position
*/
result =f_lseek(FontFile, Off);
if (result != FR_OK)
{
return 1; /* Error */
}
/*
* Read data into buffer
*/
result = f_read(FontFile, pBuffer, NumBytes, &bw);
if (result != FR_OK)
{
return 1; /* Error */
}
return 0;
}


            f_mount(0,&fatfs);
result = f_open(&Fontfile, "0:/Font.xbf", FA_OPEN_EXISTING | FA_READ | FA_OPEN_ALWAYS);//黑色字體的字符串是 字體的文件名
if (result != FR_OK)
{
return;
}
//
// Create XBF font
//
GUI_XBF_CreateFont(&XBF_Font,       // Pointer to GUI_FONT structure in RAM(3)
&XBF_Data,         // Pointer to GUI_XBF_DATA structure in RAM
GUI_XBF_TYPE_PROP_AA4_EXT, // Font type to be created
_cbGetData,        // Pointer to callback function
&Fontfile);
GUI_UC_SetEncodeUTF8();
//紅色字體的代碼在主函數(shù)中調(diào)用
//這是顯示效果 上張圖片看看


分享到:  QQ好友和群QQ好友和群 QQ空間QQ空間 騰訊微博騰訊微博 騰訊朋友騰訊朋友
收藏收藏2 分享淘帖 頂 踩
回復(fù)

使用道具 舉報

沙發(fā)
ID:139917 發(fā)表于 2016-9-20 14:50 | 只看該作者
贊                             
回復(fù)

使用道具 舉報

板凳
ID:191494 發(fā)表于 2017-4-20 09:10 | 只看該作者
你好,請問用STemWIN顯示字體是鏡像的怎么辦?
回復(fù)

使用道具 舉報

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規(guī)則

手機版|小黑屋|51黑電子論壇 |51黑電子論壇6群 QQ 管理員QQ:125739409;技術(shù)交流QQ群281945664

Powered by 單片機教程網(wǎng)

快速回復(fù) 返回頂部 返回列表