ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  About font filename support
Posted by Wontae on Jul-25-2023 16:57
Hi Peter

i have a one question.

in c++
setLabelStyle(font, fontSize, fontColor, fontAngle)


my question is font filename not support korean?

for example
setLabelStyle("Harmony M.ttf", 10, color, 0)   => it is work
setLabelStyle("하모니 M.ttf" ", 10, color, 0)  => not work

same fontfile but name is different.



Thank you

  Re: About font filename support
Posted by Peter Kwan on Jul-25-2023 20:44
Hi Wontae,

If you are using ChartDirector 7, it can support user friendly font names, which is the font names you see when choose the font in Microsoft Word. For example, instead of using "times.ttf", you can use "Time News Roman".

I do not have Korean Windows or your font, so I do not know what is the correct font name. I think some possibilities are:

현대하모니
현대하모니M
현대하모니 M
하모니
하모니M
하모니 M

You can open Microsoft Word (or any GUI program that allows you to select the font) and check what is the name of the font.

As ChartDirector expects UTF8 encoding, please use something like:

setLabelStyle(WCHARtoUTF8(L"현대하모니 M"), 10, color, 0)

If you are using MFC,  you can try _T string:

setLabelStyle(TCHARtoUTF8(_T("현대하모니 M")), 10, color, 0)

Best Regards
Peter Kwan

  Re: About font filename support
Posted by Wontae on Jul-26-2023 10:30
Hi Peter

Sorry for the trouble
I use ChartDirector 6

I tried like the sample you suggested, but it didn't work
ex) setLabelStyle(TCHARtoUTF8(_T("현대하모니 M")), 10, color, 0)

addTitle is same

c.addTitle(TCHARtoUTF8(_T("현대하모니 M")), TCHARtoUTF8(_T("현대하모니 M.TTF")), 20, 0, 0xFFFFFF);  // use font filename
c.addTitle(TCHARtoUTF8(_T("현대하모니 M")), TCHARtoUTF8(_T("현대하모니 M")), 20, 0, 0xFFFFFF); // use fontname
=>  2 case's result is "ㅁㅁㅁㅁㅁ M"  Korean Language is broken



I change font filename to English ("현대하모니 M.TTF"  -> "aaaa.TTF")
c.addTitle(TCHARtoUTF8(_T("현대하모니 M")), TCHARtoUTF8(_T("aaaa.TTF")), 20, 0, 0xFFFFFF); => result is "현대하모니 M "


is ChartDirector 6 not support?
If chart director 6 is supported, I will look for issues in other my codes.

Best Regards
Wontae Noh

  Re: About font filename support
Posted by Peter Kwan on Jul-26-2023 20:57
Attachments:
Hi Wontae,

User friendly font names are only supported since ChartDirector 7. ChartDirector 6 can only use ASCII font filenames.

The easiest way is to upgrade to ChartDirector 7. But if this is not desirable, you can use the "short pathname" for the file instead of the normal filename.

For your case, please first verify if your font filename is really in Korean and the font file is in "c:WindowsFonts". The font name shown in "c:WindowsFonts" is not the filename. To obtain the filename, select a font, right click and select "Properties". I have attached two screen shots for your reference. Please verify the font name is really Korean, and the font is in "c:windowsfonts" (or [windows]fonts, where [windows] is the windows OS directory).

After the font name is in fact in Korean, in ChartDirector 6, you can use the short pathname instead. The windows API is GetShortPathName. See:

https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getshortpathnamew

(Long time ago, windows filename can have at most 8 ASCII characters, and 3 ASCII characters for the file extension. Modern file systems support longer filenames, but for backwards compatibility, there is also an automatically generated short filename for each file. The short filename is normally not visible, but you can use GetShortPathName to get it.

Best Regards
Peter Kwan
explorer_20230726142743.png
ApplicationFrameHost_20230726142844.png

  Re: About font filename support
Posted by HANSOO KIM on Jul-27-2023 18:49
Attachments:
Dear Wontae :

Everying convered to UTF8, not unicode itself and font name and font files totally different matters, so, You have to make sure font name on the windows system. below sample shows "현대하모니 M + Italic"

<code>

char titleName[128] = { 0 };
char UTF8Bytes[128] = { 0 };

CString szTitle;
szTitle.Format(_T("다람쥐 헌 쳇바퀴에"));
memset(titleName, 0, 64);
nLen = WideCharToMultiByte(CP_UTF8, 0, szTitle.GetBuffer(), (int)szTitle.GetLength(), NULL, 0, NULL, NULL);
WideCharToMultiByte(CP_UTF8, 0, szTitle.GetBuffer(), (int)szTitle.GetLength(), titleName, nLen, NULL, NULL);


CString szFont;
szFont.Format(_T("현대하모니 M Italic"));
memset(UTF8Bytes, 0, 64);
nLen = WideCharToMultiByte(CP_UTF8, 0, szTitle.GetBuffer(), (int)szTitle.GetLength(), NULL, 0, NULL, NULL);
WideCharToMultiByte(CP_UTF8, 0, szTitle.GetBuffer(), (int)szTitle.GetLength(), UTF8Bytes, nLen, NULL, NULL);

c->addTitle(titleName, UTF8Bytes, 48);


</code>


BR
HANSOO KIM
hy.png