[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

FXRuby: dc.textFont.nil?

Chris Morris

2/14/2005 2:56:00 AM

I'm working off a modified version of the bounce.rbw sample, and in
this snippet:

def drawScene(drawable)
FXDCWindow.new(drawable) { |dc|
dc.setForeground(FXRGB(255, 255, 255))
dc.fillRectangle(0, 0, drawable.width, drawable.height)
@ball.draw(dc)
}
end

... the dc.textFont is nil ... so how can I access the current font
that's being used to make use of getTextWidth and getTextHeight
methods in order to properly layout text?

--
Chris
http:/...


2 Answers

Chris Morris

2/14/2005 3:24:00 AM

0

getApp().normalFont seems to be a valid substitute.


On Sun, 13 Feb 2005 20:55:51 -0600, Chris Morris <the.chrismo@gmail.com> wrote:
> I'm working off a modified version of the bounce.rbw sample, and in
> this snippet:
>
> def drawScene(drawable)
> FXDCWindow.new(drawable) { |dc|
> dc.setForeground(FXRGB(255, 255, 255))
> dc.fillRectangle(0, 0, drawable.width, drawable.height)
> @ball.draw(dc)
> }
> end
>
> ... the dc.textFont is nil ... so how can I access the current font
> that's being used to make use of getTextWidth and getTextHeight
> methods in order to properly layout text?
>
> --
> Chris
> http:/...
>


--
Chris
http:/...


Lyle Johnson

2/17/2005 2:14:00 PM

0

On Mon, 14 Feb 2005 11:56:06 +0900, Chris Morris <the.chrismo@gmail.com> wrote:

> I'm working off a modified version of the bounce.rbw sample, and in
> this snippet:
>
> def drawScene(drawable)
> FXDCWindow.new(drawable) { |dc|
> dc.setForeground(FXRGB(255, 255, 255))
> dc.fillRectangle(0, 0, drawable.width, drawable.height)
> @ball.draw(dc)
> }
> end
>
> ... the dc.textFont is nil ... so how can I access the current font
> that's being used to make use of getTextWidth and getTextHeight
> methods in order to properly layout text?

I've seen your follow-up message about using FXApp#normalFont as a
valid substitute, but just wanted to clarify something.

A device context (i.e. an FXDC instance) doesn't have a default text
font. So if you don't explicitly set it yourself (using the
FXDC#textFont accessor in FXRuby 1.0, or FXDC#font in FXRuby 1.2) then
yes, it will be nil.