Subject: bug#4895: 23.1; Incorrect font selected

From: Kenichi Handa <[email-masked]>
Date: Tue, 10 Nov 2009 10:32:24 +0900

In article <[email-masked]>, Andrey Paramonov <[email-masked]> writes:

> 0) emacs -Q
   
>    My .Xresources:

>    emacs*font: DejaVu Sans Mono-11

> 1) C-x C-f titledefs.dtx (attached)

>    Latin characters are displayed with DejaVu Sans Mono, as expected.
>    Cyrillic characters are not displayed properly. This is Ok yet,
>    because the file is encoded in cp1251.

> 2) C-x RET r cp1251 RET
>    yes RET
   
>    Latin characters are displayed with DejaVu Sans Mono, as expected.
>    Cyrillic characters are displayed, but not with DejaVu Sans Mono.
>    Looks like they are displayed with Terminus.

This is because Emacs prefers a font whose registry matches
with `charset' text property.

In the above case, the default fontset has this entry for
cyrillic:

     (cyrillic ,(font-spec :registry "iso10646-1" :script 'cyrillic)
	       (nil . "ISO8859-5")
	       (nil . "microsoft-cp1251")
	       (nil . "koi8-r"))

and when you read a file with cp1251, the charset property
`cp1251' is put on the buffer text.  Thus the font-selector
prefers a font whose registry is "microsoft-cp1251".

If you prefer cyrillic characters to be displayed by the
default font, you can do this in .emacs:

(set-fontset-font "fontset-default" 'cyrillic
                  (font-spec :registry "iso10646-1" :script 'cyrillic))
                                                                       
---
Kenichi Handa
[email-masked]