[Gambas-user] Again printing, here: how to change Font-properties?
Benoit Minisini
gambas at ...1...
Sat Jul 10 18:11:07 CEST 2004
On Saturday 10 July 2004 17:54, Hans-Martin Bundeshund wrote:
> Salute group,
>
> now I tried to implement printing to my 'mercantile'-application
> 'gambakaan' (kaan = kaufmännische Anwendung = mercantile-application if my
> translation is right). But I am doing somethin basicly wrong. When I trie
> to print a text using this:
>
>
> ###########################################
> sub print_it()
> DIM mytext AS String
>
> 'init the printer
> draw.begin(Printer)
> draw.font.Italic = TRUE
> draw.Font.size = 12
>
> 'puzzeling my text
> 'I only do this for a better view of the lines
> mytext = "Line1" & "\n"
> mytext = mytext & "Line2" & "\n"
> mytext = mytext & "Line3" & "\n"
>
> draw.Text(mytext,200,200)
> draw.End
> end
> ###########################################
>
>
> the values .size, .italic and name (not seen in the example) make no sence
> to the output. I can enter italic = false or true, same result.
>
> So what must I do to activate my new settings?
>
> And I have a second question: When I want to use different font-types with
> different sizes, I think I have to write the code like this:
>
> ###########################################
> sub print_it()
> DIM mytext AS String
>
> 'init the printer for headline-text
> draw.begin(Printer)
> draw.font.Italic = TRUE
> draw.Font.size = 24
>
> 'puzzeling my headlines
> mytext = "Headline1" & "\n" 'I only do this
> for a better view of the lines
> mytext = mytext & "Hedaline2" & "\n"
> draw.Text(mytext,200,200)
>
>
> 'init the printer for bottom-text
> draw.begin(Printer)
> draw.font.Italic = TRUE
> draw.Font.size = 12
>
> 'puzzeling my bottom-text
> mytext = "Bottomtext1" & "\n"
> mytext = mytext & "Bottomtext2" & "\n"
> draw.Text(mytext,200,200+200)
>
> draw.End
> end
> ###########################################
>
> Thanks for your help,
>
> HM
>
>
The Font class has changed since 0.92 (always read changelog men !)
Before, it acted like it does in Visual Basic. Now it is a true class, so
doing Draw.Font.Italic = TRUE does not change the Font object used by the
Draw class. You must do:
DIM hFont AS Font
hFont = Draw.Font
hFont.Italic = TRUE
Draw.Font = hFont
Or more quickly:
Draw.Font.Italic = TRUE
Draw.Font = Draw.Font ' It seems stupid, doesn't it ?
This change allowed me to remove some code in the interpreter that was there
just because of the Font class, and so I could speed up some things.
Now, I admit that the Font property is a bit strange, so maybe I will try to
reimplement the VB syntax in a next version.
If Something.Font.Italic = TRUE must change the font of the 'Something'
object, it means that the font object owns a reference on the 'Something'
object. But remember that the 'Something' object already has a reference on
the font object. So there will be a circular reference that will prevent the
objects to be freed... Problem!
Writing a syntax easy to use is not simple!
Regards,
--
Benoit Minisini
mailto:gambas at ...1...
More information about the User
mailing list