[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Why -dshow-available-fonts doesn't list "Times Italic"

From: Trevor Bača
Subject: Re: Why -dshow-available-fonts doesn't list "Times Italic"
Date: Fri, 30 Mar 2007 17:04:00 -0500

On 3/17/07, Han-Wen Nienhuys <address@hidden> wrote:
2007/3/16, Trevor Bača <address@hidden>:

> Unfortunately I just don't know much of anything, really, about font
> management on my operating system; it's just a shielded resource in
> most applications other that Lily.
> Does anyone see an obviously missing directory in the above output
> that would explain why I'm getting mostly regular style fonts instead
> of italic and bold?

Mac uses something called dfonts, which mean that all 4 versions of
the font come inside one file.  Lily will unpack the right font from
the dfont, but fontconfig doesn't look inside them.

Solution: use fondu to extract fonts to separate .ttfs yourself, and
put them in the ~/.fonts directory.

Oh good. This works. Thanks, Han-Wen.

The process of downloading and using the fondu font conversion utility
takes a little bit of doing. So I'll write the steps down here for

First off, let me restate the problem that lead to this original
thread: some time ago I noticed that certain fonts just didn't
override correctly in markup like this (at least under OS X):

 \markup {
   \override #'(font-name . "Times Italic")
   "This text is in Times Italic."

By default, that override does absolutely nothing -- LilyPond neither
obeys the override nor generates warnings or errors. Which is
frustrating, because this override works fine:

 \markup {
   \override #'(font-name . "Times")
   "This text is in Times Italic."

Now, if you don't use font overrides in your markup, or if you're on
an operating system other than OS X, then what follows is probably of
no use to you. But if you do want access to oblique font faces in your
OS X markup, then read on.

So why the difference between the two markups above? Han-Wen:

"Mac uses something called dfonts, which mean that all 4 versions of
the font come inside one file.  Lily will unpack the right font from
the dfont, but fontconfig doesn't look inside them."

If you're on OS X you can use spotlight to search for ".dfont" and
about 20 or 30 .dfont files will come back, all of them appearing in
either /Library/Fonts or /System/Library/Fonts. (Like I said before, I
know nothing about font management under OS X and I don't know what
the difference is between fonts sitting in /Library/Fonts and fonts
sitting in /System/Library/Fonts; but it turns out that you don't need
to know understand why .dfonts live in certain directories to use
fondu; you just need to be able to find the source .dfont files and
point fondu at those source .dfont files.)

So, presumably you can only use the regular versions of those 20 or 30
.dfont fonts in Lily.

This is where fondu comes in. The sourceforge page is and the package dated 10-October-2005
works fine. Download it, unstuff, and install.

Once fondu is installed, you call fondu on a .dfont file and it
explodes the .dfont into a whole bunch of other files (mostly ending
in TTF and BDF). The trick here is to move the input .dfont file into
a safe directory and then call fondu so that the exploded files don't
make too much of a mess.

I went back to spotlight and drug a duplicate copy of
/System/Library/Fonts/Times.dfont to the desktop. Then I called ...

 fondu ~/Desktop/Times.dfont

... and all of these files resulted:

Times-10.bdf                    TimesCE-24.bdf
Times-12.bdf                    TimesCE-9.bdf
Times-14.bdf                    TimesCY-10.bdf
Times-18.bdf                    TimesCY-12.bdf
Times-24.bdf                    TimesCYBold-10.bdf
Times-9.bdf                     TimesCYBold-12.bdf
Times.dfont                     TimesCYBoldItalic-10.bdf
TimesBold.ttf                   TimesCYBoldItalic-12.bdf
TimesBoldItalic.ttf             TimesCYItalic-10.bdf
TimesCE-10.bdf                  TimesCYItalic-12.bdf
TimesCE-12.bdf                  TimesItalic.ttf
TimesCE-14.bdf                  TimesRoman.ttf

Han-Wen's second bit of advice said: "use fondu to extract fonts to
separate .ttfs yourself, and put them in the ~/.fonts directory."

So I changed to my home directory and did ...

 ls -a

... which revealed no ~/.fonts directory.

Was this the right directory?

Running ...

 lilypond -dshow-available-fonts

... gives a bunch of output ending in ...

< snip >
Font dir: /usr/share/fonts
Font dir: /Library/Fonts
Font dir: /System/Library/Fonts
Font dir: /Users/trevorbaca/.fonts

... which shows that, yes, fontconfig does in fact search for a
directory called ~/.fonts. So I created the directory.

Then the question was whether only the four TTFs needed to copy into
~/.fonts or whether all the BDFs also needed to copy into ~/.fonts. I
decided to copy over only the TTFs and throw away the BDFs. And
everything seems to work fine; guess the BDFs don't matter.

So that's pretty much it: download fondu from sourceforge, find a
source .dfont in the guts of your filesystem somewhere, call fondu on
the .dfont, and then copy over the resulting TTFs into ~/.fonts
(creating the target directory first if it doesn't yet exist, and
ignoring the other output from fondu).

Incidentally, running ...

 lilypond -dshow-available-fonts > fonts.out

... writes nothing to fonts.out because output directs to standard
error. So, instead running ...

 lilypond -dshow-available-fonts > fonts.out 2>&1

... and redirecting both standard error and standard out to fonts.out
will produce a text listing of all the fonts that fontconfig knows
about. (This was the way that I was able to verify that prior to fondu
fontconfig knew only about Times, but that after fondu fontconfig did
indeed know about TimesItalic, TimesBold and TimesBoldItalic.)

Once you're used fondu, you can render this with the expected results
under OS X:

%%% BEGIN %%%

\version "2.11.20"

\markup {
  "This text is in Times."

\markup {
  \override #'(font-name . "Times Italic")
  "And this text is in Times Italic."

%%% END %%%

Maybe we could include fondu in the OS X package and produce (and
convert) a list of .dfont resources at install time?

Trevor Bača

reply via email to

[Prev in Thread] Current Thread [Next in Thread]