What font files do you have?
If you have separate ttf fonts for garamond (normal) and garamond-sc
(small caps and oldstyle figures), then it's not a problem: just
switch fonts and you'll get the non-lining digits. You can use
prawn-format to make the process more seamless (define a tag <osf>
that switches to Garamond-SC fonts, or something like that).
If you have postscript type-1 fonts (pfb and pfm/afm files), you
should convert them to truetype. I do this in linux using fontforge.
If you have a single truetype font file that contains the glyphs for
both lining and non-lining digits, I'm not sure how you'd do it.
Hope this helps!
bn
--
Brett Neumeier (bneu...@gmail.com)
Yeah, I'm afraid that's my situation. Single TTF that contains both
lining and non-lining. Perhaps I could extract them into a separate
font somehow.
Thanks a lot for the input!
Are you sure that isn't an OpenType font? I had not thought that
TrueType fonts supported multiple character shapes within a single
font.
I believe that FontForge (http://fontforge.sourceforge.net) can edit
both opentype and truetype fonts, so you could probably open your
Garamond font in fontforge, pick the glyphs you want, and save the
result as a truetype font (regardless of what kind of input font it
actually is).
I use fontforge in linux. It is also apparently available for mac and
can be run in MS Windows using Cygwin...so you can probably get
fontforge working if you'd like to try.
Cheers,
DFont suitcases allow for multiple fonts within a single file, which
Prawn supports.
But we don't have OpenType support.
-greg
So maybe these alternative number glyphs are available via a different
Unicode codepoint? My font foo is weak, but I assume fontforge or
something can be used to examine the glyphs and what codepoints
reference them?
-- James Healy <ji...@deefa.com> Mon, 19 Oct 2009 12:49:14 +1100
I don't know how truetype fonts actually work. In postscript type 1
fonts, the font contains an arbitrary number of named glyphs and a
default encoding vector that specifies what glyphs are associated with
numeric positions. You can then create additional encoding vectors
that map other glyphs into the active set without touching the font
itself. If truetype has the same kind of facility, then you would just
need to learn how to evoke it.
In Unicode, I *believe* there are no code points designated for
non-lining digits. They are probably in a private-use area in your
Garamond font.
Fontforge is a font editor. It lets you do anything at all with a
font...but all I've used it for, personally, is converting fonts from
one format to another, so I can't outline the steps you'd need to use
to move glyphs around within a font.
Like James Healy, my font fu is weak, bu I poked around a bit in Fontforge.
Selecting the non-lining 0 shows U+F643, 1 is U-F644, through 9 which is U+F64C.
So I can get them by using those codepoints:
https://gist.github.com/da21359077f03472fc7a
Googling it a bit, it seems only Adobe Pro fonts use these codepoints for this:
http://en.wikipedia.org/wiki/Text_figures
So I don't see that this is something that should be built into Prawn,
since it wouldn't generalize well. Solved in my case at least. Thanks
a lot!
Truetype fonts are similar. The glyphs have arbitary numbers, and there
are encoding tables that map each encoding value to a glyph. Prawn only
uses the Unicode table to lookup glyphs, so if the glyphs aren't
referenced there it won't be possible to use them.
> In Unicode, I *believe* there are no code points designated for
> non-lining digits. They are probably in a private-use area in your
> Garamond font.
Looks like you're on the money here. At least it's possible to get them
in this case. It's a shame it won't work with all fonts though.
-- James Healy <ji...@deefa.com> Tue, 20 Oct 2009 09:27:39 +1100
Presumably, you could use fontforge (or something similar) to change
the unicode character map so that the glyphs mapped to the normal
numeric code points are the non-lining digits, though -- that would be
a general-purpose solution, wouldn't it?
Alternatively, you could probably add an additional character map
directly to the PDF dictionary, and then set the font to use that
character map. I don't know you'd do that in prawn -- probably use a
method to write appropriate commands directly to the PDF stream.
(There's always a way to get things to work! At least when you're
using open file formats and open-source code.)