Any change in the Label.font, Label.fontstyle and Label.fontsize properties results in an automatic resizing of the Label so that the content is displayed correctly
Label.fontstyle read/write property
Get or set the Label font style, a table value that contains the following keys/values :
- "italic" : set to true if the font is in italic.
- "underline" : set to true if the font is underlined.
- "strike" : set to true if the font is
striked. - "thin" : set to true if the font is thin.
- "bold" : set to true if the font is bold.
- "heavy" : set to true if the font is heavy.
Example
local ui = require "ui"
-- create a simple Window
local win = ui.Window("Label.fontstyle sample", 320, 200)
local label = ui.Label(win, "LuaRT", 110, 100)
-- create a combobox
local cb = ui.Combobox(win, 100, 30)
cb.items = { "bold", "italic", "underline", "heavy", "thin" }
-- change label.fontstyle upon selection
function cb:onSelect(item)
label.fontstyle = { [item.text] = true }
end
label.font = "Times New Roman"
label.fontsize = 24
win:show()
-- update the user interface until the user closes the Window
repeat
ui.update()
until not win.visible