# rxvt-unicode & fonts -- funny problems



## free-and-bsd (Nov 24, 2017)

Hello, everyone.

I have noticed strange thing happen on my system from time to time. That is, I haven't been able to trace it to any particular event.

In my urxvt I use Terminus font, which needs a couple of tweaks to be done to /usr/local/etc/fonts/conf.d/conf.avail/70-no-bitmaps.conf.

But the final thing is defining the fonts I want to use in .Xresources and .Xdefaults files (on my system the one is a link to the other). Here is the corresponding part of it:

```
! Fonts
URxvt.allow_bold:           true
!URxvt*font: xft:xos4 Terminus-12
URxvt*font: -xos4-terminus-medium-r-normal--16-*-*-*-*-*-*-*
/*URxvt*font: xft:Monospace:pixelsize=14*/
/*URxvt*boldFont: xft:Monospace:pixelsize=14*/
```
Currently, as can be seen, I'm using the Unix-style font name there (URxvt*font: -xos4-terminus-medium-r-normal--16-*-*-*-*-*-*-*) and to make sure it works I have created /usr/local/etc/X11/xorg.conf.d/fonts.conf file with font paths.
But one can also see the commented font reference "!URxvt*font: xft:xos4 Terminus-12". This is an alternative way to tell the apps about the fonts.

Now the funny thing I'm puzzled about is that sometimes Xorg "changes its mind" as to which of these notations it understands now. So far it has been working with the Unix style one. But then, for some unknown reason, it stops recognizing that and I can't launch my urxvt terminal until I comment this out and uncomment "URxvt*font: xft:xos4 Terminus-12".

Can anybody tell me WHY this may be happening? Because this is not visibly linked to any updates. Just one fine morning I switch on my computer, launch urxvt -- no reply... Funny, isn't it?

Needless to say, I never EVER touch anything related to fonts in X. Neither is one supposed to, I guess, as it all is now automatic.


----------



## aragats (Nov 27, 2017)

free-and-bsd said:


> In my urxvt I use Terminus font, which needs a couple of tweaks to be done to /usr/local/etc/fonts/conf.d/conf.avail/70-no-bitmaps.conf


Actually, it's opposite: you *do* want to use bitmap fonts for terminals.
The problem is that, most likely, you have _terminus_ in *both* bitmap and truetype form. I'd recommend uninstalling x11-fonts/terminus-ttf. The UNIX notation works with the bitmap one.


----------



## free-and-bsd (Nov 27, 2017)

aragats said:


> Actually, it's opposite: you *do* want to use bitmap fonts for terminals.


Yes, I should have mentioned that my 70-no-bitmaps.conf is edited to include exception for Terminus font. Borrowed that from one FreeBSD font-tweaking HOWTO out there, like this:

```
<?xml version="1.0"?>
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
<fontconfig>
<!-- Reject bitmap fonts -->
 <selectfont>
  <acceptfont>
   <pattern>
    <patelt name="family">
     <string>Terminus</string>
    </patelt>
   </pattern>
  </acceptfont>
  <rejectfont>
   <pattern>
     <patelt name="scalable"><bool>false</bool></patelt>
   </pattern>
  </rejectfont>
 </selectfont>
</fontconfig>
```
The point of the HOWTO was to improve fonts in FreeBSD, which, I must admit, used to be a problem until some few years ago -- the fonts were ugly. Due to something disabled/absent in x11-fonts/fontconfig due to license issues, as far as I remember. So there were plenty of HOWTOs recommending the way to _enable_ such things on the personal basis.


> The problem is that, most likely, you have _terminus_ in *both* bitmap and truetype form. I'd recommend uninstalling x11-fonts/terminus-ttf. The UNIX notation works with the bitmap one.


Don't know about that, they're gzipped files of the form /usr/local/share/fonts/terminus-font/ter-924b.pcf.gz.


----------



## aragats (Nov 27, 2017)

I always installed x11-fonts/terminus-font with `pkg install terminus-font` and never had problems.
You can check for existence of the ttf version:
	
	



```
$ pkg info -E terminus-ttf
$ find /usr/local/share/fonts/ -iname "*terminus*ttf"
```
I see no need for it, it may take precedence over the bitmap version for some reason.


----------



## free-and-bsd (Nov 27, 2017)

OK, here we go again: I've just updated some ports and guess what? Trying to launch urxvt I get this error:

```
$urxvtc -e /usr/local/bin/bash
urxvt: -xos4-terminus-medium-r-normal--16-160-72-72-c-80-ibm-cp437: cannot deduce encoding from registry/encoding properties "IBM-CP437", ignoring font.
urxvt: -xos4-terminus-medium-r-normal--16-160-72-72-c-80-ibm-cp437: cannot deduce encoding from font name property "IBM-CP437", ignoring font.
urxvt: unable to load base fontset, please specify a valid one using -fn, aborting.
```
Funny it should complain about that even after I explicitly set in .Xresources the font name:

```
URxvt*font: -xos4-terminus-medium-r-normal--16-*-*-*-*-*-iso10646-1
```


----------



## aragats (Nov 27, 2017)

