FXRuby: dc.textFont.nil?

C

Chris Morris

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?
 
L

Lyle Johnson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,169
Messages
2,570,915
Members
47,456
Latest member
JavierWalp

Latest Threads

Top