After emWin is used, in addition to drawing images or bmp, the other big data is to display characters. Characters include ASCII codes. Of course, the most important character is Chinese character display.
This section describes how to generate a custom Chinese Character Font and display it on a TFT screen.
Hardware preparation: GG DK3750 or emWin-enabled devices
Software preparation: GG DK3750-> Example-> guidemo, FontCvt.exe, U2C.exe
1. Open the reptile \ emwin \ exefolder under the Simplicity Studio directory and install setupfontcvt_v516.exe.
2. After the installation is complete, double-click to open Font converter for emWin, and click File-> New. In the displayed window, select Standard and Encoding to select 16-Bit UNICODE. Click OK.
3. In the font window, select the appropriate font. Here, select the commonly used. The font type is normal, and the font size is generally 16. The most common Chinese character size is 16*16 pixels.
4. The default font, which contains all UNICODE characters, is very large. It should be about KB. Here we first use some techniques to generate only the Chinese Character Library and ASCII character library we need.
5. Click Edit-> Disable all characters. All characters are missing.
6. To display English letters, click Edit-> Enable range of characters. In the displayed window, select 0 ~ 7F.
7. Use the network tool to query the UINCODE address of the desired character, right-click and select Toggle characters.
8. Use a network tool to query the following string: "Norwegian micro-Company Shanghai office"
9. File-> Save. Set the Save type to C-files (*. c ). Name Songti16.c. At this point, we have prepared the characters, and the next step is how to display them.
10. How to display emWin? You need to convert Chinese characters into strings that emWin can recognize to display them.
11. Open notepad and write the string to be displayed. For example, write the string to the Norwegian micro-Company Shanghai office.
12. Click Save, save, encoding to select the UTF-8 format.
13. Open u2c.exe, load the Txt file created in step 12, and click Convert to generate the corresponding. c file.
Generated Content:
"\ Xe6 \ x8c \ xaa \ xe5 \ xa8 \ x81 \ xe8 \ x83 \ xbd \ xe5 \ xbe \ xae \ xe5 \ x85 \ xac \ xe5 \ x8f \ xb8 \ xe4 \ xb8 \ x8a \ xe6 \ xb5 \ xb7 \ xe5 \ x8a \ x9e \ xe4 \ xba \ x8b \ xe5 \ xa4 \ x84"
14. Open GG DK3750-> example-> guidemo and use include to include Songti16.c.
15. Create a string in main. c with the content in the original C file.
Static const char * _ apStrings [] = {
"\ Xe6 \ x8c \ xaa \ xe5 \ xa8 \ x81 \ xe8 \ x83 \ xbd \ xe5 \ xbe \ xae \ xe5 \ x85 \ xac \ xe5 \ x8f \ xb8 \ xe4 \ xb8 \ x8a \ xe6 \ xb5 \ xb7 \ xe5 \ x8a \ x9e \ xe4 \ xba \ x8b \ xe5 \ xa4 \ x84"
};
16. The source code is as follows:
# Include "Songti16.c"
Static const char * _ apStrings [] = {
"\ Xe6 \ x8c \ xaa \ xe5 \ xa8 \ x81 \ xe8 \ x83 \ xbd \ xe5 \ xbe \ xae \ xe5 \ x85 \ xac \ xe5 \ x8f \ xb8 \ xe4 \ xb8 \ x8a \ xe6 \ xb5 \ xb7 \ xe5 \ x8a \ x9e \ xe4 \ xba \ x8b \ xe5 \ xa4 \ x84"
};
Static const char * _ apStringsE [] = {
"Energy Micro"
};
Int main (void)
{
GUI_Init ();
GUI_Clear ();
Unsigned long I;
GUI_SetFont (& GUI_FontSongti16 );
GUI_UC_SetEncodeUTF8 ();
GUI_SetColor (GUI_YELLOW );
For (I = 0; I <GUI_COUNTOF (_ apStrings); I ++ ){
GUI_DispStringAt (_ apStrings [I], 70, 0 );
GUI_DispNextLine ();
}
GUI_SetColor (GUI_DARKCYAN );
For (I = 0; I <GUI_COUNTOF (_ apStrings); I ++ ){
GUI_DispStringAt (_ apStringsE [I], 70, 50 );
GUI_DispNextLine ();
}
While (1 );
}
17. It's almost over. Let's take a look at the final result.