Font problems with 2.5.27 on MacOS

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

Font problems with 2.5.27 on MacOS

Matthias Neeracher
It seems the changes in font.scm were harmful to MacOS X. On  
processing, I get:

warning: don't know how to embed "Verdana"="/Library/Fonts/Verdana"

and in the resulting PDF file, the chord names look weird (I believe  
it's Verdana substituted with Courier).

This seems to be related with pango default font lookup, which I  
don't understand very well, and with the fact that native fonts don't  
seem to be handled well by the open source tool chain.

Any suggestions how I could fix this? Should I just add a patch for  
MacOS to revert to Luxi for the sans serif font?

Matthias
 


_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: Font problems with 2.5.27 on MacOS

Han-Wen Nienhuys
Matthias Neeracher wrote:

> It seems the changes in font.scm were harmful to MacOS X. On  
> processing, I get:
>
> warning: don't know how to embed "Verdana"="/Library/Fonts/Verdana"
>
> and in the resulting PDF file, the chord names look weird (I believe  
> it's Verdana substituted with Courier).
>
> This seems to be related with pango default font lookup, which I  don't
> understand very well, and with the fact that native fonts don't  seem to
> be handled well by the open source tool chain.
>
> Any suggestions how I could fix this? Should I just add a patch for  
> MacOS to revert to Luxi for the sans serif font?

Yes,  I guess that's best. I'd be grateful if you could find out how we
can properly embed a dfont file. I know that there are utilities for
extracting TTFs from dfonts.

--
  Han-Wen Nienhuys - [hidden email] - http://www.xs4all.nl/~hanwen


_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Proposed patch (Was: Font problems with 2.5.27 on MacOS)

Matthias Neeracher

On Jun 3, 2005, at 2:08 AM, Han-Wen Nienhuys wrote:

> Matthias Neeracher wrote:
>
>> It seems the changes in font.scm were harmful to MacOS X. On  
>> processing, I get:
>> warning: don't know how to embed "Verdana"="/Library/Fonts/Verdana"
>> and in the resulting PDF file, the chord names look weird (I  
>> believe  it's Verdana substituted with Courier).
>> This seems to be related with pango default font lookup, which I  
>> don't understand very well, and with the fact that native fonts  
>> don't  seem to be handled well by the open source tool chain.
>> Any suggestions how I could fix this? Should I just add a patch  
>> for  MacOS to revert to Luxi for the sans serif font?
>
> Yes,  I guess that's best. I'd be grateful if you could find out  
> how we can properly embed a dfont file. I know that there are  
> utilities for extracting TTFs from dfonts.
I think I found a solution that is reasonably general: Why not pass  
all unknown font files to fontforge for pfa conversion? At this point  
in the code, it's already known that the font file must be in a font  
format that fontconfig understands, and I think the formats that  
fontforge understand are a proper superset of this, so the conversion  
should succeed.

I've attached a patch that implements this, and at least on MacOS X,  
this seems to work for the western font case. It *almost* seems to  
make xiao-haizi-guai-guai work too: the generated .ps has all fonts  
embedded, but somehow still fails pdf conversion.

Matthias


_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel

fontforge.patch (2K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Proposed patch (Was: Font problems with 2.5.27 on MacOS)

Han-Wen Nienhuys
Matthias Neeracher wrote:
>> Yes,  I guess that's best. I'd be grateful if you could find out  how
>> we can properly embed a dfont file. I know that there are  utilities
>> for extracting TTFs from dfonts.
>
>
> I think I found a solution that is reasonably general: Why not pass  all
> unknown font files to fontforge for pfa conversion?

I don't like this option because we would have to ship FontForge with
the standalone LilyPond on MacOS. FF is big, depends on X11, running it
is slow, and it doesn't have a clear versioning scheme.  In any case,
the relevant code should be implemented on the Scheme side. This is only
an option for the fink version.

AFAIK, a .dfont is an archive of several TTFs, and should be possible to
extract the right TTF font from the .dfont directly. Perhaps by
borrowing code from the Fondu utility.

> this seems to work for the western font case. It *almost* seems to  make
> xiao-haizi-guai-guai work too: the generated .ps has all fonts  
> embedded, but somehow still fails pdf conversion.

That should not be a surprise. The chinese/japanese fonts are shipped as
OTF and TTF, which are already correctly embedded by Lily. No need for
fontforge there.


--
  Han-Wen Nienhuys - [hidden email] - http://www.xs4all.nl/~hanwen


_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: Proposed patch (Was: Font problems with 2.5.27 on MacOS)

Matthias Neeracher

On Jun 5, 2005, at 2:13 PM, Han-Wen Nienhuys wrote:

Matthias Neeracher wrote:

Yes,  I guess that's best. I'd be grateful if you could find out  how we can properly embed a dfont file. I know that there are  utilities for extracting TTFs from dfonts.

I think I found a solution that is reasonably general: Why not pass  all unknown font files to fontforge for pfa conversion? 

I don't like this option because we would have to ship FontForge with the standalone LilyPond on MacOS.

It hadn't really occurred to me that this is a problem, since fontforge is used to build lilypond anyway. It is an issue for binary distributions, though.

FF is big,

Hmm, yes, I had not realized that it would add 10-15M.

depends on X11,

That is, I think, a configuration option.

AFAIK, a .dfont is an archive of several TTFs, and should be possible to extract the right TTF font from the .dfont directly.

Actually, we're not just dealing with dfonts here. Verdana, for instance, is a tradtional MacOS font, as far as I can tell. Also, I think that some font files may have the pfa font already embedded, so going through the ttf version may entail a loss of quality.

Perhaps by borrowing code from the Fondu utility.

I actually did have that running at some point (Same way as the fontforge technique, i.e. run the binary). It's slightly messier because you have to fish out the right ttf file. Also, lilypond then needs to run another conversion step for ttf to pfa, so I thought the fontforge technique was cleaner. I can resurrect that version of the code in a few hours, however. fondu IS two orders of magnitude smaller, now that I think about it.

It would not be impossible to embed the fondu code in lilypond, but that would definitely be more work, and at this stage in the release cycle, it's probably not a great idea to add a considerably amount of code for a marginal feature that is mostly needed on one platform.

this seems to work for the western font case. It *almost* seems to  make xiao-haizi-guai-guai work too: the generated .ps has all fonts  embedded, but somehow still fails pdf conversion.

That should not be a surprise. The chinese/japanese fonts are shipped as OTF and TTF, which are already correctly embedded by Lily. No need for fontforge there.

Well no, at least on 10.4, lilypond tries to typeset that file by pulling in the AppleMyunjo and Hei dfonts (fontconfig seems to take a certain perverse pleasure in defaulting to fonts that lilypond has difficulty embedding). Are you successful typesetting the file on 10.3 ? The fondu converted fonts seem to work even worse than the fontforge converted fonts for this.

Matthias



_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: Proposed patch (Was: Font problems with 2.5.27 on MacOS)

Han-Wen Nienhuys
Matthias Neeracher wrote:
>> AFAIK, a .dfont is an archive of several TTFs, and should be possible
>> to extract the right TTF font from the .dfont directly.
>
>
> Actually, we're not just dealing with dfonts here. Verdana, for
> instance, is a tradtional MacOS font, as far as I can tell. Also, I
> think that some font files may have the pfa font already embedded, so
> going through the ttf version may entail a loss of quality.

Verdana actually confuses me greatly. It's part of Microsoft Web fonts
program. I just can't work out where they store the TTF/PFA files for
these fonts.

> It would not be impossible to embed the fondu code in lilypond, but that
> would definitely be more work, and at this stage in the release cycle,
> it's probably not a great idea to add a considerably amount of code for
> a marginal feature that is mostly needed on one platform.

Perhaps, but I see invoking ff or fondu externally as a potential
support problem. If we ship early, but have to deal with a lot of
questions from confused users, that will waste our time.

>> That should not be a surprise. The chinese/japanese fonts are shipped
>> as OTF and TTF, which are already correctly embedded by Lily. No need
>> for fontforge there.
>
>
> Well no, at least on 10.4, lilypond tries to typeset that file by
> pulling in the AppleMyunjo and Hei dfonts (fontconfig seems to take a
> certain perverse pleasure in defaulting to fonts that lilypond has
> difficulty embedding). Are you successful typesetting the file on 10.3 ?

I have successfully typeset typography-demo.ly, which uses japanese.

--
  Han-Wen Nienhuys - [hidden email] - http://www.xs4all.nl/~hanwen


_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: Proposed patch (Was: Font problems with 2.5.27 on MacOS)

Matthias Neeracher

On Jun 5, 2005, at 3:02 PM, Han-Wen Nienhuys wrote:

Matthias Neeracher wrote:

AFAIK, a .dfont is an archive of several TTFs, and should be possible to extract the right TTF font from the .dfont directly.

Actually, we're not just dealing with dfonts here. Verdana, for instance, is a tradtional MacOS font, as far as I can tell. Also, I think that some font files may have the pfa font already embedded, so going through the ttf version may entail a loss of quality.

Verdana actually confuses me greatly. It's part of Microsoft Web fonts program. I just can't work out where they store the TTF/PFA files for these fonts.

In the MacOS version at least, this is a resource file that stores everything in a resource fork.

It would not be impossible to embed the fondu code in lilypond, but that would definitely be more work, and at this stage in the release cycle, it's probably not a great idea to add a considerably amount of code for a marginal feature that is mostly needed on one platform.


Perhaps, but I see invoking ff or fondu externally as a potential support problem. If we ship early, but have to deal with a lot of questions from confused users, that will waste our time.

I don't see much of a support problem here. In the standalone version, the fondu binary goes inside the application package, and in the fink version, it gets pulled in through a dependency. Am I missing something?

]That should not be a surprise. The chinese/japanese fonts are shipped as OTF and TTF, which are already correctly embedded by Lily. No need for fontforge there.

Well no, at least on 10.4, lilypond tries to typeset that file by pulling in the AppleMyunjo and Hei dfonts (fontconfig seems to take a certain perverse pleasure in defaulting to fonts that lilypond has difficulty embedding). Are you successful typesetting the file on 10.3 ? 


I have successfully typeset typography-demo.ly, which uses japanese.

Interestingly enough, that file also typesets correctly on 10.4. It seems to rely on the Hiragino otf font alone. Presumably xiao-haizi-guai-guai uses characters outside the Kanji part of CJK, which pulls in AppleMyunjo and Hei.

Matthias


_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: Proposed patch (Was: Font problems with 2.5.27 on MacOS)

Han-Wen Nienhuys
In reply to this post by Matthias Neeracher
Matthias Neeracher wrote:
> Actually, we're not just dealing with dfonts here. Verdana, for
> instance, is a tradtional MacOS font, as far as I can tell. Also, I
> think that some font files may have the pfa font already embedded, so
> going through the ttf version may entail a loss of quality.

Gotit! Verdana is really a normal TTF, but it's stored inside a mac
resource fork.  Reading it with Fondu will extract a TTF, which can then
be embedded as a Type42 using ly:ttf->pfa

 > It's slightly messier because
> you have to fish out the right ttf file. Also, lilypond then needs to

I don't understand, you'd have to figure out the right TTF file with FF
too? (You have to figure out whether to use the bold, normal, italic or
bolditalic variant


--
  Han-Wen Nienhuys - [hidden email] - http://www.xs4all.nl/~hanwen


_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel
Reply | Threaded
Open this post in threaded view
|

Re: Proposed patch (Was: Font problems with 2.5.27 on MacOS)

Han-Wen Nienhuys
In reply to this post by Matthias Neeracher
Matthias Neeracher wrote:

>
> On Jun 5, 2005, at 3:02 PM, Han-Wen Nienhuys wrote:
>
>> Matthias Neeracher wrote:
>>
>>>> AFAIK, a .dfont is an archive of several TTFs, and should be
>>>> possible to extract the right TTF font from the .dfont directly.
>>>>
>>> Actually, we're not just dealing with dfonts here. Verdana, for
>>> instance, is a tradtional MacOS font, as far as I can tell. Also, I
>>> think that some font files may have the pfa font already embedded, so
>>> going through the ttf version may entail a loss of quality.
>>
>>
>> Verdana actually confuses me greatly. It's part of Microsoft Web fonts
>> program. I just can't work out where they store the TTF/PFA files for
>> these fonts.
>
>
> In the MacOS version at least, this is a resource file that stores
> everything in a resource fork.
>
>>> It would not be impossible to embed the fondu code in lilypond, but
>>> that would definitely be more work, and at this stage in the release
>>> cycle, it's probably not a great idea to add a considerably amount of
>>> code for a marginal feature that is mostly needed on one platform.
>>>
>>
>> Perhaps, but I see invoking ff or fondu externally as a potential
>> support problem. If we ship early, but have to deal with a lot of
>> questions from confused users, that will waste our time.
>
>
> I don't see much of a support problem here. In the standalone version,
> the fondu binary goes inside the application package, and in the fink
> version, it gets pulled in through a dependency. Am I missing something?

I guess you're right. Linking in programs feels safer, but this is
acceptable. I already have fondu in the standalone .dmg. Can you prepare
a fondu patch?  (you need to make a copy of your source dir first, since
CVS is down.)

At the moment, I have

   (define (handle-mac-font name file)
     (open-input-pipe
      (format "./showfond ~a | grep FontName=" file))
        .. todo..
     )


   ..

        ((and bare-file-name (string-match "\\.dfont" bare-file-name))
         (handle-mac-font name bare-file-name))

        ((and bare-file-name (= (stat:size (stat bare-file-name)) 0))
         (handle-mac-font name bare-file-name))
       

handle-mac-font should

  - make temp directory
  - run fondu to extract the files
  - determine which file should be loaded for the given font name
  - decide whether to do ttf->pfa or pfb->pfa
  - cleanup the temp dir

--
  Han-Wen Nienhuys - [hidden email] - http://www.xs4all.nl/~hanwen


_______________________________________________
lilypond-devel mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-devel