设置文本字体要用到Font
它的常用属性如下
id
用于标识Font,类型:INT
name
用于指定字体名称,类型:STRING
size
用于指定字体大小,类型:INT
bold
用于指定是否加粗,类型:BOOL,默认值为false
underline
用于指定是否添加下划线,类型:BOOL,默认值为false
italic
用于指定是否将字体设为斜体,类型:BOOL,默认值为false
default
用于指定是否将该Font设为全局默认字体,类型:BOOL,默认值为false
注意
Font必须置于根元素Window内
示例
<?xml version="1.0" encoding="utf-8"?> <Window size="350,250" caption="0,0,0,35" sizebox="6,6,6,6" mininfo="300,200"> <Font id="0" name="宋体" size="17" bold="true" underline="true" italic="true" /> <!--窗口背景色#FFFFFFFF--> <VerticalLayout bkcolor="#FFFFFFFF"> <!--标题栏高度35,背景色#FF12B7F5--> <HorizontalLayout height="35" bkcolor="#FF12B7F5"> <Control bkimage="file=‘Icons/wolf_white_55x30.png‘ source=‘0,0,55,30‘ dest=‘0,3,55,33‘" float="true" pos="15,3,70,33" /> <!--标题DuiLib演示--> <Label text="DuiLib演示" textcolor="#FFFFFFFF" font="0" float="true" pos="75,0,200,35" /> <!--空白区--> <Control /> <HorizontalLayout width="90"> <!--最小化、最大化等按钮--> <Button name="minbtn" float="true" pos="5,8,25,28" tooltip="最小化" normalimage="file=‘Icons/minimize/minimize_white_20x20.png‘" hotimage="file=‘Icons/minimize/minimize_red_20x20.png‘" pushedimage="file=‘Icons/minimize/minimize_black_20x20.png‘" /> <Button name="maxbtn" float="true" pos="35,8,55,28" tooltip="最大化" normalimage="file=‘Icons/maximize/maximize_white_20x20.png‘" hotimage="file=‘Icons/maximize/maximize_red_20x20.png‘" pushedimage="file=‘Icons/maximize/maximize_black_20x20.png‘" /> <Button name="restorebtn" float="true" pos="35,8,55,28" tooltip="还原" visible="false" normalimage="file=‘Icons/restore_down/restore_down_white_20x20.png‘" hotimage="file=‘Icons/restore_down/restore_down_red_20x20.png‘" pushedimage="file=‘Icons/restore_down/restore_down_black_20x20.png‘" /> <Button name="closebtn" float="true" pos="65,8,85,28" tooltip="关闭" normalimage="file=‘Icons/close/close_white_20x20.png‘" hotimage="file=‘Icons/close/close_red_20x20.png‘" pushedimage="file=‘Icons/close/close_black_20x20.png‘" /> </HorizontalLayout> </HorizontalLayout> <!--居中的按钮--> <Button name="button" text="自由不是免费的。" pos="-65,-15,65,15" float="0.5,0.5,0.5,0.5" /> </VerticalLayout> </Window>
原文:https://www.cnblogs.com/buyishi/p/10417530.html