[N9H20 Non-OS] How to utilize GB2312 font encoding?

Post Reply
9chuckyoung
Posts: 88
Joined: 28 Jan 2019, 13:49

08 Jan 2021, 17:18

Nuvoton added GB2312 font encoding support and here are the steps:

0. You need a font data contains GB2312 font.
Please note that Nuvoton emWin feature does not come with any fonts or a permission or license to use any PC installed font for converting purposes. It is user’s sole responsibility to not infringe upon any third party intellectual property right by making use of the fonts in its application and obtain a license if required by the legal owner of the font.

1. Download the latest N9H20 BSP https://github.com/OpenNuvoton/N9H20_emWin_NonOS version v6.10f.6.
How to check version? Please refer to the link https://github.com/OpenNuvoton/N9H20_em ... _Version.h

Code: Select all

#define GUI_VERSION 610066
2. Enable GB2312:

Code: Select all

//
// Init emWin
//
GUI_Init();
//
// Enable GB2312
//
NVT_GUI_GB_SetEncodeGB2312();
3. Assign ASCII font data offset: (*if needed*)

Code: Select all

//
// _acFontDataArray is your font data in c array
// _u32AsciiFontDataOffset means the first ASCII font data offset, e. g., 0x00000000
//
NVT_GUI_SetASCIIOffset((U32)_acFontDataArray, _u32AsciiFontDataOffset);
4. Assign GB2312 font data offset:

Code: Select all

//
// _acFontDataArray is your font data in c array
// _u32Gb2312FontDataOffset means the first GB2312 font data offset, e. g., 0x00000800
//
NVT_GUI_SetGB2312Offset((U32)_acFontDataArray, _u32Gb2312FontDataOffset);
What is "_acFontDataArray"? This file could be ASCII + GB2312, e. g.,

Code: Select all

unsigned char _acFontDataArray[8888UL + 1] = {
  0x00, 0x00, ...
}
5. Set font name:

Code: Select all

//
// GUI_MyFont is a user defined font that utilizes emWin font structure
//
GUI_SetFont(&GUI_MyFont);
What is "GUI_MyFont"? It is a user defined font with emWin font structure, e. g.,

Code: Select all

GUI_CONST_STORAGE GUI_FONT GUI_MyFont = {
    GUI_FONTTYPE_PROP,
    ...
}
//
// Please note that it supports "GUI_FONTTYPE_PROP" ONLY!
//
6. Draw GB2312 font:

Code: Select all

//
// If your IDE & compiler support GB2312 font encoding:
//
GUI_DispString("啊\n");
//
// Or utilize hex code:
// The first byte 0xb0 is "区码" & the second byte 0xa1 is "位码"
// 0xb0, 0xa1 equals 啊
//
GUI_DispString("\xb0\xa1\n");
//
// Another example:
//
GUI_DispString("Hello! World~\xb0\xa1""GB2312 test OK!\n");

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest