Question on using Unicode fonts

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
JonnyL
Earned a small fee
Earned a small fee
Posts: 13
Joined: Mon Apr 04, 2005 7:36 pm
Location: Germany, Trier

Question on using Unicode fonts

Post by JonnyL »

Hi everyone,

I was playing around with wxDC to make a simple view-only styled text control to be able to rapidly view huge texts. This works quite well, but a Problem arises, when I'm trying to use Unicode fonts:
I'm working with non-unicode-build and would like to draw single characters with wxDC::DrawText(...) using the numeric unicode adress of the selected glyph.

Any suggestions how this could work? I'm stuck with this Problem.
upCASE
Moderator
Moderator
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE »

Hi!
Set the correct font for the dc and then use something like greekstring = wxT("\x3B1\x3B2\x3B3"); with the correct numeric values for the chars.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
JonnyL
Earned a small fee
Earned a small fee
Posts: 13
Joined: Mon Apr 04, 2005 7:36 pm
Location: Germany, Trier

Post by JonnyL »

Is it possible, that this only works in Unicode build? I thought in non-Unicode _T(...) doesn't do anything at all (?).

I am afraid, because with wxDC text can only be drawn via a wxString parameter and in non-Unicode build wxString characters internally are standard C chars, drawing chars with numeric values > 0xFF is simply not possible.

But anyway I'll try your code when I'm coming home from work today. Thanks.
JonnyL
Earned a small fee
Earned a small fee
Posts: 13
Joined: Mon Apr 04, 2005 7:36 pm
Location: Germany, Trier

Post by JonnyL »

Me again.

upCASE, I couldn't get the code you proposed to work as it should. I tried

Code: Select all

    wxString test = _T("\x3AC\x3AD\x3AE");
    dc.DrawText(test, 100,100);
with Palatino Linotype set as Font, where 0x3AC, 0x3AD, and 0x3AE should be the greek letters alpha, epsilon and eta (each with an acute), but the characters shown were these of 0xAC, 0xAD and 0xAE. :(

I guess when not using unicode build all chars are cut to the last byte.

Or did I understand something wrong in your post?
Last edited by JonnyL on Wed Apr 06, 2005 2:31 pm, edited 1 time in total.
krysa
Experienced Solver
Experienced Solver
Posts: 71
Joined: Wed Feb 16, 2005 9:23 pm
Location: Lithuania

Post by krysa »

JonnyL wrote:

Code: Select all

    wxString test = _T("\x3AC\x3AD\x3AE");
in ANSI build this should be:

Code: Select all

    wxString test = L"\x03AC\x03AD\x03AE";
Platform: MSW (Windows XP Pro)
Compiler: msvc 13.10.3077 (Free Toolkit)
wxWidgets: v2.6.0
JonnyL
Earned a small fee
Earned a small fee
Posts: 13
Joined: Mon Apr 04, 2005 7:36 pm
Location: Germany, Trier

Post by JonnyL »

Unfortunately, this won't work, too. In ANSI build if I use

Code: Select all

    wxString test = L"\x03AC\x03AD\x03AE"; 
    dc.DrawText(test, 100,100);
nothing is drawn to the screen. Anyway thanks for your reply, krysa.
krysa
Experienced Solver
Experienced Solver
Posts: 71
Joined: Wed Feb 16, 2005 9:23 pm
Location: Lithuania

Post by krysa »

JonnyL wrote:Unfortunately, this won't work, too. In ANSI build if I use

Code: Select all

    wxString test = L"\x03AC\x03AD\x03AE"; 
    dc.DrawText(test, 100,100);
nothing is drawn to the screen. Anyway thanks for your reply, krysa.
Have you tryed using some conversions from unicode to ansi (like iconv or wx)?
Platform: MSW (Windows XP Pro)
Compiler: msvc 13.10.3077 (Free Toolkit)
wxWidgets: v2.6.0
Post Reply