metric_type : default => num_or_str
option_type : default => string
class methods
# File tk/lib/tk/font.rb, line 166 def TkFont.actual(fnt, option=nil) fnt = '{}' if fnt == '' if fnt.kind_of?(TkFont) fnt.actual(option) else actual_core(fnt, nil, option) end end
# File tk/lib/tk/font.rb, line 175 def TkFont.actual_displayof(fnt, win, option=nil) fnt = '{}' if fnt == '' if fnt.kind_of?(TkFont) fnt.actual_displayof(win, option) else win = '.' unless win actual_core(fnt, win, option) end end
# File tk/lib/tk/font.rb, line 194 def TkFont.configinfo(fnt, slot=nil) if fnt.kind_of?(TkFont) fnt.configinfo(fnt, slot) else configinfo_core(fnt, slot) end end
# File tk/lib/tk/font.rb, line 185 def TkFont.configure(fnt, slot, value=None) if fnt.kind_of?(TkFont) fnt.configure(fnt, slot, value) else configure_core(fnt, slot, value) end fnt end
# File tk/lib/tk/font.rb, line 276 def TkFont.create_copy(font) fail 'source-font must be a TkFont object' unless font.kind_of? TkFont if TkComm::GET_CONFIGINFOwoRES_AS_ARRAY keys = {} font.configinfo.each{|key,value| keys[key] = value } TkFont.new(font.latin_font_id, font.kanji_font_id, keys) else # ! TkComm::GET_CONFIGINFOwoRES_AS_ARRAY TkFont.new(font.latin_font_id, font.kanji_font_id, font.configinfo) end end
# File tk/lib/tk/font.rb, line 202 def TkFont.current_configinfo(fnt, slot=nil) if fnt.kind_of?(TkFont) fnt.current_configinfo(fnt, slot) else current_configinfo_core(fnt, slot) end end
# File tk/lib/tk/font.rb, line 380 def TkFont.failsafe(font) begin if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK tk_call('font', 'failsafe', font) end rescue end end
# File tk/lib/tk/font.rb, line 248 def TkFont.families(win=nil) case (Tk::TK_VERSION) when /^4\.*/ ['fixed'] when /^8\.*/ if win tk_split_simplelist(tk_call('font', 'families', '-displayof', win)) else tk_split_simplelist(tk_call('font', 'families')) end end end
# File tk/lib/tk/font.rb, line 287 def TkFont.get_obj(name) if name =~ /^(@font[0-9]+)(|c|l|k)$/ Tk_FontNameTBL[$1] else nil end end
# File tk/lib/tk/font.rb, line 295 def TkFont.init_widget_font(pathname, *args) win, tag, key = pathname.split(';') key = 'font' if key == nil || key == '' path = [win, tag, key].join(';') case (Tk::TK_VERSION) when /^4\.*/ regexp = /^-(|kanji)#{key} / conf_list = tk_split_simplelist(tk_call(*args)). find_all{|prop| prop =~ regexp}. collect{|prop| tk_split_simplelist(prop)} if conf_list.size == 0 raise RuntimeError, "the widget may not support 'font' option" end args << {} ltn_key = "-#{key}" knj_key = "-kanji#{key}" ltn_info = conf_list.find{|conf| conf[0] == ltn_key} ltn = ltn_info[-1] ltn = nil if ltn == [] || ltn == "" knj_info = conf_list.find{|conf| conf[0] == knj_key} knj = knj_info[-1] knj = nil if knj == [] || knj == "" TkFont.new(ltn, knj).call_font_configure([path, key], *args) when /^8\.*/ regexp = /^-#{key} / conf_list = tk_split_simplelist(tk_call(*args)). find_all{|prop| prop =~ regexp}. collect{|prop| tk_split_simplelist(prop)} if conf_list.size == 0 raise RuntimeError, "the widget may not support 'font' option" end args << {} optkey = "-#{key}" info = conf_list.find{|conf| conf[0] == optkey} fnt = info[-1] fnt = nil if fnt == [] || fnt == "" unless fnt # create dummy # TkFont.new(nil, nil).call_font_configure([path, key], *args) dummy_fnt = TkFont.allocate dummy_fnt.instance_eval{ init_dummy_fontobj() } dummy_fnt else begin compound = tk_split_simplelist( Hash[*tk_split_simplelist(tk_call('font', 'configure', fnt))].collect{|k,v| [k[1..-1], v] }.assoc('compound')[1]) rescue compound = [] end if compound == [] TkFont.new(fnt).call_font_configure([path, key], *args) else TkFont.new(compound[0], compound[1]).call_font_configure([path, key], *args) end end end end
# File tk/lib/tk/font.rb, line 210 def TkFont.measure(fnt, text) fnt = '{}' if fnt == '' if fnt.kind_of?(TkFont) fnt.measure(text) else measure_core(fnt, nil, text) end end
# File tk/lib/tk/font.rb, line 219 def TkFont.measure_displayof(fnt, win, text) fnt = '{}' if fnt == '' if fnt.kind_of?(TkFont) fnt.measure_displayof(win, text) else win = '.' unless win measure_core(fnt, win, text) end end
# File tk/lib/tk/font.rb, line 229 def TkFont.metrics(fnt, option=nil) fnt = '{}' if fnt == '' if fnt.kind_of?(TkFont) fnt.metrics(option) else metrics_core(fnt, nil, option) end end
# File tk/lib/tk/font.rb, line 238 def TkFont.metrics_displayof(fnt, win, option=nil) fnt = '{}' if fnt == '' if fnt.kind_of?(TkFont) font.metrics_displayof(win, option=nil) else win = '.' unless win metrics_core(fnt, win, option) end end
# File tk/lib/tk/font.rb, line 262 def TkFont.names case (Tk::TK_VERSION) when /^4\.*/ r = ['fixed'] r += ['a14', 'k14'] if JAPANIZED_TK Tk_FontNameTBL.each_value{|obj| r.push(obj)} r | [] when /^8\.*/ tk_split_simplelist(tk_call('font', 'names')) end end
# File tk/lib/tk/font.rb, line 435 def initialize(ltn=nil, knj=nil, keys=nil) ltn = '{}' if ltn == '' knj = '{}' if knj == '' # @id = Tk_FontID.join('') @id = Tk_FontID.join(TkCore::INTERP._ip_id_) Tk_FontID[1].succ! Tk_FontNameTBL[@id] = self @latin_desscendant = nil @kanji_desscendant = nil if knj.kind_of?(Hash) && !keys keys = knj knj = nil end # compound font check if Tk::TK_VERSION == '8.0' && JAPANIZED_TK begin compound = tk_split_simplelist(tk_call('font', 'configure', ltn, '-compound')) if knj == nil if compound != [] ltn, knj = compound end else if compound != [] ltn = compound[0] end compound = tk_split_simplelist(tk_call('font', 'configure', knj, '-compound')) if compound != [] knj = compound[1] end end rescue end end if ltn if JAPANIZED_TK && !knj if Tk::TK_VERSION =~ /^4.*/ knj = DEFAULT_KANJI_FONT_NAME else knj = ltn end end else ltn = DEFAULT_LATIN_FONT_NAME knj = DEFAULT_KANJI_FONT_NAME if JAPANIZED_TK && !knj end create_compoundfont(ltn, knj, keys) end
# File tk/lib/tk/font.rb, line 1026 def [](slot) configinfo slot end
# File tk/lib/tk/font.rb, line 1030 def []=(slot, val) configure slot, val val end
# File tk/lib/tk/font.rb, line 989 def actual(option=nil) actual_core(@compoundfont, nil, option) end
# File tk/lib/tk/font.rb, line 993 def actual_displayof(win, option=nil) win = '.' unless win actual_core(@compoundfont, win, option) end
# File tk/lib/tk/font.rb, line 871 def call_font_configure(path, *args) if path.kind_of?(Array) # [path, optkey] win, tag = path[0].split(';') optkey = path[1].to_s else win, tag, optkey = path.split(';') end fontslot = _symbolkey2str(@fontslot) if optkey && optkey != "" ltn = fontslot.delete('font') knj = fontslot.delete('kanjifont') fontslot[optkey] = ltn if ltn fontslot["kanji#{optkey}"] = knj if knj end keys = _symbolkey2str(args.pop).update(fontslot) args.concat(hash_kv(keys)) tk_call(*args) Tk_FontUseTBL[[win, tag, optkey].join(';')] = self self end
# File tk/lib/tk/font.rb, line 1040 def configinfo(slot=nil) configinfo_core(@compoundfont, slot) end
# File tk/lib/tk/font.rb, line 1035 def configure(slot, value=None) configure_core(@compoundfont, slot, value) self end
# File tk/lib/tk/font.rb, line 1044 def current_configinfo(slot=nil) current_configinfo_core(@compoundfont, slot) end
# File tk/lib/tk/font.rb, line 956 def font @compoundfont end
# File tk/lib/tk/font.rb, line 843 def inspect sprintf("#<%s:%0x:%s>", self.class.inspect, self.__id__, @compoundfont) end
# File tk/lib/tk/font.rb, line 1007 def kanji_actual(option=nil) #if JAPANIZED_TK if @kanjifont != "" actual_core(@kanjifont, nil, option) else actual_core_tk4x(nil, nil, option) end end
# File tk/lib/tk/font.rb, line 1016 def kanji_actual_displayof(win, option=nil) #if JAPANIZED_TK if @kanjifont != "" win = '.' unless win actual_core(@kanjifont, win, option) else actual_core_tk4x(nil, win, option) end end
# File tk/lib/tk/font.rb, line 1081 def kanji_configinfo(slot=nil) #if JAPANIZED_TK if @kanjifont != "" configinfo_core(@kanjifont, slot) else #[] configinfo(slot) end end
# File tk/lib/tk/font.rb, line 1069 def kanji_configure(slot, value=None) #if JAPANIZED_TK if @kanjifont != "" configure_core(@kanjifont, slot, value) configure('size'=>configinfo('size')) # to reflect new configuration else #"" configure(slot, value) end self end
# File tk/lib/tk/font.rb, line 979 def kanji_font # @kanjifont if @kanji_descendant @kanji_descendant else @kanji_descendant = DescendantFont.new(self, 'kanji') end end
# File tk/lib/tk/font.rb, line 975 def kanji_font_id @kanjifont end
# File tk/lib/tk/font.rb, line 1137 def kanji_metrics(option=nil) if JAPANIZED_TK metrics_core(@kanjifont, nil, option) else metrics_core_tk4x(nil, nil, option) end end
# File tk/lib/tk/font.rb, line 1145 def kanji_metrics_displayof(win, option=nil) if JAPANIZED_TK win = '.' unless win metrics_core(@kanjifont, win, option) else metrics_core_tk4x(nil, win, option) end end
# File tk/lib/tk/font.rb, line 1104 def kanji_replace(knj) kanji_replace_core(knj) reset_pointadjust self end
# File tk/lib/tk/font.rb, line 998 def latin_actual(option=nil) actual_core(@latinfont, nil, option) end
# File tk/lib/tk/font.rb, line 1002 def latin_actual_displayof(win, option=nil) win = '.' unless win actual_core(@latinfont, win, option) end
# File tk/lib/tk/font.rb, line 1061 def latin_configinfo(slot=nil) if JAPANIZED_TK configinfo_core(@latinfont, slot) else configinfo(slot) end end
# File tk/lib/tk/font.rb, line 1052 def latin_configure(slot, value=None) if JAPANIZED_TK configure_core(@latinfont, slot, value) else configure(slot, value) end self end
# File tk/lib/tk/font.rb, line 965 def latin_font # @latinfont if @latin_descendant @latin_descendant else @latin_descendant = DescendantFont.new(self, 'latin') end end
# File tk/lib/tk/font.rb, line 961 def latin_font_id @latinfont end
# File tk/lib/tk/font.rb, line 1128 def latin_metrics(option=nil) metrics_core(@latinfont, nil, option) end
# File tk/lib/tk/font.rb, line 1132 def latin_metrics_displayof(win, option=nil) win = '.' unless win metrics_core(@latinfont, win, option) end
# File tk/lib/tk/font.rb, line 1098 def latin_replace(ltn) latin_replace_core(ltn) reset_pointadjust self end
# File tk/lib/tk/font.rb, line 1110 def measure(text) measure_core(@compoundfont, nil, text) end
# File tk/lib/tk/font.rb, line 1114 def measure_displayof(win, text) win = '.' unless win measure_core(@compoundfont, win, text) end
# File tk/lib/tk/font.rb, line 847 def method_missing(id, *args) name = id.id2name case args.length when 1 if name[-1] == ?= configure name[0..-2], args[0] args[0] else configure name, args[0] self end when 0 begin configinfo name rescue super(id, *args) # fail NameError, "undefined local variable or method `#{name}' for #{self.to_s}", error_at end else super(id, *args) # fail NameError, "undefined method `#{name}' for #{self.to_s}", error_at end end
# File tk/lib/tk/font.rb, line 1119 def metrics(option=nil) metrics_core(@compoundfont, nil, option) end
# File tk/lib/tk/font.rb, line 1123 def metrics_displayof(win, option=nil) win = '.' unless win metrics_core(@compoundfont, win, option) end
# File tk/lib/tk/font.rb, line 1091 def replace(ltn, knj=None) knj = ltn if knj == None latin_replace(ltn) kanji_replace(knj) self end
# File tk/lib/tk/font.rb, line 1154 def reset_pointadjust begin if /^8\.*/ === Tk::TK_VERSION && JAPANIZED_TK configure('pointadjust' => latin_actual.assoc('size')[1].to_f / kanji_actual.assoc('size')[1].to_f ) end rescue end self end
# File tk/lib/tk/font.rb, line 895 def used ret = [] Tk_FontUseTBL.each{|key,value| next unless self == value if key.include?(';') win, tag, optkey = key.split(';') winobj = tk_tcl2ruby(win) if winobj.kind_of? TkText if optkey ret.push([winobj, winobj.tagid2obj(tag), optkey]) else ret.push([winobj, winobj.tagid2obj(tag)]) end elsif winobj.kind_of? TkCanvas if (tagobj = TkcTag.id2obj(winobj, tag)).kind_of? TkcTag if optkey ret.push([winobj, tagobj, optkey]) else ret.push([winobj, tagobj]) end elsif (tagobj = TkcItem.id2obj(winobj, tag)).kind_of? TkcItem if optkey ret.push([winobj, tagobj, optkey]) else ret.push([winobj, tagobj]) end else if optkey ret.push([winobj, tag, optkey]) else ret.push([winobj, tag]) end end elsif winobj.kind_of? TkMenu if optkey ret.push([winobj, tag, optkey]) else ret.push([winobj, tag]) end else if optkey ret.push([win, tag, optkey]) else ret.push([win, tag]) end end else ret.push(tk_tcl2ruby(key)) end } ret end