What a PITA. I'm documenting here so others may learn from my pain.

There are vague claims on the internet that GD will work with Mac OS X style dfont files. For example, the instructions on compiling gd on OS X (http://www.paginar.net/matias/articles/gd_x_howto.html) claim to be able to run gdtestft with a dfont file. Theres also this useless little comment: (http://use.perl.org/comments.pl?sid=24188&cid=37044) that gave me hope. Bus error for me.

I tried re-configuring gd an ran the gtestft script and got this error:

dyld: Symbol not found: _FSPathMakeRef Referenced from: /usr/local/lib/libfreetype.6.dylib Expected in: flat namespace

So I dug some more and I found this http://lists.freedesktop.org/archives/fontconfig/2006-October/002501.html which claimed that freetype-2.2.1 enables MacOS specific font format support, but requires Carbon framework functions, however freetype-config and freetype2.pc don't pass the appropriate linker flags. It has instructions for flags to add, which I did.

Now gdtestft tossed this error:

Symbol not found: __cg_jpeg_resync_to_restart Referenced from: /System/Library/Frameworks/ ApplicationServices.framework/Versions/A/Frameworks/ ImageIO.framework/Versions/A/ImageIO Expected in: /usr/local/lib/libJPEG.dylib

Progres, at least. That lead me to this link: http://tolstoy.newcastle.edu.au/R/devel/05/05/0752.html, which told me that I should remove my symlink to my own intalled /usr/local/libjpeg.dylib. So I did that, re-configured and re-made gd, and now gdtestft died quietly and simply with a segfault, instead of a bus error. Sigh.

So, I opted for workarounds, which lead me to Fondu, a set of programs to interconvert between mac font formats and pfb, ttf, otf and bdf files on unix. This is happily installable via fink or darwin ports or compilation or whatever else you want.

I then used fondu to convert my Monaco.dfont file into a Monaco.ttf file, and GD would then happily read it and operate on it for me. And, for my purposes since I'm just using a single font, I can live with that. Using multiple font would be a nuisance.

Supposedly there's a way to make it all work with dfonts directly, but I still haven't found the magic incantation. If someone knows it and is willing to share, then please do. Otherwise, this workaround will get me by for now.


In reply to Re: Using fonts in GD on OS X. by jimt
in thread Using fonts in GD on OS X. by jimt

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.