Sorry this reply took longer than normal, I had to investigate some things in the font
engine to make sure I'm doing this right :)
About the colors, you were doing it just fine, but there was a bug in
PGCANVAS_COLORCONV. More of a typo than a bug actually, but I just committed a fix to
widget/canvas.c
For the fonts, the non-zero width of nothing you observed is a 'margin' value added
when rendering the text so it doesn't get jammed up against the side of something when
it's using the various alignments. It can be turned off with the PG_FSTYLE_FLUSH font
flag. Just allocate a font using pgNewFont, and logically or in the PG_FSTYLE_FLUSH
flag with your third parameter. Something like this would give you the default font,
but with no extra spacing:
font = pgNewFont(NULL,0,PG_FSTYLE_FLUSH | PG_FSTYLE_DEFAULT);
Just pass this font handle to pgSizeText and the canvas operations instead of 0. If
this is bothersome, I'm open to suggestions for alternate implementations of the font
metrics. (Especially things I don't know much about, like asian fonts and proportional
font rendering)
Another thing to note: Every time you use pgNewString, remember that you are
allocating an object in the server. For the gropnodes in the canvas, you need the
server to remember the text, but in pgSizeText you don't. To avoid memory leaks,
either delete the string handle explicitly with pgDelete, or surround the block of
code using the temporary string handles with pgEnterContext() and pgLeaveContext() to
automatically clean up.
On Wed, 04 April 2001, Olivier Bornet wrote:
>
> Hello,
>
> I have some questions about the use of PG_GROP_TEXT for the
> implementation the Waba (http://waba.sourceforge.net) port to
> PicoGUI.
>
> - pgSizeText(). After some tests, I think it compute not in a
> correct way. To have correct size, we have to substract a
> w_nothing value calculate with :
> pgSizeText( &w_nothing, &h, theFont, pgNewString( "" ).
>
> - when writing a text, we always have a small space just before
> it (corresponding to w_nothing / 2 ).
>
> - color selection for text doesn't work. Or I don't understand
> how to use.
>
> Attached to this email is a small sample with all the points.
>
> The main question is "Is this the real way of use, or is this
> a bug ? (for the position/size problems), and How to use color ?"
>
> Thanks in advance.
>
> Olivier
> --
> Olivier Bornet SMARTDATA SA
> [EMAIL PROTECTED] Centre du Parc
> http://www.smartdata.ch av. des Pr�s-Beudin 20
> Phone +41-27-723'55'03 1920 Martigny
> Fax +41-27-723'55'19 Phone +41-27-723'55'18
--
perl -e'socket S,2,1,tcp;connect S,pack(H16,"0200029a80692d32").\0x8;print
grep!/=/,<S>'
_______________________________________________
Pgui-devel mailing list
[EMAIL PROTECTED]
http://lists.sourceforge.net/lists/listinfo/pgui-devel