Lower case numbers?

128 views
Skip to first unread message

Henrik N

unread,
Oct 18, 2009, 4:09:22 AM10/18/09
to Prawn
Some fonts, e.g. "Garamond 3", come (as I understand it) with support
for lower case numbers, also known as old style figures. See
http://devworld.apple.com/textfonts/Tools/tooldir/TrueEdit/Documentation/TE/TE3numbers.html
for some more info.

You can get them in Photoshop by making the numbers small-caps, or in
Pages.app by choosing number case in the typography settings.

I'm guessing there is no support for this in Prawn?

I'm quite familiar with Ruby but not with PDF and TTF internals. Could
someone who is point me in the right direction if I want to have a
stab at this?

Brett Neumeier

unread,
Oct 18, 2009, 1:27:15 PM10/18/09
to prawn...@googlegroups.com
On Sun, Oct 18, 2009 at 3:09 AM, Henrik N <hen...@nyh.se> wrote:
>
> Some fonts, e.g. "Garamond 3", come (as I understand it) with support
> for lower case numbers, also known as old style figures. [..]

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)

Henrik Nyh

unread,
Oct 18, 2009, 1:36:17 PM10/18/09
to prawn...@googlegroups.com
On Sun, Oct 18, 2009 at 19:27, Brett Neumeier <bneu...@gmail.com> wrote:
>
> On Sun, Oct 18, 2009 at 3:09 AM, Henrik N <hen...@nyh.se> wrote:
>>
>> Some fonts, e.g. "Garamond 3", come (as I understand it) with support
>> for lower case numbers, also known as old style figures. [..]
>
> What font files do you have?
>
> ...

> 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.

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!

Brett Neumeier

unread,
Oct 18, 2009, 9:42:53 PM10/18/09
to prawn...@googlegroups.com
On Sun, Oct 18, 2009 at 12:36 PM, Henrik Nyh <hen...@nyh.se> wrote:
> 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.

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,

Gregory Brown

unread,
Oct 18, 2009, 9:45:59 PM10/18/09
to prawn...@googlegroups.com
On Sun, Oct 18, 2009 at 9:42 PM, Brett Neumeier <bneu...@gmail.com> wrote:
>
> On Sun, Oct 18, 2009 at 12:36 PM, Henrik Nyh <hen...@nyh.se> wrote:
>> 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.
>
> Are you sure that isn't an OpenType font? I had not thought that
> TrueType fonts supported multiple character shapes within a single
> font.

DFont suitcases allow for multiple fonts within a single file, which
Prawn supports.
But we don't have OpenType support.

-greg

James Healy

unread,
Oct 18, 2009, 9:49:27 PM10/18/09
to prawn...@googlegroups.com
Gregory Brown wrote:
> DFont suitcases allow for multiple fonts within a single file, which
> Prawn supports.
> But we don't have OpenType support.

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

Brett Neumeier

unread,
Oct 19, 2009, 10:37:09 AM10/19/09
to prawn...@googlegroups.com
James Healy wrote:
> 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?

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.

Henrik Nyh

unread,
Oct 19, 2009, 2:54:09 PM10/19/09
to prawn...@googlegroups.com

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!

James Healy

unread,
Oct 19, 2009, 6:29:57 PM10/19/09
to prawn...@googlegroups.com
Brett Neumeier wrote:
> 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.

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

Brett Neumeier

unread,
Oct 19, 2009, 11:13:58 PM10/19/09
to prawn...@googlegroups.com
On Mon, Oct 19, 2009 at 5:29 PM, James Healy <ji...@deefa.com> wrote:
>> 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.

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.)

Reply all
Reply to author
Forward
0 new messages