prawn icon indicating copy to clipboard operation
prawn copied to clipboard

TTF Overflowing Bounding Box

Open mrj opened this issue 8 years ago • 1 comments

If, for example, I render the Rock Salt Google TrueType font in a bounding_box (or text_box) with valign :top, it overflows the box:

Prawn Screencap

A similar thing happens with valign :bottom — as well as :center if the box is short enough.

Also, if I set the font height to be 3mm and the bounding box height to be 3mm, the text doesn't fit, no text is rendered, and an extra page is generated. To avoid this for the Rock Salt font I had to make the box height 4% bigger.

I'd like to get the top of the font aligned to the top of the box in the Prawn-generated PDF to match the web-browser rendering, which correctly aligns the top of this font to the top of a surrounding div.

mrj avatar Mar 24 '17 03:03 mrj

@mrj I gather this is still a problem? The image path seems to be invalid, so it is hard to see what's wrong.

However, the problem may be that when you set a font height of 3mm a line of text is larger because Prawn doesn't just use the height of the individual characters but actually the font's ascender and descender. Additionally, fonts may contain characters that go beyond the ascender and descender which would also be a problem.

gettalong avatar Jun 23 '17 16:06 gettalong

I guess this is a font issue.

image

Glyphs are going way outside of specified bounding boxes. Prawn uses the metrics specified in the font, not the actual extents of glyph outlines.


Feel free to reopen and provide a clarification if my guess is incorrect.

pointlessone avatar Jan 16 '24 13:01 pointlessone