找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 9615|回复: 2
打印 上一主题 下一主题
收起左侧

STemWIN显示中文字体

[复制链接]
跳转到指定楼层
楼主
ID:75926 发表于 2015-4-10 17:22 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
想让STemWIN显示中文字体首先要移植了文件系统和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;//定义文件系统
/*
*********************************************************************************************************
*
*       _cbGetData
*
* Function description
*   Callback function for getting font data
*
* Parameters:
*   Off      - Position of XBF file to be read文件内偏移量
*   NumBytes - Number of requested bytes需要读取的文件数量
*   pVoid    - Application defined pointer//文件指针
*   pBuffer  - Pointer to buffer to be filled by the function读出来的文件数据缓冲区
*
* 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();
//红色字体的代码在主函数中调用
//这是显示效果 上张图片看看


分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏2 分享淘帖 顶 踩
回复

使用道具 举报

沙发
ID:139917 发表于 2016-9-20 14:50 | 只看该作者
赞                             
回复

使用道具 举报

板凳
ID:191494 发表于 2017-4-20 09:10 | 只看该作者
你好,请问用STemWIN显示字体是镜像的怎么办?
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|51黑电子论坛 |51黑电子论坛6群 QQ 管理员QQ:125739409;技术交流QQ群281945664

Powered by 单片机教程网

快速回复 返回顶部 返回列表