在Haskell的GTK的DrawingArea上绘制文本 [英] Drawing text on GTK's DrawingArea in Haskell
问题描述
我有一个 DrawingArea
,我可以使用 drawRectangle
和的drawLine
。如何在该区域上绘制文字?我最感兴趣的是能够快速输出单行文本的东西。
I have a DrawingArea
onto which I can draw using primitives such as drawRectangle
and drawLine
. How do I draw text onto that area? I'm most interested in something that quickly outputs a single line of text.
Graphics.UI.Gtk.Gdk.Drawable.layoutLine
Graphics.UI.Gtk.Gdk.Drawable.layoutLine
seems to be what I want, but it wants a Graphics.Rendering.Pango.Layout.LayoutLine
as input. How do I construct that LayoutLine
?
有没有比这样更好的选择?
Are there better alternatives than doing it this way?
谢谢!
Thanks!
推荐答案
我已经找到了用Pango做这件事的方法。 / p>
I've found the way to do this with Pango.
layout <- widgetCreateLayout drawAreaWidget stringToDraw
然后,您可以使用这个新创建的布局,其中包含 drawLayout
和 drawLayoutWithColors
。
Then you can use this newly-created layout with functions such as drawLayout
and drawLayoutWithColors
.
这篇关于在Haskell的GTK的DrawingArea上绘制文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!