class Tk::Font
Create and inspect fonts. The font command provides several facilities for dealing with fonts, such as defining named fonts and inspecting the actual attributes of a font.
Constants
- FONT_CONFIGURE_HINTS
Public Class Methods
actual(font, options = {})
click to toggle source
NOTE:
the signature has been simplified to a required +font+ argument and a simple +options+ hash. The original signature is: `font actual font ?-displayof window? ?option? ?--? ?char?` But it just makes things very painful.
@options
:displayof window :char char :option name
# File lib/ffi-tk/command/font.rb, line 72 def self.actual(font, options = {}) window = options.fetch(:displayof, None) option = options.fetch(:option, None) char = options.fetch(:char, None) args = [] args << '-displayof' << window unless window == None args << option.to_tcl_option unless option == None args << '--' << char.to_tcl unless char == None array = execute(:actual, font, *args) array.tcl_options_to_hash(FONT_CONFIGURE_HINTS) end
configure(fontname, argument = None)
click to toggle source
# File lib/ffi-tk/command/font.rb, line 86 def self.configure(fontname, argument = None) Configure.common( self, [:configure, fontname], argument, FONT_CONFIGURE_HINTS ) end
create(fontname, options = None)
click to toggle source
# File lib/ffi-tk/command/font.rb, line 92 def self.create(fontname, options = None) if fontname.respond_to?(:to_tcl_options) options = fontname fontname = None options = options.to_tcl_options end execute(:create, fontname, options)&.to_str end
delete(*fontnames)
click to toggle source
# File lib/ffi-tk/command/font.rb, line 102 def self.delete(*fontnames) execute(:delete, *fontnames) end
execute(command, *args)
click to toggle source
# File lib/ffi-tk/command/font.rb, line 54 def self.execute(command, *args) Tk.execute(:font, command, *args) end
execute_only(command, *args)
click to toggle source
# File lib/ffi-tk/command/font.rb, line 58 def self.execute_only(command, *args) Tk.execute_only(:font, command, *args) end
families(options = {})
click to toggle source
The return value is a list of the case-insensitive names of all font families that exist on window's display. If the window argument is omitted, it defaults to the main window.
# File lib/ffi-tk/command/font.rb, line 109 def self.families(options = {}) execute(:families, options.to_tcl_options) end
measure(font, text, options = {})
click to toggle source
# File lib/ffi-tk/command/font.rb, line 113 def self.measure(font, text, options = {}) execute(:measure, font, options.to_tcl_options, text) end
metrics(font, option, options = {})
click to toggle source
# File lib/ffi-tk/command/font.rb, line 117 def self.metrics(font, option, options = {}) execute(:metrics, font, options.to_tcl_options, option.to_tcl_option) end
names()
click to toggle source
The return value is a list of all the named fonts that are currently defined.
# File lib/ffi-tk/command/font.rb, line 123 def self.names execute(:names).to_a end
new(string_or_hash)
click to toggle source
# File lib/ffi-tk/command/font.rb, line 7 def initialize(string_or_hash) if string_or_hash.respond_to?(:to_str) string_or_hash =~ /^(.*)\s+(\d+)?$/ params = {} params[:family] = Regexp.last_match(1).to_s params[:size] = Regexp.last_match(2).to_i if Regexp.last_match(2) @font = Font.create(params) elsif string_or_hash.respond_to?(:to_hash) @font = Font.create(string_or_hash) else raise ArgumentError end end
Public Instance Methods
actual(options = {})
click to toggle source
# File lib/ffi-tk/command/font.rb, line 23 def actual(options = {}) Font.actual(@font, options) end
actual_hash(options = {})
click to toggle source
# File lib/ffi-tk/command/font.rb, line 27 def actual_hash(options = {}) Font.actual(@font, options) end
configure(argument = None)
click to toggle source
# File lib/ffi-tk/command/font.rb, line 39 def configure(argument = None) Font.configure(@font, argument) end
measure(text, options = {})
click to toggle source
# File lib/ffi-tk/command/font.rb, line 31 def measure(text, options = {}) Font.measure(@font, text, options) end
metrics(option, options = {})
click to toggle source
# File lib/ffi-tk/command/font.rb, line 35 def metrics(option, options = {}) Font.metrics(@font, option, options) end
to_tcl()
click to toggle source
# File lib/ffi-tk/command/font.rb, line 43 def to_tcl TclString.new(@font) end