Is ruby pango right for this?

Hi all, and pardon me for posting right away! (there is no ettiquette
information at the listinfo page)

I have a task, which sounds simple enough but it is looking
surprisingly involved. I need to display some information about font
files: Mac & PC PostScript (type 1), Mac and PC TTF, and OpenType.

From all the PS/TTF files, I need the fontname (much preffered to be
as Mac displays it) and it’s weight/face details: I need to
concatenate the fontname/weights to things like “Neue Helvetica Black
Italic”, etc. But fonts seem to place/misplace names all throughout
the fontfile and a simple extraction of, for example the “postscript
full name” will usually show the wrong information.

I also need the glyphnames for any glyphs that appear in the font.

And I need the unicode, if available, so I can distinguish, for
example, latin characters from turkish, or symbol fonts (or OTFs,
etc). This last part is easy enough for me to look up from the
unicode range, I think.

It’s with opentype that things get funky. A single opentype font file
can have different faces, and different ligature substitutions for
small caps, subscripts, etc. (Its all defined in it’s layout tables)

I’m not looking forward to processing all this, it’s amazingly
complicated for such a simple thing. But I have to gather and process
all this information, and best I can tell there’s no tools around that
do this for me all in one package.

So I’m looking at Pango to do it – to me it’s just an added boon that
Ruby has a pango interface! But I’m wondering, does anyone know how
easy, or even possible this is? Can I get these informations all from
ruby-gnome2, for each of the font formats?

Thanks for reading!
Robbie


Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net’s Techsay panel and you’ll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

Hi,

I think you will be able to get some of the data you want like font
metrics or character set coverage but some others like the glyph names
are likely to be too low level for Pango. Also, one problem I can think
of is that Pango, through Fontconfig, is only aware of fonts in terms of
“what they provide” (languages covered, weight etc). You may not be able
to load fonts from their file name. If nobody answers you here, I would
suggest you ask your question on the pango list.

To me though, it seems clear that the way to go is the freetype library.
It can do exactly what you want for the font formats you have mentioned.
AFAIK however, there does not exist Ruby bindings for it. You will have
to take care of this :wink:

I am the author of a pure Ruby library to manipulate TrueType fonts.
http://rubyforge.org/projects/ttf-ruby/

It will do what you want for TrueType fonts. And you could possibly read
other fonts by converting them to TrueType with some utilities. This
library is still at an early stage though.

Mathieu

PS: I have tried the following and get a segfault at line 6:

require “pango”

fd = Pango::FontDescription.new
fd.family = “DejaVu Sans”

font = Pango::FontMap.new.load_font(Pango::Context.new, fd)

puts font.inspect

I am not sure whether it is a bug or I misunderstood something in the
API.

Mathieu

Robbie Muffin wrote:

Italic", etc. But fonts seem to place/misplace names all throughout
It’s with opentype that things get funky. A single opentype font file
easy, or even possible this is? Can I get these informations all from


ruby-gnome2-devel-en mailing list
[email protected]
ruby-gnome2-devel-en List Signup and Options


Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net’s Techsay panel and you’ll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

Hi,

In [email protected]
“[ruby-gnome2-devel-en] is ruby pango right for this?” on Tue, 16 Jan
2007 16:09:54 -0500,
“Robbie Muffin” [email protected] wrote:

From all the PS/TTF files, I need the fontname (much preffered to be
as Mac displays it)

require ‘gtk2’

families = Gtk::Invisible.new.pango_context.families
p families.collect {|family| family.name}

                and it's weight/face details: I need to

p families.collect {|family| family.faces {|face| face.name}}

as Mac displays it) and it’s weight/face details: I need to
concatenate the fontname/weights to things like “Neue Helvetica Black
Italic”, etc.

p families.collect {|family| family.faces {|face| face.describe.to_s}}

Thanks,

kou


Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net’s Techsay panel and you’ll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV

Hi,

In [email protected]
“Re: [ruby-gnome2-devel-en] is ruby pango right for this?” on Thu, 18
Jan 2007 16:25:44 +0100,
Mathieu B. [email protected] wrote:

I am not sure whether it is a bug or I misunderstood something in the API.

You shouldn’t instantiate Pango::FontMap directory. We can
only use modularized Pango::FontMap. (like Pango::FcFontMap,
Pango::CairoFcFontMap and so on.) They will be loaded
dynamically.

Thanks,

kou


Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net’s Techsay panel and you’ll get the chance to share
your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV