[Gambas-user] Draw.Text adapted to DrawingArea ?

Eilert eilert-sprachen at ...221...
Mon Feb 14 15:11:39 CET 2005


Ah Laurent, I think I didn't explain clear enough what I want. Let me 
say it this way:

When I start my preview, I call a function that recalculates millimeters 
into screen pixels. The DrawingArea has to be adjusted in measures of 
screen pixels. My little function take the Desktop.Resolution and 
computes the necessary number of pixels to let the DrawingArea as wide 
and as long as necessary for an A4 page.

The problem is that it miscalculates a bit (maybe 10 %) because 
"Desktop.Resolution" says something like 76, and it would be 82 to make 
a "real" A4 sheet (I compared it on the screen).

So everything appears somewhat smaller than A4. No problem, BUT WITH FONTS:

Fonts are sized in pts, i. e. points, and not screen pixels. The 
function behind this in Qt recalculates my "Courier 12" into the 
necessary number of screen pixels for a page with Desktop.Resolution 76, 
not 82. So on my somewhat smaller page, all fonts appear slightly too big.

What I am looking for is an easy way to rescale the fonts to a size 
which fits to the scale of my DrawingArea, maybe something like a 
pts-to-screen-pixel ratio.

Rolf


Laurent Carlier schrieb:
> Le Lundi 14 Février 2005 12:10, Eilert a écrit :
> 
>>The Draw.Text() function has a width and height option, but I don't
>>understand how it works (no examples in the help) and I don't know if it
>>would be of any help here.
> 
> 
> draw.textHeight("my text") return the height of the text (my text) in pixels,
> draw.textWidth("my text") return the width of the text (my text) in pixels.
> 





More information about the User mailing list