From 2562004338bc2694a7d8da75f4effcb9aa889641 Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 29 Jul 1998 09:50:58 +0000 Subject: sync ev git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@280 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/tkfont.rb | 46 +++++++++++++++++++++++++++++----------------- 1 file changed, 29 insertions(+), 17 deletions(-) (limited to 'lib/tkfont.rb') diff --git a/lib/tkfont.rb b/lib/tkfont.rb index 9c2f4c1b66..1c11f8f842 100644 --- a/lib/tkfont.rb +++ b/lib/tkfont.rb @@ -42,7 +42,7 @@ class TkFont r | [] when /^8\.*/ - list(tk_call('font', 'names')) + tk_split_simplelist(tk_call('font', 'names')) end end @@ -89,10 +89,14 @@ class TkFont if fnt == [] TkFont.new(nil, nil).call_font_configure(path, *(args + [{}])) else - compound = Hash[*list(tk_call('font', 'configure', - fnt))].collect{|key,value| - [key[1..-1], value] - }.assoc('compound')[1] + begin + compound = Hash[*list(tk_call('font', 'configure', + fnt))].collect{|key,value| + [key[1..-1], value] + }.assoc('compound')[1] + rescue + compound = [] + end if compound == [] TkFont.new(fnt, DEFAULT_KANJI_FONT_NAME) \ .call_font_configure(path, *(args + [{}])) @@ -156,14 +160,19 @@ class TkFont elsif font.kind_of? Array finfo = {} finfo['family'] = font[0].to_s - if font[1] && font[1] != '0' && font[1] =~ /^(|\+|-)([0-9]+)$/ - if $1 == '-' - finfo['pixels'] = font[1].to_s + if font[1] + fsize = font[1].to_s + if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/ + if $1 == '-' + finfo['pixels'] = $2 + else + finfo['points'] = $2 + end else - finfo['points'] = font[1].to_s + finfo['points'] = '13' end end - finfo[2..-1].each{|style| + font[2..-1].each{|style| case (style) when 'normal' finfo['weight'] = style @@ -199,16 +208,19 @@ class TkFont elsif font.kind_of? Array finfo = {} finfo['family'] = font[0].to_s - if font[1] && font[1] != '0' && font[1] =~ /^(|\+|-)([0-9]+)$/ - if $1 == '-' - finfo['pixels'] = $2 + if font[1] + fsize = font[1].to_s + if fsize != '0' && fsize =~ /^(|\+|-)([0-9]+)$/ + if $1 == '-' + finfo['pixels'] = $2 + else + finfo['points'] = $2 + end else - finfo['points'] = $2 + finfo['points'] = '13' end - else - finfo['points'] = '13' end - finfo[2..-1].each{|style| + font[2..-1].each{|style| case (style) when 'normal' finfo['weight'] = style -- cgit v1.2.3