Mongolian in Tcl strimjes

"You name it - Tcl can do it!" Richard Suchenwirth 2001-08-09 - The Mongolian alphabet was derived from Uighur in the 13th century and is special in that it always goes in vertical top-down lines, the lines running from left to right. In the Mongolian People's Republic it was replaced in 1946 by the Cyrillic alphabet, but in China's autonomous region Inner Mongolia it is still used, and so for instance visible on every Chinese banknote. Also, the Mongolian PR is said to have reintroduced the traditional alphabet since 1990. How this will work on computer i18n remains to be seen - all window titlebars, menus etc. would have to have x and y coordinates swapped...

Here's a study how to render Mongolian into strimjes - one proc (that takes care of vertical concatenation, which is trivial with append, and spelling rules) and one font. The output of strimj::monglish can be turned into a bitmap or photo image, and thus inserted in most Tk widgets. This is just a first shot, the font is also far from complete, but in the tester that runs if you execute this file (and have the file strimj.tcl from strimj - string image routines in the working directory), a command like

 strimj::monglish "mongGoL tolI"

already produces quite faithfully the words for "Mongolian dictionary" - any Tcl'ers in Inner Mongolia to verify? The "Monglish" in the entry widget is rendered on <Return> to the text widget, in original size plus zoomed by factor 2, so you can experiment. Enjoy!

WikiDbImage mongolian.jpg

# See http://www.omniglot.com/writing/mongolian.htm

 if {[file tail [info script]]==[file tail $argv0]} {source strimj.tcl}

 proc strimj::monglish s {
    regsub -all {([aeio])n([^aeio])} $s {\1a\2} s
    set si ""
    foreach char [split $s ""] {
        append si \n[expand [char $char Mongolian]]
    }
    set si
 }
 strimj::font Mongolian {
 a {
 ..#####
 .....##
 .....##
 } A {
 ...##
 .##
 ...####
 .......#####
 } b {
 ..########
 .#...##...#
 ..#####...##
 .........##
 .......##
 } c {
 ..#..##
 ..#..##
 .######
 #.#..##
 .#...##
 } f {
 #.########
 ##...##...#
 ..#####...##
 .........##
 .......##
 } g {
 ...#####
 .###....##
 .......##
 .....##
 } G {
 ##.####
 .....##
 ##.####
 .....##
 .....##
 } i {
 ....###
 ...#.##
 ..#..##
 .....##
 } I {
 ...#####
 ..##....##
 .......##
 ....###
 } l {
 .....##..##
 .....##..#
 ..########
 .....##
 } L {
 ....###
 ..##.....##
 ....###..#
 .......##
 } m {
 .##########
 .....##...#
 .....##...##
 } n {
 .....##
 #.#####
 .....##
 .....##
 } o {
 ..#####
 .#...##
 ..#####
 .....##
 } p {
 .##..#####
 .#...##...#
 ..#####...##
 .........##
 .......##
 } r {
 .##.###
 ..##.##
 ###..##
 .....##
 } t {
 ......##
 .....#..#
 ......##
 ..#####
 .....##
 } z {
 ...####
 .......###
 ...####
 ....#####
 .........##
 } {{ }} {
 .
 .
 .
 } . {
 .
 .
 .....##....
 ...######
 .....##
 }
 }
 if {[file tail [info script]]==[file tail $argv0]} {
    text .t -width 16 -height 16
    entry .e -textvar text
    set text "mongGoL tolI.."
    bind .e <Return> {display $text}
    proc display {text} {
        set im [strimj::bitmap [strimj::monglish $text]]
        .t image create end -image $im
        .t insert end " "
        set im [strimj::bitmap [strimj::zoom [strimj::monglish $text] 2]]
        .t image create end -image $im
        .t insert end " "
    }
    pack .e .t -expand 1 -fill both
    display $text
 }

if 0 {Arts and crafts of Tcl-Tk programming Category Human Language}