ui.fontdialog([widget], [color])

Displays a dialog box for the user to choose a Windows system font.

Parameters

widget

An optional widget whose font will initialize dialog's fields.
If an Edit widget is provided, the current selection font is used to initialize dialog's fields.

color

An optional number representing a RGB color value, to initialize the dialog color field.

Return value

If a font selection has been made, this function returns four values which correspond to the characteristics of the selected font :
  • The font name as a string.
  • The font size as a number.
  • The font style as a table with boolean fields "italic", "underline", "striked", "bold", "thin", "heavy".
  • The font color as a number.
If the user clicked on the Cancel button, this function returns nil.

Example

local ui = require "ui" -- open a dialog to choose a font local name, size, style, color = ui.fontdialog() -- check if a font have been choosen if name ~= " " then -- output font characteristics local msg = "Font name : "..name.."\nFont size : "..size.."\nFont color : "..string.format("%X", color).."\nFont style :" for k, v in pairs(style) do if v then msg = msg.." ["..k.."]" end end ui.info(msg) end