I've got a question about font height calculations because I'm having
issues with certain fonts not leaving enough vertical room in my
output. From a thread last October it looks like there's an assumption
that descent is a negative number:
http://groups.google.com/group/prawn-ruby/browse_thread/thread/a744d3e6c0d93cab/c4fa5fd5c46c815a?lnk=gst&q=font+height#c4fa5fd5c46c815a
1) :at specifies the baseline position. without the :at, you are
using the current y value which will specify the top edge of the text
(including a line gap)
2) font.height is equal to the ascender + descender + line_gap
3) and remember each font style will have different values for these
4) descender is actually a negative value so font.height is more
accurately ascender-descender+line_gap
I am working with a font (Lucida Fax) that has a positive descent
specified. Is that a violation of a font standard, or should prawn be
tolerant of this and negate the descent if it's positive? I imagine
this would be an easy enough change, and I'll probably patch it in to
get this working if so, but I would like to know if this is something
that I should contribute back, or if this is an aberration?
Here's the output of ttfunk for Lucida Fax (that renders jumbled-
vertically), followed by MS gothic (which renders fine) - note the
sign difference on the descender field
ruby example.rb ../ruby-pdf/LucidaFaxRegular.ttf
-- FONT ------------------------------------
revision : 000100c4
name : Lucida Fax Regular, Lucida Fax, Lucida Fax, Lucida Fax
Regular, Lucida Fax, Lucida Fax, Lucida Fax, Lucida Fax, Lucida Fax,
Lucida Fax, Lucida Fax, Lucida Fax, Lucida Fax, Lucida Fax
family : Lucida Fax, Lucida Fax
subfamily : Regular, normal, Standard, Regular, Normal, Normaali,
Normal, Normale, Standaard, Normal, Normal, Normal, Normal, Normal
postscript: LucidaFax
-- FONT METRICS ----------------------------
units/em : 2048
ascent : 1579
descent : 420
line gap : 49
bbox : (-592,-420)-(2100,1925)
-- SIMPLE CHARACTER -> GLYPH LOOKUP --------
character : ☜
character code: 9756
glyph id : 0
glyph type : simple
glyph size : 78b
glyph bbox : (128,0)-(896,1480)
-- COMPOUND CHARACTER -> GLYPH LOOKUP ------
character : ë
character code: 235
glyph id : 115
glyph type : compound
glyph size : 46b
glyph bbox : (123,-25)-(1004,1456)
components : 2 [72, 142]
ruby example.rb "/Users/jkk/Library/Fonts/MS Gothic.ttf"
-- FONT ------------------------------------
revision : 0002851f
name : MS Gothic, ?l?r ?S?V?b?N, MS Gothic, ?-?3 0?0?0?0?
family : MS Gothic, ?l?r ?S?V?b?N, MS Gothic, ?-?3 0?0?0?0?
subfamily : Regular, Regular, Regular, jn?
postscript: MS-Gothic
-- FONT METRICS ----------------------------
units/em : 256
ascent : 220
descent : -36
line gap : 0
bbox : (-31,-35)-(255,220)
-- SIMPLE CHARACTER -> GLYPH LOOKUP --------
character : ☜
character code: 9756
glyph id : 1805
glyph type : simple
glyph size : 396b
glyph bbox : (9,33)-(243,145)
-- COMPOUND CHARACTER -> GLYPH LOOKUP ------
character : ë
character code: 235
glyph id : 173
glyph type : simple
glyph size : 180b
glyph bbox : (13,2)-(115,171)
thanks for your insights.