cancel
Showing results for 
Search instead for 
Did you mean: 

[STemWin] - Allocated TTF font converted to external memory

TNguy.0
Associate

Hello All,

I want to make a font library to support multiple languages, it has to store all the necessary characters inside.

With the language with less characters like English, Italian, Deutsche .... we can store it to internal flash. But when including Simplified Chinese characters it did not enough space to put them all together, it has too much characters (more than 400 compare with 128 of ASCII)

STemWin supports us to convert the TTF font file to c source file which be used to font creating routine. (GUI_TTF_CreateFont())

1 - I did follow the example code from STemWin spec and it worked fine.

GUI_TTF_CS Cs0, Cs1;
GUI_TTF_DATA Data;
GUI_FONT Font0, Font1;
//
// Set parameters for accessing the font file
//
Data.pData = aTTF; // Address
Data.NumBytes = sizeof(aTTF); // Size
//
// Set creation parameters of first font
//
Cs0.pTTF = &Data; // Use address of GUI_TTF_DATA
Cs0.PixelHeight = 24; // Pixel height
Cs0.FaceIndex = 0; // Initialize to 0
//
// Set creation parameters of second font
//
Cs1.pTTF = &Data; // Use address of GUI_TTF_DATA
Cs1.PixelHeight = 48; // Pixel height
Cs1.FaceIndex = 0; // Initialize to 0
//
// Create 2 fonts
//
GUI_TTF_CreateFont(&Font0, &Cs0);
GUI_TTF_CreateFont(&Font1, &Cs1);
//
// Draw something using the fonts
//
GUI_SetFont(&Font0);
GUI_DispString("Hello world\n");
GUI_SetFont(&Font1);
GUI_DispString("Hello world");
  • That mean it worked with internal RAM and the TTF library was set and run correctly.

2 - Because I want to create more fonts and more languages then I mapped to the external RAM to get more space.

#pragma location=0x64000000
static __no_init U32 aMemory[GUI_NUMBYTES / 4];
//Map to the external RAM start address 0x64000000
 
void GUI_X_Config(void)
{
    GUI_ALLOC_AssignMemory(aMemory, GUI_NUMBYTES);
 
}
  • Please noted that I tested read/write external RAM manually and it work correctly

3 - When make a program with TTF font create and initialize GUI to external memory it run with hang hard fault error invalid instruction.

 0690X000006D85BQAS.png

4 - But when put a break point above that hang point and run it again. The data read from external RAM had value available.

 0690X000006D85GQAS.png

Please help me if any one has idea how to debug this problem ?

Or could you please give me any advice if you worked with multiple languages display. The solution how to store all the font inside internal/external memory.

Best regards,

DucThinh

2 REPLIES 2

You can story font in SDIO

TNguy.0
Associate

Dear @Vitaliy Chernobay​ 

Thank you for your help, but because requirement does not support the SD card, then can we store the font TTF in internal/external flash then using the TTF library in executing time and we can use all fonts from external RAM instead?

Thank you,