LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Problems with TWM + UTF-8 (http://www.linuxquestions.org/questions/slackware-14/problems-with-twm-utf-8-a-4175435922/)

Soderlund 11-06-2012 10:37 AM

Problems with TWM + UTF-8
 
I know UTF-8 isn't fully supported, but I found a work-around (on a NetBSD mailing list) for the bug where TWM would instantly crash when you attempt to start it after enabling UTF-8 (saying "unable to open fontset").

Starting X without TWM does not cause a crash, by the way. It only happens with TWM. The rest of the system -- and X -- work fine with UTF-8.

The work-around

LC_CTYPE should be a non-UTF-8 locale.

Code:

$ cat .xinitrc
...
exec env LC_CTYPE=en_US /usr/bin/twm

This starts TWM, but UTF-8 does not work. If you open files with vim, it says [converted]. echo $LC_CTYPE in XTerm returns en_US, so that's expected.

Enabling UTF-8 in a non-UTF-8 TWM

From X, after starting it that way:

Code:

LC_CTYPE='' xterm
This launches an XTerm with UTF-8, and vim properly handles UTF-8 files. Any other xterms started normally have the LC_CTYPE variable set to "en_US", so...

Setting LC_CTYPE only for TWM

I tried this:

Code:

$ cat .profile
LC_CTYPE=''; export LC_CTYPE
$ cat .bashrc
LC_CTYPE=''

What I want to achieve with this is:
  • TWM starts with LC_CTYPE=en_US without crashing. Check.
  • Every other application launched from TWM has an empty LC_CTYPE, and should therefore use UTF-8 (falling back $LANG?), as if you would have started XTerm using LC_CTYPE='' xterm. Fail.

If I start X with those modifications to .profile and .bashrc, then TWM starts, and LC_CTYPE is empty when you open an XTerm normally, but those XTerms do not use UTF-8. Any UTF-8-files opened in vim contain funky symbols and you can't even enter .

Everything (keyboard and encoding) works fine if you start an XTerm with LC_CTYPE='' xterm, but not otherwise, even though the LC_CTYPE variable is empty in both cases!

Why does it behave like this? I just want LC_CTYPE to be "en_US" for TWM, but not for any other program. That would fix the whole thing.

Thanks in advance.

By the way, the original NetBSD post -- which must be the same bug -- is here:
http://gnats.netbsd.org/41129

bobzilla 11-06-2012 01:30 PM

1 Attachment(s)
I tested in generic (no extra packagaes) full install of 14.0 in VirtualBox and twm works nicely. I even remember running it under en_US.UTF-8 under 13.37 without a hitch.

What version of Slack?

markush 11-06-2012 05:24 PM

I've set de_DE.utf8 and twm runs without problems here. Slackware64-14.0.

Are you sure that the errormessage "unable to open fontset" does explicitely depend on using utf8? couldn't it help just to configure for another fontset?

Markus

Soderlund 11-07-2012 08:20 AM

I use version 14.0 x86.

I've even tried "-*-*-*-*-*--*-*-*-*-*-*-*-*".

I didn't do a full install, so there must be some package missing. I didn't install:
  • KDE
  • KDEI
  • XFCE
  • teTeX
  • emacs
  • Most of the XAP packages

I figured I can't possibly have to install KDE to run TWM, I was going to get texlive, there were no fonts in XAP, and it can't depend on emacs. But since I'm the only one having problems, that must be it.

I see now that teTeX indeed has the Computer Modern fonts, so I'll try that one. It seems odd since everything else works though.

What fonts do you use in your .twmrcs, by the way?

I appreciate the help.

markush 11-07-2012 08:31 AM

Quote:

Originally Posted by Soderlund (Post 4824119)
...
...
I see now that teTeX indeed has the Computer Modern fonts, so I'll try that one. It seems odd since everything else works though.

What fonts do you use in your .twmrcs, by the way?

I appreciate the help.

I don't have a .twmrc at all. I'd recommend to remove the .twmrc file temporarily (simply mv .twmrc .twmrc.bkp) so that it cannot be read by twm and then start twm. It's possible that you've messed things up with your .twmrc.

Markus

Soderlund 11-07-2012 09:05 AM

Quote:

Originally Posted by markush (Post 4824128)
I don't have a .twmrc at all. I'd recommend to remove the .twmrc file temporarily (simply mv .twmrc .twmrc.bkp) so that it cannot be read by twm and then start twm. It's possible that you've messed things up with your .twmrc.

Markus

It didn't work; I got the same error, but about the default font.

teTeX didn't solve it either.

markush 11-07-2012 09:11 AM

Well, what I would do then is rebuild twm from source, the source is in the source-tree from Slackware in x/X11, use the SlackBuild.script.

BTW: I don't believe that the missing series you've mentioned above can be responsible for your issue with twm. If there where packages from l or x missing, I would recommend to install the complete l and x series.

Markus

bobzilla 11-07-2012 12:17 PM

Quote:

Originally Posted by Soderlund (Post 4824119)
I figured I can't possibly have to install KDE to run TWM, I was going to get texlive, there were no fonts in XAP, and it can't depend on emacs. But since I'm the only one having problems, that must be it.

I see now that teTeX indeed has the Computer Modern fonts, so I'll try that one. It seems odd since everything else works though.

You don't need *tex or KDE. As Markus said most probably the problem is somewhere else.

Niether is the problem with .twmrc. I don't remember any options to set fonts in twmrc. But you might check the contents of your .Xresources. If you use the default xinitrc for twm, it starts three xterms. It quits when you exit one of the them. It might be the problem with xterm, not twm directly. Ie: if xterm exits, twm will too.

Also, have you installed all the fonts from /x disk set?

Soderlund 11-08-2012 09:54 AM

Getting rid of the .xinitrc worked! This turned out to be the criminal:

Code:

xrandr -s 800x600 --rate 60
/usr/bin/twm &
exec /usr/bin/xterm

With this, twm always complains missing fonts, but only when using an UTF-8 LC_CTYPE (not if it's c or en_US). The fix is:

Code:

/usr/bin/twm &
sleep 2
xrandr -s 800x600 --rate 60
exec /usr/bin/xterm

I don't know if sleep is necessary, but apparently TWM doesn't like to be started in 800x600 resolution.

The fonts are a bit big now actually, so I guess they are configured for 1600x1200. But I'll sort that out.

Thanks a lot for the help.

bobzilla 11-19-2012 12:21 AM

I have to apologies to op. I checked my config several days after responding to this thread and I made two wrong statements.

1. I did use something like this in my xinirc.twm in 13.37:

Code:

LC_CTYPE=en_US /usr/bin/twm
According to GNU Lib C documentation:
Quote:

LC_CTYPE - This category applies to classification and conversion of characters, and to multibyte and wide characters
And it worked, so it seems there was a bug in twm character/string handling. Btw, it seems the bug has been fixed because it works nicely without that in 14.0.

2. There is a section on fonts in twmrc:

Code:

# Fonts
TitleFont      "-*-dejavu sans-bold-*-*-*-12-*-*-*-*-*-*-*"
MenuFont        "-*-dejavu sans-bold-*-*-*-12-*-*-*-*-*-*-*"
IconFont        "-*-dejavu sans-bold-*-*-*-12-*-*-*-*-*-*-*"
IconManagerFont "-*-dejavu sans-bold-*-*-*-12-*-*-*-*-*-*-*"
ResizeFont      "-*-dejavu sans-bold-*-*-*-12-*-*-*-*-*-*-*"

To make up to the author, I'm posting my (tested and working) configs for 14.0.
http://pastebin.com/2UkvNRVK
http://pastebin.com/Di783JB4

And sorry for misleading you with the wrong answer. :( Memory is a bitch. :)

Soderlund 11-19-2012 08:32 AM

No worries. Thanks for posting your configs. I tried them and they work.

But when I inserted "xrandr -s 800x600" before starting twm in your .xinitrc, it says it can't find the fontset.

Code:

xrandr -s 800x600 # Doesn't work
/usr/bin/twm &

/usr/bin/xsetroot -solid $ROOTBGCOLOR -cursor_name $CURSOR &
exec /usr/bin/uxterm -geometry 80x25+0+0

Code:

/usr/bin/twm &
sleep 2; xrandr -s 800x600 # Works

/usr/bin/xsetroot -solid $ROOTBGCOLOR -cursor_name $CURSOR &
exec /usr/bin/uxterm -geometry 80x25+0+0

I don't have this problem in Debian 6, which uses TWM version 1.0.4. Since you had to set LC_CTYPE in Slackware 13.37 (which uses the same TWM version as Wheezy: 1.0.6), I bet this work-around will be required for TWM in Wheezy too.

bobzilla 11-19-2012 11:52 AM

Start it in the background (put an ampersand after the command). For example:
Code:

xrandr -s 800x600 &
Btw, if you use my config, you might want to delete the part that defines custom bitmaps. Or replace them with your own.

Code:

# Title bar buttons
ForceIcons
IconDirectory "/home/bocke/.icons/twm"
LeftTitleButton "menu.xbm"=f.menu "winops"
RightTitleButton "iconify.xbm"=f.iconify
RightTitleButton "maximize.xbm"=f.fullzoom
RightTitleButton "close.xbm"=f.delete

There is also a menu item you might want to customize:
Code:

"Play                          "      f.exec "mocp -l /home/bocke/Music/* &"


---------- Post added 11-19-12 at 06:53 PM ----------

Anyway, what's the exact error message? Do you have Dejavu Sans installed on your Debian box?

Soderlund 11-22-2012 05:10 AM

Does it work for you to start it in the background? I tried and I get the same error.

The error message says:
Code:

twm:  unable to open fontset x
Where "x" is any font.

I tested a few other things, and got some interesting results. This is done from X, after starting it without invoking Xrandr from .xinitrc (thus starting in 1600x1200).

Code:

# 1: Quit TWM, so that no window manager is running
xrandr -s 800x600
xrandr -s 1600x1200
twm &              # Success

Code:

# 1: Quit TWM
xrandr -s 800x600
twm &              # Fails: "Unable to open fontset"
xrandr -s 1600x1200
twm &              # Fails: "Unable to open fontset"

Notice the difference: if I set the resolution to 800x600 and then back to 1600x1200, then TWM starts. But If I set it to 800x600, try to start TWM (which fails), and then switch back 1600x1200, then TWM does not start. It's as if starting TWM in the "wrong" resolution sets some flag somewhere that makes it unable to start for the duration of the X session.

I don't know if I have Dejavu Sans on the Debian partition, but I've tried dozens of fonts and they all give the same error, even though they are in xfontsel.

By the way, xfontsel also says: "Warning: Unable to load any usable fontset"; all fonts show up in xfontsel though.

I appreciate you trying to help me with this, but I think it's hopeless. It must be a bug somewhere, probably in TWM. I see that they have messed with the font setting code recently.


All times are GMT -5. The time now is 05:59 PM.