summaryrefslogtreecommitdiffstats
path: root/library/demos/unicodeout.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'library/demos/unicodeout.tcl')
-rw-r--r--library/demos/unicodeout.tcl62
1 files changed, 50 insertions, 12 deletions
diff --git a/library/demos/unicodeout.tcl b/library/demos/unicodeout.tcl
index ec0b7d0..11cc933 100644
--- a/library/demos/unicodeout.tcl
+++ b/library/demos/unicodeout.tcl
@@ -7,6 +7,28 @@ if {![info exists widgetDemo]} {
error "This script should be run from the \"widget\" demo."
}
+package require Tk
+
+# On Windows, we need to determine whether the font system will render
+# right-to-left text.
+
+if {[tk windowingsystem] eq {win32}} {
+ set rkey [join {
+ HKEY_LOCAL_MACHINE
+ SOFTWARE
+ Microsoft
+ {Windows NT}
+ CurrentVersion
+ LanguagePack
+ } \\]
+ set w32langs {}
+ if {![catch {package require registry}]} {
+ if {[catch {registry values $rkey} w32langs]} {
+ set w32langs {}
+ }
+ }
+}
+
set w .unicodeout
catch {destroy $w}
toplevel $w
@@ -14,7 +36,7 @@ wm title $w "Unicode Label Demonstration"
wm iconname $w "unicodeout"
positionWindow $w
-label $w.msg -font $font -wraplength 4i -justify left \
+label $w.msg -font $font -wraplength 4i -anchor w -justify left \
-text "This is a sample of Tk's support for languages that use\
non-Western character sets. However, what you will actually see\
below depends largely on what character sets you have installed,\
@@ -24,11 +46,9 @@ label $w.msg -font $font -wraplength 4i -justify left \
portable fashion."
pack $w.msg -side top
-frame $w.buttons
-pack $w.buttons -side bottom -fill x -pady 2m
-button $w.buttons.dismiss -text Dismiss -command "destroy $w"
-button $w.buttons.code -text "See Code" -command "showCode $w"
-pack $w.buttons.dismiss $w.buttons.code -side left -expand 1
+## See Code / Dismiss buttons
+set btns [addSeeDismiss $w.buttons $w]
+pack $btns -side bottom -fill x
pack [label $w.wait -text "Please wait while loading fonts..." \
-font {Helvetica 12 italic}]
@@ -53,17 +73,35 @@ set oldCursor [$w cget -cursor]
$w conf -cursor watch
update
-addSample $w Arabic \
- "\uFE94\uFEF4\uFE91\uFEAE\uFECC\uFEDF\uFE8D\uFE94" \
- "\uFEE4\uFEE0\uFEDC\uFEDF\uFE8D"
+if {[tk windowingsystem] eq {x11}
+ || (([tk windowingsystem] eq {win32}) && ({ARABIC} ni $w32langs))} {
+ # Using presentation forms (pre-layouted)
+ addSample $w Arabic \
+ "\uFE94\uFEF4\uFE91\uFEAE\uFECC\uFEDF\uFE8D " \
+ "\uFE94\uFEE4\uFEE0\uFEDC\uFEDF\uFE8D"
+} else {
+ # Using standard text characters
+ addSample $w Arabic \
+ "\u0627\u0644\u0643\u0644\u0645\u0629 " \
+ "\u0627\u0644\u0639\u0631\u0628\u064A\u0629"
+}
addSample $w "Trad. Chinese" "\u4E2D\u570B\u7684\u6F22\u5B57"
addSample $w "Simpl. Chinese" "\u6C49\u8BED"
addSample $w Greek \
"\u0395\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AE " \
"\u03B3\u03BB\u03CE\u03C3\u03C3\u03B1"
-addSample $w Hebrew \
- "\u05DD\u05D9\u05DC\u05E9\u05D5\u05E8\u05D9 " \
- "\u05DC\u05D9\u05D0\u05E8\u05E9\u05D9"
+if {[tk windowingsystem] eq {x11}
+ || (([tk windowingsystem] eq {win32}) && ({HEBREW} ni $w32langs))} {
+ # Visual order (pre-layouted)
+ addSample $w Hebrew \
+ "\u05EA\u05D9\u05E8\u05D1\u05E2 " \
+ "\u05D1\u05EA\u05DB"
+} else {
+ # Standard logical order
+ addSample $w Hebrew \
+ "\u05DB\u05EA\u05D1 " \
+ "\u05E2\u05D1\u05E8\u05D9\u05EA"
+}
addSample $w Japanese \
"\u65E5\u672C\u8A9E\u306E\u3072\u3089\u304C\u306A, " \
"\u6F22\u5B57\u3068\u30AB\u30BF\u30AB\u30CA"