If you need to set the font of the control frequently.
Then there are two options:
1, use GUI.SetFont, but this will lose the default font
2, use Control.SetFont, but will cause the display to be abnormal. For example:
Code: Select all
Gui:=GuiCreate()
t:=Gui.addtext("x1 y0","aasdfsadgsdf")
s:=Gui.addtext("x1 y222","aasdfsadgsdf")
Gui.show("w444 h444")
Sleep(500)
t.SetFont("s24")
s.SetFont("s34")
MsgBox
So, can we add a more concise and direct way?
For example:
Code: Select all
hfont:={size:22,italic:1}
Gui.addtext("f" hfont " x1 y0","aasdfsadgsdf")
CreateFont(obj){
static gs:=getdevicecaps(getdc(0), 90 ),this:={"width":[4, "uint"],"escapement":[8, "uint"],"orientation":[12, "uint"],"italic":[20, "uchar"],"underline":[21, "uchar"]
,"strike":[22, "uchar"],"outprecision":[24, "uchar"],"clipprecision":[25, "uchar"],"pitchandfamily":[27, "uchar"],"charset":[23, "uchar"],"quality":[26, "uchar"]}
varsetcapacity(logfont, 92, 0)
rtlmovememory(&logfont, &pum_logfont, 92)
if objhaskey( obj, "size" )
numput( -muldiv( abs(obj.delete("size")), gs, 72 ),logfont, 0, "int" )
if objhaskey( obj, "name" )
strput(obj.delete("name"), &logfont + 28, 32, "utf-16")
if objhaskey( obj, "bold" )
NumPut(obj.delete("bold")?700:400, &LOGFONT,16, uint)
for i,n in obj
s:=this[i],NumPut(n, &LOGFONT, s.1, s.2)
return CreateFontIndirect( &logfont )
}