-
Whereas pdf = Prawn::Document.new
puts pdf.width_of 'A'
puts pdf.width_of 'a'
puts pdf.height_of 'A'
puts pdf.height_of 'a' outputs
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
The width of each character has to be different because we need it to calculate the width of a line. However, the height of a line should not depend on the characters therein. For example, a line with just I don't know if Prawn provides direct access to the font to get the real height but you can always fall back to ttfunk to get the correct values. |
Beta Was this translation helpful? Give feedback.
-
As @gettalong mentioned, you can turn to TTFunk for specific character metrics but you won't get exact bounding boxes of glyphs. Most fonts try to keep character metrics height the same to have consistent line height. IF you would like exact bounding boxes of glyps then, unfortunately, I don't believe TTFunk will be of much help as it doesn't parse glyph tables because in Praws we don't use that information for anything so we don't spend time on parsing it. |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
I have looked at the code of the font implementation of Prawn:
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
I got it working! Here is the code (using a font that is available on my system). Thank you for your help.