在gtk textview中使用系统等宽字体 [英] use the system monospace font in gtk textview

查看:116
本文介绍了在gtk textview中使用系统等宽字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的(Python)程序中使用系统等宽字体显示文本中的GtkTextView。我找到了许多使用expicit字体名称和大小的方法。但是,我想使用系统指定的等宽字体(例如,从ubuntu字体首选项面板)。



我的程序应该能够在Windows以及Linux上运行没有修改,自动选择正确的字体。



澄清,这是不是我想要的:

  fontdesc = pango.FontDescription(Courier 18)
textview.modify_font(fontdesc)

b $ b

I would like to have a GtkTextView in my (Python) program which shows text with the system monospace font. I found many ways which use an expicit font family name and size. However, I would like to use the system specified monospace font (e.g. from the ubuntu font preferences panel).

My program should be able to run on Windows as well as Linux without modifications, chosing automatically the right font.

to clarify, this is not what I want:

fontdesc = pango.FontDescription("Courier 18")
textview.modify_font(fontdesc)

解决方案

You can just use "monospace 18" as your font and it will use the system monospaced font.

这篇关于在gtk textview中使用系统等宽字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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