unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Fonts and fontsets on X
@ 2012-10-12 16:38 Yuri D'Elia
  2012-10-16 12:06 ` Kenichi Handa
  0 siblings, 1 reply; 2+ messages in thread
From: Yuri D'Elia @ 2012-10-12 16:38 UTC (permalink / raw)
  To: emacs-devel

Hi everyone. I would like to have some insider's comments about 
fontsets. I'm trying both emacs 23/24 from debian.

Can fontsets be used as a decent "fallback" mechanism whenever the 
requested glyph of a font is missing?

The typical case scenario is a monospaced font that comes in both 
normal/bold variants, but the bold face does not contain all glyphs. 
Showing the glyph from the normal face would be better than using 
another face.

My initial approach to this was:

(create-fontset-from-fontset-spec "-unknown-Droid Sans 
Mono-normal-normal-normal-*-18-*-*-*-*-*-fontset-normal,-unknown-DejaVu 
Sans Mono-normal-normal-normal-*-18-*-*-*-*-*-*")
(create-fontset-from-fontset-spec "-unknown-Droid Sans 
Mono-bold-normal-normal-*-18-*-*-*-*-*-fontset-bold,-unknown-Droid Sans 
Mono-normal-normal-normal-*-18-*-*-*-*-*-*,-unknown-DejaVu Sans 
Mono-normal-normal-normal-*-18-*-*-*-*-*-*")

(set-face-attribute 'default :font "fontset-normal")
(set-face-attribute 'bold :font "fontset-bold")

But, it doesn't seem to work as intended. I still see glyphs coming from 
a different face (math greek letters, for exacly). Why exactly?

My second attempt was to use fontconfig, which works correctly under urxvt:

<fontconfig>
   <match target="font">
     <test name="family">
       <string>Droid Sans Mono</string>
     </test>
     <edit name="family" mode="append" binding="weak">
       <string>DejaVu Sans Mono</string>
     </edit>
   </match>
   <match target="font">
     <test name="family">
       <string>Droid Sans</string>
     </test>
     <test name="weight">
       <const>bold</const>
     </test>
     <edit name="fullname" mode="append" binding="same">
       <string>Droid Sans Regular</string>
     </edit>
   </match>
</fontconfig>

notice how I define a "same" binding which replaces the fullname of the 
font for the bold variant, and then a general weak fallback.

However, emacs still completely ignores my definition, and C-u C-x = 
confirms that the font being displayed is not the one I requested. By 
reading the manual, starting emacs with -fn 'Droid Sans Mono' should use 
all glyps from Droid (then DejaVu Sans, if my fontconfig setup is ok), 
and *then* use fontset-default.

Then, let's assume I have a different family for 'variable-pitch, which 
is reasonable, since I don't want monospaced glyphs here.

Again, it seems that the only way I can make use of the font's own 
glyphs before the fallback is to define its own fontset and redefine all 
the ranges.

Either I don't get it, or fontset doesn't seem to play well at all with 
font-lock and different faces.




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Fonts and fontsets on X
  2012-10-12 16:38 Fonts and fontsets on X Yuri D'Elia
@ 2012-10-16 12:06 ` Kenichi Handa
  0 siblings, 0 replies; 2+ messages in thread
From: Kenichi Handa @ 2012-10-16 12:06 UTC (permalink / raw)
  To: Yuri D'Elia; +Cc: emacs-devel

In article <k59h1n$23t$1@ger.gmane.org>, Yuri D'Elia <wavexx@users.sourceforge.net> writes:

> Hi everyone. I would like to have some insider's comments about 
> fontsets. I'm trying both emacs 23/24 from debian.

> Can fontsets be used as a decent "fallback" mechanism whenever the 
> requested glyph of a font is missing?

> The typical case scenario is a monospaced font that comes in both 
> normal/bold variants, but the bold face does not contain all glyphs. 
> Showing the glyph from the normal face would be better than using 
> another face.

> My initial approach to this was:

> (create-fontset-from-fontset-spec "-unknown-Droid Sans 
> Mono-normal-normal-normal-*-18-*-*-*-*-*-fontset-normal,-unknown-DejaVu 
> Sans Mono-normal-normal-normal-*-18-*-*-*-*-*-*")
> (create-fontset-from-fontset-spec "-unknown-Droid Sans 
> Mono-bold-normal-normal-*-18-*-*-*-*-*-fontset-bold,-unknown-Droid Sans 
> Mono-normal-normal-normal-*-18-*-*-*-*-*-*,-unknown-DejaVu Sans 
> Mono-normal-normal-normal-*-18-*-*-*-*-*-*")

If you want to specify the default font exactly by name,
please use "ascii" for SCRIPT-NAME as below (see the docstring of
create-fontset-from-fontset-spec):

(create-fontset-from-fontset-spec
 "-unknown-Droid Sans Mono-normal-normal-normal-*-18-*-*-*-*-*-fontset-normal,\
  ascii:-unknown-DejaVu Sans Mono-normal-normal-normal-*-18-*-*-*-*-*-*")
(create-fontset-from-fontset-spec
 "-unknown-Droid Sans Mono-bold-normal-normal-*-18-*-*-*-*-*-fontset-bold,\
  ascii:-unknown-Droid Sans Mono-normal-normal-normal-*-18-*-*-*-*-*-*")

> (set-face-attribute 'default :font "fontset-normal")
> (set-face-attribute 'bold :font "fontset-bold")

The aboves are syntax error.  Do this:

(set-face-attribute 'default nil :font "fontset-normal")
(set-face-attribute 'bold nil :font "fontset-bold")

With them, my bold face uses "Droid Sans Mono" font.

---
Kenichi Handa
handa@gnu.org



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-10-16 12:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-12 16:38 Fonts and fontsets on X Yuri D'Elia
2012-10-16 12:06 ` Kenichi Handa

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).