diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-07-12 14:44:18 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2020-07-12 14:44:18 (GMT) |
commit | c1b6abf51d0a94a1ef77c7119af5deddd62e1d16 (patch) | |
tree | 3085d69114f2fa65f4bc148a5062601c80283be7 /library/fontchooser.tcl | |
parent | 8a4797c9a16ff548b9d7a02b28ac8df76bdb2ff0 (diff) | |
download | tk-c1b6abf51d0a94a1ef77c7119af5deddd62e1d16.zip tk-c1b6abf51d0a94a1ef77c7119af5deddd62e1d16.tar.gz tk-c1b6abf51d0a94a1ef77c7119af5deddd62e1d16.tar.bz2 |
Fix [2442314]: Fontchooser - use message catalog for font style.
Diffstat (limited to 'library/fontchooser.tcl')
-rw-r--r-- | library/fontchooser.tcl | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/library/fontchooser.tcl b/library/fontchooser.tcl index 5395acb..0510fb9 100644 --- a/library/fontchooser.tcl +++ b/library/fontchooser.tcl @@ -14,11 +14,11 @@ namespace eval ::tk::fontchooser { set S(W) .__tk__fontchooser set S(fonts) [lsort -dictionary [font families]] set S(styles) [list \ - [::msgcat::mc "Regular"] \ - [::msgcat::mc "Italic"] \ - [::msgcat::mc "Bold"] \ - [::msgcat::mc "Bold Italic"] \ - ] + [::msgcat::mc "Regular"] \ + [::msgcat::mc "Italic"] \ + [::msgcat::mc "Bold"] \ + [::msgcat::mc "Bold Italic"] \ + ] set S(sizes) {8 9 10 11 12 14 16 18 20 22 24 26 28 36 48 72} set S(strike) 0 @@ -36,9 +36,9 @@ proc ::tk::fontchooser::Setup {} { # Canonical versions of font families, styles, etc. for easier searching set S(fonts,lcase) {} - foreach font $S(fonts) { lappend S(fonts,lcase) [string tolower $font]} + foreach font $S(fonts) {lappend S(fonts,lcase) [string tolower $font]} set S(styles,lcase) {} - foreach style $S(styles) { lappend S(styles,lcase) [string tolower $style]} + foreach style $S(styles) {lappend S(styles,lcase) [string tolower $style]} set S(sizes,lcase) $S(sizes) ::ttk::style layout FontchooserFrame { @@ -145,10 +145,13 @@ proc ::tk::fontchooser::Create {} { wm title $S(W) $S(-title) wm transient $S(W) [winfo toplevel $S(-parent)] + set scaling [tk scaling] + set sizeWidth [expr {int([string length [::msgcat::mc "&Size:"]] * $scaling)}] + set outer [::ttk::frame $S(W).outer -padding {10 10}] ::tk::AmpWidget ::ttk::label $S(W).font -text [::msgcat::mc "&Font:"] ::tk::AmpWidget ::ttk::label $S(W).style -text [::msgcat::mc "Font st&yle:"] - ::tk::AmpWidget ::ttk::label $S(W).size -text [::msgcat::mc "&Size:"] + ::tk::AmpWidget ::ttk::label $S(W).size -text [::msgcat::mc "&Size:"] -width $sizeWidth ttk::entry $S(W).efont -width 18 \ -textvariable [namespace which -variable S](font) ttk::entry $S(W).estyle -width 10 \ @@ -199,7 +202,7 @@ proc ::tk::fontchooser::Create {} { set minsize(sizes) \ [expr {[font measure TkDefaultFont "-99"] + $scroll_width}] set min [expr {$minsize(gap) * 4}] - foreach {what width} [array get minsize] { incr min $width } + foreach {what width} [array get minsize] {incr min $width} wm minsize $S(W) $min 260 bind $S(W) <Return> [namespace code [list Done 1]] @@ -327,13 +330,13 @@ proc ::tk::fontchooser::Init {{defaultFont ""}} { set S(size) $F(-size) set S(strike) $F(-overstrike) set S(under) $F(-underline) - set S(style) "Regular" + set S(style) [::msgcat::mc "Regular"] if {$F(-weight) eq "bold" && $F(-slant) eq "italic"} { - set S(style) "Bold Italic" + set S(style) [::msgcat::mc "Bold Italic"] } elseif {$F(-weight) eq "bold"} { - set S(style) "Bold" + set S(style) [::msgcat::mc "Bold"] } elseif {$F(-slant) eq "italic"} { - set S(style) "Italic" + set S(style) [::msgcat::mc "Italic"] } set S(first) 0 @@ -396,7 +399,7 @@ proc ::tk::fontchooser::Tracer {var1 var2 op} { } $S(W).l${var}s see $n } - if {!$bad} { Update } + if {!$bad} {Update} $S(W).ok configure -state $nstate } @@ -408,11 +411,11 @@ proc ::tk::fontchooser::Update {} { variable S set S(result) [list $S(font) $S(size)] - if {$S(style) eq "Bold"} { lappend S(result) bold } - if {$S(style) eq "Italic"} { lappend S(result) italic } - if {$S(style) eq "Bold Italic"} { lappend S(result) bold italic} - if {$S(strike)} { lappend S(result) overstrike} - if {$S(under)} { lappend S(result) underline} + if {$S(style) eq [::msgcat::mc "Bold"]} {lappend S(result) bold} + if {$S(style) eq [::msgcat::mc "Italic"]} {lappend S(result) italic} + if {$S(style) eq [::msgcat::mc "Bold Italic"]} {lappend S(result) bold italic} + if {$S(strike)} {lappend S(result) overstrike} + if {$S(under)} {lappend S(result) underline} $S(sample) configure -font $S(result) } |