pango_font_description_from_string设置字体
来源:互联网 发布:数据分析师 薪水 编辑:程序博客网 时间:2024/06/06 10:01
pango_font_description_from_string设置字体
使用PangoFontDescription更改指定控件的样式
/*
* pango_font_description_from_string();
* 字体font的设置采用字符串格式, "[Family-List] [Style-Options] [size]"
* Family-List: 一串以逗号分割的字体名, 逗号结尾.
* Sytle-Ooptions: 一串空格分割的选项: Bold Italic 等
* size: 大小, 10进制数, 以point为单位.
* 示例:
* font_name = " Sans, Bold Italic 12"
* font_name = " Sans,"
* font_name = "Bold 12"
* font_name = "12"
* font_name = "Bold Italic"
*/
PangoFontDescription *font_desc = pango_font_description_from_string("Sans Blod 20");
pango_font_description_set_size (font_desc, 50 * PANGO_SCALE); // 这里的“50”就是你的字体大小,可以随意设置。
gtk_widget_modify_font(font_desc);
// gtk_widget_set_style();
// gtk_widget_modify_style();
pango_font_description_free (font_desc);
实例:
GtkWidget *entry = NULL;
entry = gtk_entry_new ();
PangoFontDescription *pfd;
pfd = pango_font_description_from_string("Sans 12");
gtk_widget_modify_font(GTK_WIDGET(entry),pfd);
pango_font_description_free(pfd); // 释放
// 设置字体颜色:
PangoAttrList *attrls = NULL;
PangoAttribute *attr = NULL;
attrls = pango_attr_list_new ();
attr = pango_attr_underline_new(PANGO_UNDERLINE_SINGLE);
attr->start_index = 0; // 设置下划线,0-3 总共3个字符有下划线
attr->end_index = 3;
pango_attr_list_change(attrls, attr);
attr = pango_attr_foreground_new(65535,0,0); // 设置颜色,rgb
pango_attr_list_change(attrls, attr);
gtk_label_set_attributes(GTK_LABEL(label), attrls);
pango_attr_list_unref(attrls); // 释放
if (default_font_ == NULL) {
GtkSettings* settings = gtk_settings_get_default();
gchar* font_name = NULL;
g_object_get(settings, "gtk-font-name", &font_name, NULL); // important
// Temporary CHECK for helping track down
// http://code.google.com/p/chromium/issues/detail?id=12530
CHECK(font_name) << " Unable to get gtk-font-name for default font.";
PangoFontDescription* desc = pango_font_description_from_string(font_name);
default_font_ = new Font(desc);
pango_font_description_free(desc);
g_free(font_name);
DCHECK(default_font_);
}
- pango_font_description_from_string设置字体
- 设置字体
- 字体设置
- 设置字体
- 字体设置
- 设置字体
- 设置字体
- 设置字体
- 设置字体
- 字体设置
- 设置字体
- iOS 设置字体 自定义字体
- iOS 设置字体 自定义字体
- iOS 设置字体 自定义字体
- VS2010字体设置+推荐字体
- ckeditor设置默认字体设置
- Android 字体设置 Typeface 设置
- icewm的字体设置
- 18条人情规则
- 谈谈:.Net中的序列化和反序列化
- Linux虚拟内存实现原理
- stl格式说明和stl文件生成(ascII,binary),vs2005,文件生成后imageware读取成功
- [译]人脸检测与人脸识别简介
- pango_font_description_from_string设置字体
- input文本输入框的文字居中处理
- ODBC 连接 oracle 数据库
- 如何在KEIL编译器中创建工程V0.9测试版
- struts2.1.6 1 初步与配置
- VC++图象处理编程
- HTML5之IndexedDB使用详解
- 任天堂红白机- 好的设计的典型
- 代码运行框