Forum: Ruby How to get font info on *nix?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
rmagick (Guest)
on 2005-11-21 17:07
(Received via mailing list)
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) but I'm
not sure that's right.
halostatue (Guest)
on 2005-11-21 18:20
(Received via mailing list)
On 11/21/05, removed_email_address@domain.invalid 
<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) 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
mental (Guest)
on 2005-11-21 19:33
(Received via mailing list)
Quoting "removed_email_address@domain.invalid" 
<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) 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
hramrach (Guest)
on 2005-11-21 20:49
(Received via mailing list)
On 11/21/05, removed_email_address@domain.invalid 
<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://en.policejnistat.cz
Timothy H. (Guest)
on 2005-11-22 03:04
(Received via mailing list)
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!
This topic is locked and can not be replied to.