how to draw text symbols

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
chuma
Earned a small fee
Earned a small fee
Posts: 19
Joined: Tue Jan 03, 2006 8:49 pm
Location: Vancouver, Canada

how to draw text symbols

Post by chuma » Tue Jan 31, 2006 10:09 pm

Using wxGTK-2.6.2 on Scientific Linux Release 4.0

Is it possible to draw symbols, e.g. greek letter theta, integral sign, etc.
using the wxDC::DrawText method, and if so, how???

Trying out the font sample included with the distribution, I can choose the
font "Standard Symbols L" from the font dialog, but it only shows the
usual A-Z a-z alphabet, while xfontsel displays the greek characters as
expected.

Any help is appreciated.

Joe Chuma

Cursor
Earned some good credits
Earned some good credits
Posts: 120
Joined: Sun Aug 29, 2004 3:09 pm
Location: Grenoble, France
Contact:

Post by Cursor » Wed Feb 01, 2006 6:38 am

Yes you can, but - as all text software - you must change the font you use.
If you select a symbol font (1& 2) and use it with wxDC::DrawText, the text is writted with symbols.

1 : http://www.wxwidgets.org/manuals/2.6.2/ ... tml#wxfont
2 : http://www.wxwidgets.org/manuals/2.6.2/ ... xdcsetfont
What is little and green, witch go up and down ??
Yoda playing with the force.

Manu
Experienced Solver
Experienced Solver
Posts: 73
Joined: Wed Jun 22, 2005 8:27 am

Post by Manu » Wed Feb 01, 2006 1:01 pm

Sorry,

What do you mean by
Cursor wrote: If you select a symbol font (1& 2) ....
what do you do exactly ??

thanks

Cursor
Earned some good credits
Earned some good credits
Posts: 120
Joined: Sun Aug 29, 2004 3:09 pm
Location: Grenoble, France
Contact:

Post by Cursor » Wed Feb 01, 2006 5:28 pm

When you create a wxFont object, you can set a font face like "webdings" or "wingdings" (or what you want).
This fonts are symbol-oriented, you can use it to draw such symbols.
What is little and green, witch go up and down ??
Yoda playing with the force.

leio
Can't get richer than this
Can't get richer than this
Posts: 802
Joined: Mon Dec 27, 2004 10:46 am
Location: Estonia, Tallinn
Contact:

Post by leio » Wed Feb 01, 2006 11:48 pm

Actually, wxGTK of course uses GTK+, which in turn uses pango to do its font stuff.
Now, pango uses font-config in a way that you are always almost guaranteed to be shown a glyph, if it exists in any installed font that font-config can see. Simply the selected font is the first where it is looked from.

To show greek letters, you need

a) Use an unicode build of wxWidgets
b) Pass the appropriate unicode value for the letter to DrawText, or another method you are using.
Compilers: gcc-3.3.6, gcc-3.4.5, gcc-4.0.2, gcc-4.1.0 and MSVC6
OS's: Gentoo Linux, WinXP; WX: CVS HEAD

Project Manager of wxMUD - http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI - http://www.omgui.org/

Cursor
Earned some good credits
Earned some good credits
Posts: 120
Joined: Sun Aug 29, 2004 3:09 pm
Location: Grenoble, France
Contact:

Post by Cursor » Thu Feb 02, 2006 6:36 am

Ok, I hadnt tested it on wxGTK (it must do it a day), I only use that on Windows and it work perfectly.
What is little and green, witch go up and down ??
Yoda playing with the force.

leio
Can't get richer than this
Can't get richer than this
Posts: 802
Joined: Mon Dec 27, 2004 10:46 am
Location: Estonia, Tallinn
Contact:

Post by leio » Fri Feb 03, 2006 1:24 am

Yeah, to be cross-platform, what you tell, will be important too.
Compilers: gcc-3.3.6, gcc-3.4.5, gcc-4.0.2, gcc-4.1.0 and MSVC6
OS's: Gentoo Linux, WinXP; WX: CVS HEAD

Project Manager of wxMUD - http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI - http://www.omgui.org/

Post Reply