On 17.05.2006 02:02:52 Manuel Mall wrote: > On Tuesday 16 May 2006 19:58, Jeremias Maerki wrote: > > Some background on my latest change. I found out that certain > > TrueType fonts were off vertically inside their line area. It turned > > out it has to do with different interpretations of the "ascender" and > > descender" values which are part of font metrics and which FOP uses > > to determine the baseline placement. FOP currently works with the > > assumption that the ascender+descender fit into the "em box". > > However, in some TrueType fonts the ascender is sometimes given as > > the maximum elevation of a font which can go way beyond the em box. > > BTW, this is always true for Java2D/AWT which makes determining the > > baseline difficult. I've recently implemented similar "hacks" in the > > AWT font metrics adapter which I'll commit shortly. > > > > You can see the effect of rev 406917 here: > > http://people.apache.org/~jeremias/fop/font-metrics-sandbox.fop.trunk > >.before.pdf > > http://people.apache.org/~jeremias/fop/font-metrics-sandbox.fop.trunk > >.after.pdf The second and third lines are painted using TrueType > > fonts, the first is a base 14 font and the last a Type 1 font. > > > > IMO, my change is an improvement but not a clean fix. I think > > TrueType has better information on the baseline somewhere (havn't > > found it, yet). I didn't look closer into the cases where multiple > > accents are stacked on a glyph. That's basically the reason why the > > fonts can go beyond the em box. At some point we may need to revisit > > our model of line building to accomodate these glyphs. I guess I have > > to buy a book about typography one day... :-) > > Your fix triggered me looking into the specs and some actual ttf files > and I can't make proper sense of it all as well. The whole vertical > font metrics area seem to be quite messy, see for example: > http://typophile.com/wiki/Vertical%20Metrics%20How-To
Very interesting article. What's important for us is that the hhea.lineGap value is uninteresting/irrelevant for us since we have the line-height property (default to 1.2) which we use for baseline-to-baseline measurement. That means we can't really follow the recommendation to only use OS/2.winAscender and OS/2.winDescender. :-( > I don't know anything about LaTeX. Does it understand TrueType fonts? If > so would it be worthwhile to check its source code? I don't think so. I can't find any reference. But I've never worked with LaTeX. > Also do we know what Foray Fonts does? Prefers the OS/2.sTypeAscender over hhea.Ascender just like FOP did before my patch. http://svn.sourceforge.net/viewcvs.cgi/foray/trunk/foray/foray-font/src/java/org/foray/font/format/TTFFont.java?view=markup > Until someone comes up with a better (cleaner?) solution to determine > the actual baseline position for a given truetype / opentype font your > patch looks good to me. > > <snip/> > > > > Jeremias Maerki > > Manuel Jeremias Maerki
