在Haskell的GTK的DrawingArea上绘制文本 [英] Drawing text on GTK's DrawingArea in Haskell

查看:165
本文介绍了在Haskell的GTK的DrawingArea上绘制文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