[Gambas-user] Draw.Text problem with control chars
Doriano Blengino
doriano.blengino at ...1909...
Sat Jan 30 10:05:21 CET 2010
Fabien Bodard ha scritto:
> draw.text(replace(stext, "\t",string(" ",5)),x,y)
>
Quick and simple hack, but may be he wants to make tabular columns...
not so simple to do.
Tab widths are not always the same, it depends on the position on screen.
If using a fixed font, then replacing a tabulator with the correct
amount of spaces (not always 5 spaces) works well.
If not using a fixed font, the previous method works not so well: the
calculus should be done in pixels.
To print a tab, one must take the current position, divide by 8 (or
another "tab width", or 64 pixels, or the width of 16 spaces...), take
the integer part, add 1, and multiply again for the tab width (8, or 64,
or the width of 16 spaces, or whatever).
In a word processor applications, tabs are at fixed positions not
necessarily even-spaced. An array with predetermined tab positions could
work.
Regards,
--
Doriano Blengino
"Listen twice before you speak.
This is why we have two ears, but only one mouth."
More information about the User
mailing list