[fxruby-users] FXDCWindow::drawText encoding

Jeroen van der Zijp jeroen at fox-toolkit.org
Wed Mar 23 10:39:30 EST 2005

On Wednesday 23 March 2005 09:20 am, Jannis Pohlmann wrote:
> Hi all.
> I just started experimenting with the FOX drawing functions. After 
> having a little problem with
> text positioning, I know stumbled into an encoding problem (at least, I 
> think so).
> Whenever I want to draw something like "foo\nbar" or "foo\r\nbar" I get 
> those ugly squares (which
> likely symbolize a char the font (?) is not able to display).
> Screenshot is attached. My system's encoding is UTF-8, by the way.
> Any ideas?

Please note that dc.drawText() does not do any formatting, it just draws
the visible characters and draws "replacement" characters for the formatting 
characters like \n and \t.

If you want interpretation of the formatting, just place a text widget and
it will do a lot of formatting for you; alternatively you can write a loop;
here is what FXLabel uses:

    while(end<text.length() && text[end]!='\n') end++;

I know you're working in Ruby, and this is C++.  But I hope you get the
idea:- hunt for the \n, then draw up to that, move to the next line and
hunt for the next \n.  Repeat until the whole string is done....

	- Jeroen

P.S.  As for utf-8, this capability will be in FOX in the 1.6 version;
the plan is to have unicode drawing support for all widgets, and have
some stuff in place for localization.

More information about the fxruby-users mailing list