I am trying to us an outside font with GD.

Though I do not have to use X11 fonts, GD comes with a program called "bdf2gd.pl" that can convert X11 fonts to a compatible format. So it looked like a good place to start. Unfortunately, the utility doesn't seem to work. A 99k ASCII text file comes out a 220k binary file.

The GD documentation also says their font format is the same as the old Windows' fixed-point format. So I got my copy of Windows 3.1 and tried one of its fonts. GD complains its format is not correct.

So, my question, oh wise ones, is what is the true way to use outside fonts in GD?


I humbly await your enlightenment,
seekerOfKnowledge



** UPDATE **

Thanks everyone, but I figured out I did not give enough detail and, after tracing through all the Perl modules involved (and libgd), have found the problem. The answer is, it can not be done without changing a module.


Let me explain:

First, an important detail: I wanted the GD font for the Chart-2.4.7 module, which passes it to GD. Additionally, I wanted ultimately to use a proportionally-spaced font.

To use a proportionally-spaced font, I need to modify chart to allow font specifications and not just GD font objects and I need to change all the text positioning code to take the flexible widths into account.

I did trace through the libgd code and found the on-disk format for its fixed fonts. So I can now use fixed fonts all day long. This will have to suffice, until I can take the time to modify Chart.



Thanks everyone for your quick response and help.

In reply to Converting X11 fonts for GD by seekerOfKnowledge

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.