in reply to Module to map fontnames to X11 fonts.dir entries ?

Probably not exactly what you're looking for, but maybe a useful starting point for further investigations:  fontconfig comes with a little utility fc-match that maps logical names / property patterns to real font files installed in the system — presuming fontconfig itself is installed and properly configured. The details of the matching algorithm, valid property specs, etc. are described in the docs.  For example,

$ fc-match Times:italic

would output

n021023l.pfb: "Nimbus Roman No9 L" "Regular Italic"

or more verbosely (which includes the absolute path to the font file):

$ fc-match --verbose sans:bold Pattern has 28 elts (size 32) family: "Arial"(s) style: "Bold"(s) stylelang: "xx"(s) slant: 0(i)(s) weight: 200(i)(s) width: 100(i)(s) size: 12(f)(s) pixelsize: 12.5(f)(s) foundry: "monotype"(s) antialias: FcTrue(s) hintstyle: 3(i)(s) hinting: FcTrue(s) verticallayout: FcFalse(s) autohint: FcTrue(s) globaladvance: FcTrue(s) file: "/usr/X11R6/lib/X11/fonts/truetype/truetype/arialbd.ttf" +(s) index: 0(i)(s) outline: FcTrue(s) scalable: FcTrue(s) dpi: 75(f)(s) rgba: 1(i)(w) scale: 1(f)(s) charset: set(s) lang: aa|af|ar|ast|ava|ay|az|az-ir|be|bg|bi|bin|br|bs|bua|ca|. +.. fontversion: 184812(i)(s) capability: "otlayout:arab"(s) fontformat: "TrueType"(s) embeddedbitmap: FcFalse(w)

With --sort you'd get a sorted list of best matching fonts...

I have no idea, however, how that relates to the XLFD that you mentioned. Also, I'm not aware of any Perl binding to the fontconfig library (but it shouldn't be too difficult to create one, should you prefer to make direct calls into the lib, instead of using the supplied utility — the interface is reasonably well documented).

Replies are listed 'Best First'.
Re^2: Module to map fontnames to X11 fonts.dir entries ?
by renodino (Curate) on Dec 12, 2007 at 20:24 UTC
    Many thnx.

    But that seems like a sledgehammer to swat a fly (albeit, a very pesky fly!).

    So I guess its time to start slinging some Perl. I'm surprised this problem hasn't yet been addressed, it seems like a reasonably common issue thats been around for more than a decade. So I'm merging Win32::Font::NameToFile with an XLFD handler, and maybe look into an OS X solution as well. Then we'll finally have a single solution (well, sortof).


    Perl Contrarian & SQL fanboy