Author Topic: How to change Chineess front in STM32F103  (Read 1458 times)

0 Members and 1 Guest are viewing this topic.

Offline Md Mubdiul HasanTopic starter

  • Regular Contributor
  • *
  • Posts: 202
  • Country: kr
  • Lets learn more to be more inspired in Electronics
How to change Chineess front in STM32F103
« on: January 17, 2022, 08:01:24 am »
Hi there,


I am handling a project which has display application both for English and Korean front but I would like to add Chiness front in it.
For that reason, I have to add more thing in front.c and front.h etc.

I can made some Chineess front/ charecter using Note pad pixel and a software named KSX1001 frontedit
BMP to front can be made. i.e IMAGE SIZE-16*16, front size-32. Software output gives .c file when input is a .bmp file.

Take a look output c file for a given .bmp,
Code: [Select]
#define byte unsigned char
#define word unsigned int
//---------------------------------------------------------
extern code byte ImageFontTbl[];
//---------------------------------------------------------

code byte ImageFontTbl[]={ // ImageSize: 16 X 16
0xff,0x7f, // QQQQQQQQ.QQQQQQQ
0xff,0x7f, // QQQQQQQQ.QQQQQQQ
0xff,0x7f, // QQQQQQQQ.QQQQQQQ
0xff,0x7f, // QQQQQQQQ.QQQQQQQ
0xc0,0x01, // QQ.............Q
0xdf,0x7d, // QQ.QQQQQ.QQQQQ.Q
0xdf,0x7d, // QQ.QQQQQ.QQQQQ.Q
0xdf,0x7d, // QQ.QQQQQ.QQQQQ.Q
0xdf,0x7d, // QQ.QQQQQ.QQQQQ.Q
0xc0,0x01, // QQ.............Q
0xdf,0x7d, // QQ.QQQQQ.QQQQQ.Q
0xff,0x7f, // QQQQQQQQ.QQQQQQQ
0xff,0x7f, // QQQQQQQQ.QQQQQQQ
0xff,0x7f, // QQQQQQQQ.QQQQQQQ
0xff,0x7f, // QQQQQQQQ.QQQQQQQ
0xff,0x7f, // QQQQQQQQ.QQQQQQQ

}; // FontSize= 32




Now my original front.c file called image registor in  following way

