Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I type a different character set (like APL) in a Text Widget?

Status
Not open for further replies.

BioDJ

Programmer
Oct 5, 2001
10
0
0
NL
While using a text widget in my editing-program, I have found the problem that when I select a different font, most of the time I cannot type that font's specific characters. It does work with for example WingDings. The keys are correctly assigned to give different characters on screen (namely wingding symbols, in stead of normal letters).

But! When I choose APL for a font (I want to use my editor in APL as well) I cannot type APL symbols; in stead I can just type normal letters).

Does anyone have any suggestion to this? I know the windows interface (WI) does have a simple style-feature to its editbox - something like the number 2048. But is there anything like that in TCL???

Responses very welcome.....

DJ
 
It sounds like what you're asking about relates to "input method editors," which allow you to input characters that do not appear on your keyboard. Unfortunately, this is a very tricky area to handle, no matter what language you're programming in. The best help I can offer (which isn't much) is to check out the Tcl'ers Wiki ( specifically the page
Tcl versions 8.1 and later do have native Unicode character support, so any character mapped to the Unicode character set can theoretically be handled. However, to properly display the character, your system must have a font capable of representing that character. For example, this code:

Code:
pack [text .t]
 .t insert end "Japan  \u65E5\u672C\n"
 .t insert end "Athens \u0391\u03B8\u03AE\u03BD\u03B1\u03B9"

isn't going to display much useful without a font on your system that can handle Japanese and Greek character sets.

Complicating matters further, some fonts on your system might not have mappings into Unicode (either they don't map at all, or there isn't information mapping the characters to Unicode codepoints). So in a particular font, you might have a character represented by a 0x4D bytecode (a bomb symbol in the Wingdings font on my Windows 2000 system), but Tcl considers the bytecode 0x4D to be a Unicode capital M, which is what it would display. However, if you configure your widget to display in the Wingdings font, you'll see the bomb.

So, if this last option is good enough for you, you've got your solution. If you say:

Code:
pack [text .t]
.t insert end "Ken Jones\n"

you'll see my name displayed. If you then say:

Code:
.t configure -font "Wingdings"

you'll see a sequence of Wingding characters. - Ken Jones, President
Avia Training and Consulting
866-TCL-HELP (866-825-4357) US Toll free
415-643-8692 Voice
415-643-8697 Fax
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top