# How to get font info on \*nix?

**URL:** <https://www.ruby-forum.com/t/how-to-get-font-info-on-nix/48501>\
**Category:** Ruby\
**Created:** [November 21, 2005, 4:07pm UTC](https://www.ruby-forum.com/t/how-to-get-font-info-on-nix/48501 "2005-11-21T16:07:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![rmagick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6de8d8/32.png) [@rmagick](https://www.ruby-forum.com/u/rmagick)\
**Post date:** [November 21, 2005, 4:07pm UTC](https://www.ruby-forum.com/t/how-to-get-font-info-on-nix/48501/1 "2005-11-21T16:07:56Z")

</div>

I’m thinking about writing a Ruby extension for Linux/\*BSD/Darwin to  
enumerate all the fonts (Postscript and TTF) that are installed, along  
with their attributes. Given such an extension I could write a Ruby  
program to generate a custom ImageMagick font config file.

Can somebody enlighten me about where to start? Is there an existing  
library I can leverage? I found fontconfig ([www.fontconfig.org](http://www.fontconfig.org)) but I’m  
not sure that’s right.

---

<div class="post-metadata">

**Author:** ![rmagick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6de8d8/32.png) [@rmagick](https://www.ruby-forum.com/u/rmagick)\
**Post date:** [November 21, 2005, 5:20pm UTC](https://www.ruby-forum.com/t/how-to-get-font-info-on-nix/48501/2 "2005-11-21T17:20:41Z")

</div>

On 11/21/05, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I’m thinking about writing a Ruby extension for Linux/\*BSD/Darwin to  
> enumerate all the fonts (Postscript and TTF) that are installed, along  
> with their attributes. Given such an extension I could write a Ruby  
> program to generate a custom ImageMagick font config file.
> 
> Can somebody enlighten me about where to start? Is there an existing  
> library I can leverage? I found fontconfig ([www.fontconfig.org](http://www.fontconfig.org)) but I’m  
> not sure that’s right.

Take a look near the top of the PDF::Writer main file  
(lib/pdf/writer.rb) and you’ll see what I do in order to find existing  
fonts. It’s imperfect and somewhat untested, but you may need to parse  
the fonts themselves to determine the relevant information.

-austin

---

<div class="post-metadata">

**Author:** ![rmagick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6de8d8/32.png) [@rmagick](https://www.ruby-forum.com/u/rmagick)\
**Post date:** [November 21, 2005, 6:33pm UTC](https://www.ruby-forum.com/t/how-to-get-font-info-on-nix/48501/3 "2005-11-21T18:33:24Z")

</div>

Quoting “removed\_email\_address@domain.invalid” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Can somebody enlighten me about where to start? Is there an  
> existing library I can leverage? I found fontconfig  
> ([www.fontconfig.org](http://www.fontconfig.org)) but I’m not sure that’s right.

Fontconfig is about the closest you can come to a standard for font  
configuration on \*nix right now. Which is to say: not very, but  
it’s probably the best you can do.

It should at least work anywhere that’s got a modern Gtk.

-mental

---

<div class="post-metadata">

**Author:** ![rmagick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6de8d8/32.png) [@rmagick](https://www.ruby-forum.com/u/rmagick)\
**Post date:** [November 21, 2005, 7:49pm UTC](https://www.ruby-forum.com/t/how-to-get-font-info-on-nix/48501/4 "2005-11-21T19:49:57Z")

</div>

On 11/21/05, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> It should at least work anywhere that’s got a modern Gtk.  
> Or xterm, recent xterms can use TrueType fonts, and they are linked  
> with fontconfig.  
> I only wish more Xlib applications did that 🙂

Thanks

Michal

–  
Support the freedom of music!  
Maybe it’s a weird genre … but weird is _not_ illegal.  
Maybe next time they will send a special forces commando  
to your picnic … because they think you are weird.  
[www.music-versus-guns.org](http://www.music-versus-guns.org)[http://en.policejnistat.cz](http://en.policejnistat.cz)

---

<div class="post-metadata">

**Author:** ![rmagick](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/6de8d8/32.png) [@rmagick](https://www.ruby-forum.com/u/rmagick)\
**Post date:** [November 22, 2005, 2:04am UTC](https://www.ruby-forum.com/t/how-to-get-font-info-on-nix/48501/5 "2005-11-22T02:04:35Z")

</div>

Austin Z. wrote:

> Take a look near the top of the PDF::Writer main file  
> (lib/pdf/writer.rb) and you’ll see what I do in order to find existing  
> fonts. It’s imperfect and somewhat untested, but you may need to parse  
> the fonts themselves to determine the relevant information.

Verrrry interesting…Thanks, Austin!
