标签:
杂谈 |
分类: 稚嫩痕迹 |
1,控件通用
颜色:
GdkColor color;
gdk_color_parse ("颜色(如green,red,blue)", &color);
gtk_widget_modify_text (GTK_WIDGET(控件), GTK_STATE_NORMAL, &color);//文本颜色
gtk_widget_modify_bg
gtk_widget_modify_fg
(GTK_WIDGET(控件),
字体:
PangoFontDescription *font_desc =
pango_font_description_from_string("Sans");
pango_font_description_set_size (font_desc, 15 * PANGO_SCALE);
gtk_widget_modify_font
(GTK_WIDGET(控件),
pango_font_description_free (font_desc);
2, label控件
除了可以用以上程序调整外,还可以用gtk_label_set_markup()函数(功能虽然很强大,但是容易失去控制~不如用方法1。)
gtk_label_set_markup(GTK_LABEL(labelname)),"<span foreground='red' underline='double' underline_color='blue' font_desc='32'>label for test!</span>");
<span>标签是用来操作label显示的属性,包括背景色,字体色,字体,字体大小,下划线,等等.
其中foreground='red' 就是定义前景色(字体颜色)为红色,也可以foreground='#00FF00',这两个值是相等的.
underline='double' 是下划线为双线,还可以设值为'none', 'single', 'double', 'low', 'error' 等.
underline_color='blue' 是下划线的颜色.
此外,还可以选的属性有:
font_desc 字体大小,值如'12',官方文档说明为字体描述,但我测试结果为字体大小
size 官方文档为字体大小,但我测试结果不起作用.
stype 样式,值如'normal', 'oblique', 'italic' 等.
weight 字型,值如'ultralight', 'light', 'normal', 'bold', 'ultrabold'等
stretch 拉伸,值如'ultracondensed', 'extracondensed', 'condensed', 'semicondensed', 'normal', 'semiexpanded', 'expanded', 'extraexpanded', 'ultraexpanded'
SPAN文档:
The root tag of a marked-up document is
<markup>, but pango_parse_markup()
allows you to
omit this tag, so you will most likely never need to use it. The
most
general markup tag is <span>, then
there are some convenience
tags. <span> has the following
attributes:
<span> attributes
font_desc
A font description string, such as "Sans Italic 12".
See
pango_font_description_from_string()
for a description of the format of the string representation . Note
that any
other span attributes will override this description. So if you
have
"Sans Italic" and also a style="normal" attribute, you will get
Sans normal,
not italic.
font_family
A font family name
face
Synonym for font_family
size
Font size in 1024ths of a point, or one of the absolute
sizes
'xx-small', 'x-small', 'small', 'medium', 'large', 'x-large',
'xx-large', or one of the relative sizes 'smaller' or
'larger'.
If you want to specify a absolute size, it's usually easier
to take advantage of the ability to specify a partial
font description using 'font_desc'; you can use
font_desc='12.5' rather than
size='12800'.
style
One of 'normal', 'oblique', 'italic'
weight
One of 'ultralight', 'light', 'normal', 'bold', 'ultrabold',
'heavy',
or a numeric weight
variant
'normal' or 'smallcaps'
stretch
One of 'ultracondensed', 'extracondensed', 'condensed',
'semicondensed', 'normal', 'semiexpanded', 'expanded',
'extraexpanded', 'ultraexpanded'
foreground
An RGB color specification such as '#00FF00' or a color name such
as
'red'
background
An RGB color specification such as '#00FF00' or a color name such
as
'red'
underline
One of 'none', 'single', 'double', 'low', 'error'
underline_color
The color of underlines; an RGB color specification such as
'#00FF00'
or a color name such as 'red'
rise
Vertical displacement, in 10000ths of an em. Can be negative
for
subscript, positive for superscript.
strikethrough
'true' or 'false' whether to strike through the text
strikethrough_color
The color of strikethrough lines; an RGB color specification such
as
'#00FF00' or a color name such as 'red'
fallback
'true' or 'false' whether to enable fallback. If disabled, then
characters
will only be used from the closest matching font on the system. No
fallback
will be done to other fonts on the system that might contain the
characters
in the text. Fallback is enabled by default. Most applications
should not
disable fallback.
lang
A language code, indicating the text language
letter_spacing
Inter-letter spacing in 1024ths of a point.
gravity
One of 'south', 'east', 'north', 'west', 'auto'.
gravity_hint
One of 'natural', 'strong', 'line'.
The following convenience tags are provided:
Convenience tags
b
Bold
big
Makes font relatively larger, equivalent to <span
size="larger">
i
Italic
s
Strikethrough
sub
Subscript
sup
Superscript
small
Makes font relatively smaller, equivalent to <span
size="smaller">
tt
Monospace font
u
Underline

加载中…