FontButton

日本語

FontButton opens the native font chooser and reports a FontDescriptor.

Appearance

FontButton on Ubuntu
Ubuntu
FontButton on Windows
Windows
FontButton on macOS
macOS

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 do
  on_changed do |font_descriptor|
    window.msg_box("Font Changed", "Family: #{font_descriptor.family}\nSize: #{font_descriptor.size}")
  end
end

window.child = font_button
window.show

UIng.main
UIng.uninit

Usage notes

  • Handle a new choice with on_changed.
  • Use the descriptor inside the callback or the block-based font helper.

API reference · Gallery source