Version 2 of Font problems

Updated 2002-07-02 07:48:35

RS was asked the following, and herewith passes the questions on to the community:


The story goes like this: I have a set of 8-bit BDF (or PCF) fonts which are almost full in the sense that nearly 250 encodings are occupied by glyphs. (Those not occupied are "forbidden" positions like \x00 (NULL), \x09 (TAB), \x0a (CR), \xa0 ( ) etc.) Older versions of Tcl/Tk in tandem with older X distributions displayed all characters (in tk widgets) perfectly. Newer versions of Tcl/Tk (and newer X distributions) do not display certain characters correctly, for example, I am always getting a display of \x01 as \x01 (and not as the glyph defined in the BDF files at encoding 1).

If one has to use some kind of non-system encodings (like Japanese, Korean, Hebrew etc.), one may use "encoding convertfrom" or "encoding convertto" commands. "fconfigure -encoding" demands a channel to read/write strings in specified encodings. "encoding system", on the other hand, is something that may change the overall application behavior.

But my problem seems to be fundamentally different. I have a string to insert in a text widget / label / button, that contains \x01 in the straightforward 8-bit encoding and I want to see the corresponding glyph defined in the font files and not the escape sequence \x01. Is there a way to do this?


RS: First idea is that one of the DOS codepage encodings delivered with Tcl since 8.1 can help. Here is a little code page browser that displays the characters 0x00..0xFF of the selected encoding (double-click in the listbox).


 package require Tk
 listbox   .lb -yscrollcommand ".y set" -width 16
 bind .lb <Double-1> {showCodepage .t [selection get]}
 scrollbar .y -command ".lb yview"
 text .t -bg white -height 32 -wrap word
 pack .lb .y .t -side left -fill y
 pack .t        -fill both -expand 1

 foreach encoding [lsort [encoding names]] {
    .lb insert end $encoding
 }
 proc showCodepage {w encoding} {
    $w delete 1.0 end
    wm title . $encoding
    set hexdigits [list 0 1 2 3 4 5 6 7 8 9 A B C D E F]
    foreach high $hexdigits {
        foreach low $hexdigits {
            set c [encoding convertfrom $encoding [subst \\x$high$low]] 
            $w insert end "$high$low:$c "
        }
        $w insert end \n\n
    }
 } ;# RS

But from what I see, character positions 0x00..0x1F have no glyph in any encoding..