I'd like to query what fonts are available on a *nix-like system, ideally using PHP 5.2 or 5.3, but there doesn't seem to be many libraries available to do it in a system-independent way. php-font-lib just scans a directory (code, demo) but I'd hope there is a more elegant way to do it. (In any case, scanning a folder is only part of the task; font files still need to be opened to retrieve name and other metadata).
Background: I am rendering PDFs on a webserver using Inkscape, and would like to determine what fonts are available to render text elements. I'm developing on OS 10.6.8 and deploying on Linux.
Edit: I've found a PHP wrapper for Pango, which is an advanced font renderer often used with Cairo; both of these are used in Inkscape. The wrapper is quite new, so I am not yet sure whether it can produce a font listing - but it does look interesting :)
.
I've just found a cross-platform command, fc-list
. Works on OS X 10.6.8 and my Ubuntu VPS, and could easily be invoked by PHP. On my Linux machine I get a list in this format:
Nimbus Sans L:style=Regular Italic
URW Palladio L:style=Roman
Century Schoolbook L:style=Bold Italic
Nimbus Sans L:style=Bold
URW Chancery L:style=Medium Italic
Nimbus Roman No9 L:style=Regular
Century Schoolbook L:style=Bold
Century Schoolbook L:style=Italic
Nimbus Sans L:style=Regular
URW Palladio L:style=Italic
Nimbus Sans L:style=Bold Condensed
URW Gothic L:style=Demi
Nimbus Roman No9 L:style=Medium Italic
Nimbus Mono L:style=Bold Oblique
Dingbats:style=Regular
...continues...
On the Mac it looks like this:
URW Gothic L:style=Book Oblique
Fixed:style=ja
URW Palladio L:style=Bold Italic
Heiti SC,黑體\-簡,黒体\-簡,Heiti\-간체,黑体\-简:style=Light,細體,Mager,Fein,Ohut,Fin,Leggero,ライト,가는체,Licht,Tynn,Leve,Светлый,细体,Fina
Arial Narrow:style=Bold Italic,Negreta cursiva,tučné kurzíva,fed kursiv,Fett Kursiv,Έντονα Πλάγια,Negrita Cursiva,Lihavoitu Kursivoi,Gras Italique,Félkövér dőlt,Grassetto Corsivo,Vet Cursief,Halvfet Kursiv,Pogrubiona kursywa,Negrito Itálico,Полужирный Курсив,Tučná kurzíva,Fet Kursiv,Kalın İtalik,Krepko poševno,Lodi etzana
Fixed:style=Regular
Helvetica:style=Bold Oblique
Arial:style=Bold,Negreta,tučné,fed,Fett,Έντονα,Negrita,Lihavoitu,Gras,Félkövér,Grassetto,Vet,Halvfet,Pogrubiony,Negrito,Полужирный,Fet,Kalın,Krepko,đậm,Lodia
KufiStandardGK:style=Regular,標準體,Ordinær,Normal,Normaali,Regolare,レギュラー,일반체,Regulier,Обычный,常规体
Courier:style=Regular,標準體,Ordinær,Normal,Normaali,Regolare,レギュラー,일반체,Regulier,Обычный,常规体
New Century Schoolbook:style=Italic
Menlo:style=Bold
Luxi Sans:style=Bold Oblique
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With