Have you merged the resources after editing .Xresources: `xrdb -merge ~/.Xresources`?
By the way, I have a backup font specified for _urxvt_ as well:
	
	



```
URxvt.font: -*-terminus-medium-*-*-*-16-*-*-*-*-*-iso10646-*, \
           -*-unifont-*-r-*-*-16-*-*-*-*-*-iso10646-*
```
It is also useful when dealing with certain characters which do not exist in _terminus_.


----------



## free-and-bsd (Nov 27, 2017)

Doesn't help. There is another related thread, though. The same error I had when upgrading.


----------



## free-and-bsd (Nov 27, 2017)

Well, it's just ONE OF THOSE TIMES I'm talking about in this thread: the _name_ of the font by which it can be recognized in .Xresources has changed. Just as it happened before, namely, instead of the last working one "URxvt*font: xft:*xos4* Terminus*-12*" I must now write there "URxvt*font: xft:Terminus:12:style=regular".

Now this is precisely what keeps on changing I don't know why. Right now the correct name can be received from `fc-list | grep Terminus`. It gives me:

```
/usr/local/share/fonts/terminus-font/ter-x18b.pcf.gz: Terminus:style=Bold
/usr/local/share/fonts/terminus-font/ter-x28b.pcf.gz: Terminus:style=Bold
/usr/local/share/fonts/terminus-font/ter-x20b.pcf.gz: Terminus:style=Bold
/usr/local/share/fonts/terminus-font/ter-x18n.pcf.gz: Terminus:style=Regular
/usr/local/share/fonts/terminus-font/ter-x28n.pcf.gz: Terminus:style=Regular
............
```
The previous time I used this one it gave me names like xos4 Terminus-12 etc. Then it stopped giving me anything until I added the FontPath to Xorg configuration (didn't have to do it before).

So... this "unstable" behaviour is what I find disturbing. Such things as app fonts you set up ONCE and then forget. But not with urxvt and not with terminus font. Well...

Anyway, thank you so much for your support


----------



## aragats (Nov 27, 2017)

free-and-bsd said:


> the _name_ of the font by which it can be recognized in .Xresources has changed


I guess, that's an Xft library's issue. I rarely use xft notation, prefer the standard Unix-style names which can easily be checked with x11-fonts/xfontsel, especially for bitmap fonts.


----------



## free-and-bsd (Nov 27, 2017)

aragats said:


> I guess, that's an Xft library's issue. I rarely use xft notation, prefer the standard Unix-style names which can easily be checked with x11-fonts/xfontsel, especially for bitmap fonts.


Well, I finally found that xlsfonts does that, but it needs FontPath to me mentioned in /usr/local/etc/X11/xorg.conf/fonts.conf file.

So, this all is, I guess, the "downside" of having a personalized simplistic FVWM-based desktop. But it's worth it.


----------



## aragats (Nov 27, 2017)

But how it may relate to window manager?..
That's a real problem if something relies on window manager's capability to add a font path. At least it must be consistent: either fonts paths have to be always configured manually, or automatically upon new fonts installations.


----------



## free-and-bsd (Nov 27, 2017)

aragats said:


> But how it may relate to window manager?..
> That's a real problem if something relies on window manager's capability to add a font path. At least it must be consistent: either fonts paths have to be always configured manually, or automatically upon new fonts installations.


Right, and in case of a DE like GNOME I have NO IDEA what's happening underneath. Granted, I've never had any font related problems there, but some more serious ones I did have. With FVWM many things are configured manually, but... you know what there is and what it does.


----------



## Adrien2002 (Jan 4, 2018)

The FreeBSD stable 11.1 just got updated and now urxvt says that :


```
$ urxvt
urxvt: -xos4-terminus-bold-r-normal--24-240-72-72-c-120-ibm-cp437: cannot deduce encoding from registry/encoding properties "IBM-CP437", ignoring font.
urxvt: -xos4-terminus-bold-r-normal--24-240-72-72-c-120-ibm-cp437: cannot deduce encoding from font name property "IBM-CP437", ignoring font.
urxvt: unable to load base fontset, please specify a valid one using -fn, aborting.
```


----------



## free-and-bsd (Jan 7, 2018)

Adrien2002 said:


> The FreeBSD stable 11.1 just got updated and now urxvt says that :
> 
> 
> ```
> ...


Exactly! This happens to me every now and then -- every now and then it decides that it can't read the Unix notation. Then after a while it "can't read" the xft notation and have to fall back to Unix. 

And since there is NO documented configuration that would define the one or the other in some configuration files, I consider this a BUG. Only, I don't know which package the bug is attributed to.

For solution see my posts above.


----------



## aragats (Jan 7, 2018)

Supposing that urxvt tries to use _cp437_ (which does not exist in most fonts) I just extracted x11/rxvt-unicode source code, searched for _cp437_ and found nothing! So it's definitely not a urxvt issue, there must be a config file somewhere with
"-xos4-terminus-bold-r-normal--24-240-72-72-c-120-ibm-cp437" font name notation.

(By the way, I don't have and never had such issue in 2 computers I run FreeBSD in)


----------

