如何在 FXRuby 中的 FXCanvas 上使用drawText?

发布于 2024-10-02 17:54:55 字数 237 浏览 0 评论 0原文

我正在尝试使文本出现在 FXCanvas 上。当我使用此代码时:

def score_box(event)
FXDCWindow.new(@canvas) do |dc|

    dc.drawText(640, 450, @score)
end     
end  

但它给我一个错误,说我需要选择一种字体,我该怎么做?或者你能提供在画布上制作文本的方法吗?谢谢

-双极裤

I am trying to make text appear on a FXCanvas. when I use this code:

def score_box(event)
FXDCWindow.new(@canvas) do |dc|

    dc.drawText(640, 450, @score)
end     
end  

but it gives me an error saying I need to select a font, how do I do this? or could you provide anyway to make text on a canvas? Thanks

-bipolarpants

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

西瓜 2024-10-09 17:54:55

您需要在设备上下文(dc)中选择一个 FXFont 对象,例如

FXDCWindow.new(@canvas) do |dc|
  font = FXFont.new(...)
  font.create
  dc.font = font
  dc.drawText(640, 450, @score)
end

You need to select an FXFont object into the device context (dc), e.g.

FXDCWindow.new(@canvas) do |dc|
  font = FXFont.new(...)
  font.create
  dc.font = font
  dc.drawText(640, 450, @score)
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文