Is it possible to use font maker to build up CJK characters? I've tried it to input two Chinese characters, but it seems to be not correct, please check my attached picture.
MAMAHOW
Hi,
Can you please re-attach your picture? It doesn't seem to have made it in this topic.
After running some tests it seems to be a problem with Windows, and how it handles the input boxes.
Hi,
Please check my setting of Font Maker
and the font image output of Chinese character seems to be chooped out.
Thanks,
Monky
Hi,
We've tested our makefont tool with Chinese characters without any trouble. Can you post the truetype font file and character set you're using (save the contents of the input box to a unicode textfile).
Hi~
How to load Chinese character set?I just saw ASCii and Extended ascii in the Load character set list.
Hi Maya,
You can type a custom character set in the textbox. To be able to type Chinese characters there, you need to have support for Chinese symbols on your Windows installation.
An updated font tool will be available in one of the upcoming EDGELIB releases which can also read the character set from a unicode text file.
Hi,
Thanks for your reply.
I create font surface and coding as follows,
font.SetFontCharacters(0, 127);
font.BuildFont(true);
buffer->DrawFont(100, 100, &font;, "一二八", EFO_HCENTER | EFO_VCENTER | EFX_OPACITY, 255);
but can't see any font. Anything goes wrong?
Hi Maya,
To use non-ascii characers (such as Chinese), we recommend using font.SetCharacterSet. Also make sure to use WCHAR strings instead of char to support unicode.
I try it as follow,
if (ef.Open("font.epk", EFOF_READ))
{
if (!ef.PackAuthorize(0)){
SetErrorMsg("Pack Authorize fail!!!");
return(E_ERROR);
}
ClassEMemory::DeAlloc(filedata);
}
else{
SetErrorMsg("Open epk fail!!!");
return(E_ERROR);
}
if (ef.PackGetFileData(filedata, filedatasize, "test.png") == E_OK)
{
if (display->CreateSurface(&shared.test;, filedata, filedatasize) != E_OK)
{
SetErrorMsg("CreateSurface fail!--> test.png");
return(E_ERROR);
}
WCHAR testFont = (WCHAR)L"一乙丁七乃九了二人儿入八几刀刁力";
shared.test.SetFontCharacterSet(&testFont;);
shared.test.BuildFont(true);
ClassEMemory::DeAlloc(filedata);
}
WCHAR testFont1 = (WCHAR)L"一二八";
buffer->DrawFont(iconRC.left+iconWidth/2, iconRC.top+70+offsetH, &shared-;>test, &testFont1;, EFO_HCENTER | EFO_VCENTER | EFX_OPACITY, imgOpacity);
but I still can't see any font.
Could you show me the sample code about Drawing font using non-ASCII character set? thanks a lot!
Hi Maya,
The first thing that could go wrong is how the WCHAR string is defined. Please check at the sample below:
- Code:
WCHAR testFont = (WCHAR)L"一乙丁七乃九了二人儿入八几刀刁力"; //This doesn't work because it doesn't allocate a full character array for all your characters
WCHAR testFont[] = L"一乙丁七乃九了二人儿入八几刀刁力"; //This is better
Another problem is that the L"" operator is ambigious between compilers, and WCHAR is not. For gcc compilers (such as Symbian and iPhone) the L"" allocated 4 bytes per character while WCHAR is always 2 bytes per character.
The best way to handle this is to store your string in a unicode text file and read it like this:
- Code:
ClassEFile ef;
WCHAR testFont[256];
ClassEStd::StrCpy(testFont, "");
if (ef.Open("test.txt", EFOF_READ | EFOF_READONLYPATH))
{
unsigned short uni_id;
ef.Read(&uni_id, 2);
if (uni_id == 0xFEFF)
{
unsigned long fsize = ef.Size();
if (fsize < 256 * sizeof(WCHAR) && size % 2 == 0)
{
ef.Read(testFont, fsize - 2);
testFont[(fsize - 2) / sizeof(WCHAR)] = 0;
}
}
ef.Close();
}
Hi,
Thanks for your reply.
I try your suggestion, it's work.
But I want to show string dynamically,the string is composed of any text in testFont.txt(continue last post), such as "九十","十入"...,because I don't know what string I will draw,I can't store my string in a unicode text file in advance,I try draw as follows,
WCHAR myText[]= L"九十".
buffer->DrawFont(100, 100, &font;, myText, EFO_HCENTER | EFO_VCENTER | EFX_OPACITY, 255);
It have compile error as follows,
error C2440: 'initializing' : cannot convert from 'const wchar_t [4]' to 'unsigned short []'
2> There is no context in which this conversion is possible
how can I do?
Hi Maya,
Unfortunately, that's not possible. It's mainly due to the difference between the wchar_t and WCHAR datatypes. The only solution would be to write your own wchar_t to WCHAR converter.