Code: [Select]
const unsigned char IMAGE_16_16[COUNT_OF_16_IMAGE][32] = {

{0x11,0xaa,0x44,0x00,0xff,0x00,0xff,0x00,0x44,0xaa,0x11,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00}, // trace
{0x00,0xfe,0x02,0x12,0x12,0x12,0x12,0x82,0x42,0x22,0x12,0x0a,0x06,0xfe,0x00,0x00,0x00,0x3f,0x30,0x28,0x24,0x22,0x21,0x24,0x22,0x24,0x28,0x24,0x20,0x3f,0x00,0x00}, // Inverter
{0xff,0x01,0xfd,0xed,0xed,0xed,0xed,0x7d,0xbd,0xdd,0xed,0xf5,0xf9,0x01,0xff,0x00,0x7f,0x40,0x4f,0x57,0x5b,0x5d,0x5e,0x5b,0x5d,0x5b,0x57,0x5b,0x5f,0x40,0x7f,0x00}, // Reverse invertion
................................
................................

Another place they have represent korean front as follows,

Code: [Select]
const unsigned char FONT_HAN[0x168][32] = {
  {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
  {0x00, 0x04, 0x04, 0x04, 0xc4, 0xfc, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x18, 0x0e, 0x07, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
  {0x00, 0x04, 0x04, 0xfc, 0xfc, 0x04, 0xfc, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x1f, 0x07, 0x18, 0x1f, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
..................................
................................

 Even they have also present each letter

Code: [Select]
const unsigned char WAN_TO_JO[0x92E][2] = {
{0x88, 0x61},// 가
{0x88, 0x62},// 각
{0x88, 0x65},// 간
{0x88, 0x68},// 갇
{0x88, 0x69},// 갈
{0x88, 0x6a},// 갉
{0x88, 0x6b},// 갊
{0x88, 0x71},// 감
{0x88, 0x73},// 갑
{0x88, 0x74},// 값
{0x88, 0x75},// 갓
{0x88, 0x76},// 갔
...............................
...............................



Kindly suggest me what to do things for chiness. Does Image count has particular meaning to display it?
Does chiness front also need ASCI II charecter ? My front C also includes ASCI II.
Figure out the difference between IMAGE and FRONT of constant unsigned charecter.
« Last Edit: January 17, 2022, 08:11:53 am by Md Mubdiul Hasan »
Hasan
 

Offline thm_w

  • Super Contributor
  • ***
  • Posts: 6352
  • Country: ca
  • Non-expert
Re: How to change Chineess front in STM32F103
« Reply #1 on: January 17, 2022, 10:22:50 pm »
You mean "font" not "front" right.
As mentioned on the crosspost here: https://www.electro-tech-online.com/threads/how-to-change-chinese-front-in-stm32f103-c-programming.162865/
Look into GB2312 encoding.

You'll have to figure out how your specific application is displaying each font and convert your drawing to that type.
some examples here: https://learn.adafruit.com/adafruit-gfx-graphics-library/using-fonts
Profile -> Modify profile -> Look and Layout ->  Don't show users' signatures
 

Offline Md Mubdiul HasanTopic starter

  • Regular Contributor
  • *
  • Posts: 202
  • Country: kr
  • Lets learn more to be more inspired in Electronics
Re: How to change Chineess front in STM32F103
« Reply #2 on: January 18, 2022, 12:37:52 am »
Quote
Look into GB2312 encoding.
Do you want me to use similar one?, https://string-functions.com/encodedecode.aspx
As I mentioned earlier, I can generate directly front from image file. Lets say image file is given.


Quote
You'll have to figure out how your specific application is displaying each font and convert your drawing to that type.
some examples here: https://learn.adafruit.com/adafruit-gfx-graphics-library/using-fonts

STM32 firmware can do this job nicely. In my case code need modify. Take a look
Code: [Select]
void TextOut_5_4(int x, int y, char ch)
{
UINT i, yIndex;
UINT ArryIndex;
BYTE FontData;

yIndex = y % 8;
y /= 8;

for(i = 0; i < 4; i++)
{
ArryIndex = y * SCREEN_WITH + x + i;

FontData = FONT_5_4[(BYTE)ch][i] << yIndex;
pLCD_Screen[ArryIndex] |= FontData;

FontData = FONT_5_4[(BYTE)ch][i] >> (8 - yIndex);
pLCD_Screen[ArryIndex + SCREEN_WITH] |= FontData;
}

}

int TextOut(int x, int y, char *pString, BOOL bInvert)
{
int Size = 0;

while(*pString)
{
if(*pString & 0x80)
{
TextOut_Han(x, y, pString, bInvert);
pString += 2;
x += 16;
Size += 16;
}
else
{
TextOut_ASC_II_16(x, y, *pString, bInvert);
pString++;
x += 8;
Size += 8;
}
}

return Size;
}
Hasan
 

Offline AndyC_772

  • Super Contributor
  • ***
  • Posts: 4227
  • Country: gb
  • Professional design engineer
    • Cawte Engineering | Reliable Electronics
Re: How to change Chineess front in STM32F103
« Reply #3 on: January 18, 2022, 08:32:24 am »
You might find this software helpful:

https://github.com/pavius/the-dot-factory

It converts bitmaps into C code in a variety of formats - you might find there's one that's similar to the way your existing software encodes other fonts.

Offline Md Mubdiul HasanTopic starter

  • Regular Contributor
  • *
  • Posts: 202
  • Country: kr
  • Lets learn more to be more inspired in Electronics
Re: How to change Chineess front in STM32F103
« Reply #4 on: January 24, 2022, 05:02:54 am »
You might find this software helpful:

https://github.com/pavius/the-dot-factory

It converts bitmaps into C code in a variety of formats - you might find there's one that's similar to the way your existing software encodes other fonts.

Your suggestion has already implemented. That was not main issue.
Hasan
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf