Skip to content

Commit

Permalink
using font descriptor to compute font metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
Frulenzo committed Mar 31, 2016
1 parent e47993b commit 78dc04c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/java/be/quodlibet/boxable/utils/FontUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ public static float getHeight(final PDFont font, final float fontSize) {
* @throws IOException
*/
private static void createFontMetrics(final PDFont font) throws IOException {
final float base = font.getHeight("a".codePointAt(0)) / 1000;
final float ascent = font.getHeight("d".codePointAt(0)) / 1000 - base;
final float descent = font.getHeight("g".codePointAt(0)) / 1000 - base;
fontMetrics.put(font.getName(), new FontMetrics(base + ascent + descent, ascent, -descent));
final float base = font.getFontDescriptor().getXHeight() / 1000;
final float ascent = font.getFontDescriptor().getAscent() / 1000 - base;
final float descent = font.getFontDescriptor().getDescent() / 1000;
fontMetrics.put(font.getName(), new FontMetrics(base + ascent - descent, ascent, descent));
}
}

0 comments on commit 78dc04c

Please sign in to comment.