[Gambas-user] Where is Font.Resolution?

Benoit Minisini gambas at ...1...
Thu Oct 9 12:57:53 CEST 2008


On jeudi 09 octobre 2008, Rolf-Werner Eilert wrote:
> Benoit Minisini schrieb:
> > On mercredi 08 octobre 2008, Rolf-Werner Eilert wrote:
> >> Another question:
> >>
> >> In Gambas1, there was Font.Resolution. I used it for scaling things. In
> >> Gambas2, it doesn't exist anymore.
> >>
> >> Is there a replacement?
> >>
> >> Regards
> >>
> >> Rolf
> >
> > Desktop.Resolution (more logical name)
>
> Are you sure this was the same? Font.Resolution had a completely
> different description:
>
> --------------
> STATIC PROPERTY Resolution AS Integer
>
>
> Returns or sets the resolution used for transforming font size from
> points to screen pixel sizes. By default, font size is based on a 96 DPI
> resolution.
> Gambas use this property so that a given font size will always display
> the same whatever the real screen resolution is.
>
>
> --------------
>
> In the printing engine I programmed in Gambas1, the only chance to get
> pictures/images (such as firm logo etc.) printed correctly was to
> compute a graphical ratio like this:
>
> 'before starting to print, get graphical ratio
>
>   grafikRatio = Desktop.Resolution / Font.Resolution
>
> 'then start printing, and when it's an image,
> 'compute the printing ratio for it and calculate
> 'the stretching values in percent (as they are given
> 'in the printing form)
>
>      bild = image.Load(datei$)
>      druckRatio = Printer.Resolution / Desktop.Resolution * grafikRatio
>      breite = bild.Width
>      hoehe = bild.Height
>      breite = (breite / 100 * prozent) * druckRatio
>      hoehe = (hoehe / 100 * prozent) * druckRatio
>      Draw.Image(bild.Stretch(breite, hoehe), x1, y1)
>
> Don't ask me about details, it's been a long time ago, but it used to
> run this way and had cost me a lot of brain pain at that time to develop
>
>   :-) I vaguely remember that otherwise the images turned out way too
>
> small or too large.
>
> Now fyi, in Gambas2 I just replaced Font.Resolution by "96", and it runs
> as expected. The basic question now is, what does printing have to do
> with desktop resolution, and is there an easier way to achieve this in
> Gambas2?
>
> Regards
>
> Rolf
>

Forget Font.Resolution.

If you are drawing on screen, the font resolution is Desktop.Resolution, and 
if you are drawing on printer, the font resolution is Printer.Resolution.

And remember that:
- You are drawing with pixels.
- Resolution is a number of pixels per inch.
- Font height is in point, which is 1/72th of an inch. (in Postscript. It is 
actually an approximation. Love english units :-) )

Your way of drawing a picture is correct, but you can do faster in Gambas2, 
because you can stretch and draw in one shot with the Draw.Image() method. No 
need to stretch first, then draw.

Regards,

-- 
Benoit Minisini




More information about the User mailing list