diff options
author | Christopher Zimmermann <madroach@gmerlin.de> | 2020-07-30 22:46:50 +0200 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2020-09-22 22:00:38 +0000 |
commit | 747c58aa17b9adc016aed0caab049417a20f0b22 (patch) | |
tree | cab6f2638fe7f96ab289e349ff0fdbad96842827 | |
parent | 64e7f386baf69fa6857047fc8ad9b4cd9a8185f1 (diff) |
calculate capHeight and xHeight as recommended
-rw-r--r-- | write.c | 26 |
1 files changed, 13 insertions, 13 deletions
@@ -262,23 +262,23 @@ fontMetrics(FontPtr font) font->pxMetrics.descent * TWO_SIXTEENTH / font->pxMetrics.height; - fprintf(stderr, "ascent %d ascentpx %d descent %d descentpx %d\n", - font->metrics.ascent, - font->pxMetrics.ascent, - font->metrics.descent, - font->pxMetrics.descent); - - if(font->pxMetrics.capHeight == UNDEF) - /* TODO get ascent of letter 'X' - how to do lookups of ascii codes ? */ - font->metrics.capHeight = font->metrics.ascent; + if(font->pxMetrics.capHeight == UNDEF) { + if(glyphMetrics(font, 'X', NULL, NULL, NULL, NULL, &font->metrics.capHeight) != 1) + font->metrics.capHeight = font->metrics.ascent; + font->pxMetrics.capHeight = + font->metrics.capHeight * font->pxMetrics.height / TWO_SIXTEENTH; + } else font->metrics.capHeight = font->pxMetrics.capHeight * TWO_SIXTEENTH / font->pxMetrics.height; - if(font->pxMetrics.xHeight == UNDEF) - /* TODO get ascent of letter 'x' - how to do lookups of ascii codes ? */ - font->metrics.xHeight = font->metrics.ascent * 2 / 3; + if(font->pxMetrics.xHeight == UNDEF) { + if(glyphMetrics(font, 'x', NULL, NULL, NULL, NULL, &font->metrics.xHeight) != 1) + font->metrics.xHeight = font->metrics.capHeight * 2 / 3; + font->pxMetrics.xHeight = + font->metrics.xHeight * font->pxMetrics.height / TWO_SIXTEENTH; + } else font->metrics.xHeight = font->pxMetrics.xHeight @@ -295,10 +295,10 @@ fontMetrics(FontPtr font) } if(font->pxMetrics.underlineThickness == UNDEF) + /* make sure thickness is at least one pixel. */ /* TODO: this could be refined according to * X Logical Font Description Conventions (xlfd.txt) * by also considering the font weight. */ - /* make sure thickness is at least one pixel. */ font->metrics.underlineThickness = TWO_SIXTEENTH / (font->pxMetrics.height < 9 ? font->pxMetrics.height : 9); |