FontButton
FontButton opens the native font chooser and reports a FontDescriptor.
Appearance
Runnable example
require "uing"
UIng.init
window = UIng::Window.new("FontButton Example", 300, 100, margined: true)
window.on_closing do
UIng.quit
true
end
font_button = UIng::FontButton.new
selected_font = font_button.font
font_button.on_changed do |font_descriptor|
previous_font = selected_font
selected_font = font_descriptor
window.msg_box(
"Font Changed",
"Previous: #{previous_font.family}\nFamily: #{selected_font.family}\nSize: #{selected_font.size}"
)
end
window.child = font_button
window.show
UIng.main
UIng.uninit
Usage notes
fontreturns the currently selectedFontDescriptor.- Handle a new choice with
on_changed. Its descriptor can be retained after the callback. - The block-based
fontform is also available. None of these descriptors needsfree.


