Expression qt.QFont(arg) returns a new font object.
Argument arg may be a string previously returned
by qfont:tostring() or
a table whose fields specify the desired font characteristics.
The following fields are recognized, listed in order of priority:
family may contain a comma
separated list of the desired font families.
sans to true indicates
a preference for sans serif font families such as "Helvetica".
This is more portable than specifying a family.
serif to true indicates
a preference for serif font families such as "Times".
This is more portable than specifying a family.
typewriter to true
indicates a preference for a fixed width font families
such as "Courier".
This is more portable than specifying a family.
size specify the desired size of the font.
The default size is 10 points.
pixelSize and pointSize also
indicates the desired size of the font. Field pixelSize
is an alias for size. Field pointSize includes a correction
factor corresponding to the actual resolution of the target device.
weight defines the weight of the font.
Weight 50 corresponds to a normal font and weight 75 corresponds
to a bold font.
stretch is a percentage applied to the
width of all characters. Value 100 corresponds to a normal width.
Value 150 increases all width by 50 percent.
bold to true requests a bold font
if the selected font family defines a bold variant.
italic to true requests and italic font
if the selected font family defines an italic or oblique variant.
fixedPitch to true requests a fixed pitch
font if the selected font family defines such a variant (rare).
underline to true draws a line
below all the character at a font-specified position.
overline to true draws a line
above all the character at a font-specified position.
strikeOut to true draws a line
that crosses the character at a font-specified position.
Example:
require 'qtwidget'
w=qtwidget.newwindow(300,300)
w:moveto(20,20)
w:setfont(qt.QFont{serif=true,size=12,italic=true})
w:show("foo")
w:setfont(qt.QFont{serif=true,size=12,italic=true,underline=true})
w:setcolor("blue")
w:show("bar")