@@ -52,10 +52,6 @@ def SYSTEM_FONT_NAMES.include?(name)
5252
5353 # set default font
5454 case Tk ::TK_VERSION
55- when /^4\. .*/
56- DEFAULT_LATIN_FONT_NAME = 'a14' . freeze
57- DEFAULT_KANJI_FONT_NAME = 'k14' . freeze
58-
5955 when /^8\. [0-4]/
6056 if JAPANIZED_TK
6157 begin
@@ -122,19 +118,14 @@ def SYSTEM_FONT_NAMES.include?(name)
122118 DEFAULT_LATIN_FONT_NAME = ltn . freeze
123119 DEFAULT_KANJI_FONT_NAME = knj . freeze
124120
125- when /^8 \. [5-9]/ , /^9 \. .*/
121+ else
126122 if tk_call ( 'font' , 'names' ) =~ /\b TkDefaultFont\b /
127123 DEFAULT_LATIN_FONT_NAME = 'TkDefaultFont' . freeze
128124 DEFAULT_KANJI_FONT_NAME = 'TkDefaultFont' . freeze
129125 else
130126 DEFAULT_LATIN_FONT_NAME = 'Helvetica' . freeze
131127 DEFAULT_KANJI_FONT_NAME = 'mincho' . freeze
132128 end
133-
134- else # unknown version
135- DEFAULT_LATIN_FONT_NAME = 'Helvetica' . freeze
136- DEFAULT_KANJI_FONT_NAME = 'mincho' . freeze
137-
138129 end
139130
140131 if $DEBUG
@@ -346,34 +337,15 @@ def TkFont.metrics_hash_displayof(fnt, win, option=nil)
346337 end
347338
348339 def TkFont . families ( win = nil )
349- case ( Tk ::TK_VERSION )
350- when /^4\. .*/
351- [ 'fixed' ]
352-
353- when /^8\. .*/
354- if win
355- tk_split_simplelist ( tk_call ( 'font' , 'families' , '-displayof' , win ) )
356- else
357- tk_split_simplelist ( tk_call ( 'font' , 'families' ) )
358- end
340+ if win
341+ tk_split_simplelist ( tk_call ( 'font' , 'families' , '-displayof' , win ) )
342+ else
343+ tk_split_simplelist ( tk_call ( 'font' , 'families' ) )
359344 end
360345 end
361346
362347 def TkFont . names
363- case ( Tk ::TK_VERSION )
364- when /^4\. .*/
365- r = [ 'fixed' ]
366- r += [ 'a14' , 'k14' ] if JAPANIZED_TK
367- Tk_FontNameTBL . mutex . synchronize {
368- Tk_FontNameTBL . each_value { |obj | r . push ( obj ) }
369- }
370- #r | []
371- r . uniq
372-
373- when /^8\. .*/
374- tk_split_simplelist ( tk_call ( 'font' , 'names' ) )
375-
376- end
348+ tk_split_simplelist ( tk_call ( 'font' , 'names' ) )
377349 end
378350
379351 def TkFont . create_copy ( font )
@@ -406,32 +378,6 @@ def TkFont.init_widget_font(pathname, *args)
406378 path = [ win , tag , key ] . join ( ';' )
407379
408380 case ( Tk ::TK_VERSION )
409- when /^4\. .*/
410- regexp = /^-(|kanji)#{ key } /
411-
412- conf_list = tk_split_simplelist ( tk_call ( *args ) ) .
413- find_all { |prop | prop =~ regexp } .
414- collect { |prop | tk_split_simplelist ( prop ) }
415-
416- if conf_list . size == 0
417- raise RuntimeError , "the widget may not support 'font' option"
418- end
419-
420- args << { }
421-
422- ltn_key = "-#{ key } "
423- knj_key = "-kanji#{ key } "
424-
425- ltn_info = conf_list . find { |conf | conf [ 0 ] == ltn_key }
426- ltn = ltn_info [ -1 ]
427- ltn = nil if ltn == [ ] || ltn == ""
428-
429- knj_info = conf_list . find { |conf | conf [ 0 ] == knj_key }
430- knj = knj_info [ -1 ]
431- knj = nil if knj == [ ] || knj == ""
432-
433- TkFont . new ( ltn , knj ) . call_font_configure ( [ path , key ] , *args )
434-
435381 when /^8\. [0-4]/
436382 regexp = /^-#{ key } /
437383
@@ -479,7 +425,7 @@ def TkFont.init_widget_font(pathname, *args)
479425 end
480426 end
481427
482- when /^8 \. [5-9]/ , /^9 \. .*/
428+ else
483429 regexp = /^-#{ key } /
484430
485431 conf_list = tk_split_simplelist ( tk_call ( *args ) ) .
@@ -527,7 +473,7 @@ def TkFont.used_on(path=nil)
527473
528474 def TkFont . failsafe ( font )
529475 begin
530- if /^8 \. .*/ === Tk :: TK_VERSION && JAPANIZED_TK
476+ if JAPANIZED_TK
531477 tk_call ( 'font' , 'failsafe' , font )
532478 end
533479 rescue
@@ -552,36 +498,23 @@ def init_dummy_fontobj
552498 # @kanji_desscendant = nil
553499 @descendant = [ nil , nil ] # [latin, kanji]
554500
555- case ( Tk ::TK_VERSION )
556- when /^4\. .*/
557- @latinfont = ""
558- @kanjifont = ""
559- if JAPANIZED_TK
560- @compoundfont = [ [ @latinfont ] , [ @kanjifont ] ]
561- @fontslot = { 'font' => @latinfont , 'kanjifont' => @kanjifont }
562- else
563- @compoundfont = @latinfont
564- @fontslot = { 'font' => @latinfont }
565- end
566- else
567- @latinfont = @id + 'l'
568- @kanjifont = @id + 'k'
569- @compoundfont = @id + 'c'
570-
571- if JAPANIZED_TK
572- tk_call ( 'font' , 'create' , @latinfont , '-charset' , 'iso8859' )
573- tk_call ( 'font' , 'create' , @kanjifont , '-charset' , 'jisx0208.1983' )
574- tk_call ( 'font' , 'create' , @compoundfont ,
575- '-compound' , [ @latinfont , @kanjifont ] )
576- else
577- tk_call ( 'font' , 'create' , @latinfont )
578- tk_call ( 'font' , 'create' , @kanjifont )
579- tk_call ( 'font' , 'create' , @compoundfont )
580- end
501+ @latinfont = @id + 'l'
502+ @kanjifont = @id + 'k'
503+ @compoundfont = @id + 'c'
581504
582- @fontslot = { 'font' => @compoundfont }
505+ if JAPANIZED_TK
506+ tk_call ( 'font' , 'create' , @latinfont , '-charset' , 'iso8859' )
507+ tk_call ( 'font' , 'create' , @kanjifont , '-charset' , 'jisx0208.1983' )
508+ tk_call ( 'font' , 'create' , @compoundfont ,
509+ '-compound' , [ @latinfont , @kanjifont ] )
510+ else
511+ tk_call ( 'font' , 'create' , @latinfont )
512+ tk_call ( 'font' , 'create' , @kanjifont )
513+ tk_call ( 'font' , 'create' , @compoundfont )
583514 end
584515
516+ @fontslot = { 'font' => @compoundfont }
517+
585518 self
586519 end
587520
@@ -637,11 +570,7 @@ def initialize(ltn=nil, knj=nil, keys=nil)
637570
638571 if ltn
639572 if JAPANIZED_TK && !knj
640- if Tk ::TK_VERSION =~ /^4..*/
641- knj = DEFAULT_KANJI_FONT_NAME
642- else
643- knj = ltn
644- end
573+ knj = ltn
645574 end
646575 else
647576 ltn = DEFAULT_LATIN_FONT_NAME
@@ -1586,7 +1515,7 @@ def kanji_metrics_hash_displayof(win, option=nil)
15861515
15871516 def reset_pointadjust
15881517 begin
1589- if /^8 \. .*/ === Tk :: TK_VERSION && JAPANIZED_TK
1518+ if JAPANIZED_TK
15901519 configure ( 'pointadjust' => latin_actual . assoc ( 'size' ) [ 1 ] . to_f /
15911520 kanji_actual . assoc ( 'size' ) [ 1 ] . to_f )
15921521 end
@@ -1599,11 +1528,6 @@ def reset_pointadjust
15991528 # private alias
16001529 ###################################
16011530 case ( Tk ::TK_VERSION )
1602- when /^4\. .*/
1603- alias create_latinfont create_latinfont_tk4x
1604- alias create_kanjifont create_kanjifont_tk4x
1605- alias create_compoundfont create_compoundfont_tk4x
1606-
16071531 when /^8\. [0-5]/
16081532 alias create_latinfont create_latinfont_tk8x
16091533 alias create_kanjifont create_kanjifont_tk8x
@@ -2188,41 +2112,15 @@ def metrics_core_tk8x(font, win, option=nil)
21882112 ###################################
21892113 # private alias
21902114 ###################################
2191- case ( Tk ::TK_VERSION )
2192- when /^4\. .*/
2193- alias actual_core actual_core_tk4x
2194- alias configure_core configure_core_tk4x
2195- alias configinfo_core configinfo_core_tk4x
2196- alias current_configinfo_core current_configinfo_core_tk4x
2197- alias delete_core delete_core_tk4x
2198- alias latin_replace_core latin_replace_core_tk4x
2199- alias kanji_replace_core kanji_replace_core_tk4x
2200- alias measure_core measure_core_tk4x
2201- alias metrics_core metrics_core_tk4x
2202-
2203- when /^8\. [0-9]/
2204- alias actual_core actual_core_tk8x
2205- alias configure_core configure_core_tk8x
2206- alias configinfo_core configinfo_core_tk8x
2207- alias current_configinfo_core current_configinfo_core_tk8x
2208- alias delete_core delete_core_tk8x
2209- alias latin_replace_core latin_replace_core_tk8x
2210- alias kanji_replace_core kanji_replace_core_tk8x
2211- alias measure_core measure_core_tk8x
2212- alias metrics_core metrics_core_tk8x
2213-
2214- else
2215- alias actual_core actual_core_tk8x
2216- alias configure_core configure_core_tk8x
2217- alias configinfo_core configinfo_core_tk8x
2218- alias current_configinfo_core current_configinfo_core_tk8x
2219- alias delete_core delete_core_tk8x
2220- alias latin_replace_core latin_replace_core_tk8x
2221- alias kanji_replace_core kanji_replace_core_tk8x
2222- alias measure_core measure_core_tk8x
2223- alias metrics_core metrics_core_tk8x
2224-
2225- end
2115+ alias actual_core actual_core_tk8x
2116+ alias configure_core configure_core_tk8x
2117+ alias configinfo_core configinfo_core_tk8x
2118+ alias current_configinfo_core current_configinfo_core_tk8x
2119+ alias delete_core delete_core_tk8x
2120+ alias latin_replace_core latin_replace_core_tk8x
2121+ alias kanji_replace_core kanji_replace_core_tk8x
2122+ alias measure_core measure_core_tk8x
2123+ alias metrics_core metrics_core_tk8x
22262124end
22272125
22282126class TkFont
0 commit comments