From e3971be7b20580a54b3c26281a5912433b9a7319 Mon Sep 17 00:00:00 2001 From: Jan Friesse Date: Wed, 2 Nov 2022 09:41:57 +0100 Subject: Use FONT_UNITS_FLOOR for ascent/descent Before version 1.49.3 the pango was using (probably) values from BLC table, since 1.49.3 pango uses harfbuzz for metrics and it seems harfbuzz is using OS2 table. Result is font with 1px extra for ascend/descent. Solution seems to be to use FONT_UNITS_FLOOR instead of FONT_UNITS_CEIL when storing file. Fixes: #7 Part-of: --- write.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'write.c') diff --git a/write.c b/write.c index b1397ff..fda4d21 100644 --- a/write.c +++ b/write.c @@ -941,8 +941,8 @@ writehhea(FILE* out, FontPtr font) degreesToFraction(font->italicAngle, &num, &den); writeULONG(out, 0x00010000); /* version */ - writeSHORT(out, FONT_UNITS_CEIL(font->metrics.ascent)); /* ascender */ - writeSHORT(out, -FONT_UNITS_CEIL(font->metrics.descent)); /* descender */ + writeSHORT(out, FONT_UNITS_FLOOR(font->metrics.ascent)); /* ascender */ + writeSHORT(out, -FONT_UNITS_FLOOR(font->metrics.descent)); /* descender */ writeSHORT(out, FONT_UNITS(font->metrics.size - font->metrics.ascent - font->metrics.descent)); /* lineGap */ writeUSHORT(out, FONT_UNITS(font->metrics.maxAwidth)); /* advanceWidthMax */ /* TODO: the next three are not calculated according to spec, are they ? @@ -1116,14 +1116,14 @@ writeOS2(FILE* out, FontPtr font) writeUSHORT(out, i); /* fsSelection; */ writeUSHORT(out, 0x20); /* usFirstCharIndex; */ writeUSHORT(out, 0xFFFD); /* usLastCharIndex; */ - writeUSHORT(out, FONT_UNITS_CEIL(font->metrics.ascent)); /* sTypoAscender; */ - writeSHORT(out, -FONT_UNITS_CEIL(font->metrics.descent)); /* sTypoDescender; */ + writeUSHORT(out, FONT_UNITS_FLOOR(font->metrics.ascent)); /* sTypoAscender; */ + writeSHORT(out, -FONT_UNITS_FLOOR(font->metrics.descent)); /* sTypoDescender; */ writeSHORT(out, FONT_UNITS(font->metrics.size - font->metrics.ascent - font->metrics.descent)); /* sTypoLineGap */ #ifdef NO_TYPO_METRICS - writeUSHORT(out, FONT_UNITS_CEIL(font->metrics.ascent)); /* usWinAscent; */ - writeUSHORT(out, FONT_UNITS_CEIL(font->metrics.descent)); /* usWinDescent; */ + writeUSHORT(out, FONT_UNITS_FLOOR(font->metrics.ascent)); /* usWinAscent; */ + writeUSHORT(out, FONT_UNITS_FLOOR(font->metrics.descent)); /* usWinDescent; */ #else - writeUSHORT(out, FONT_UNITS_CEIL(font->metrics.maxY)); /* usWinAscent; */ + writeUSHORT(out, FONT_UNITS_FLOOR(font->metrics.maxY)); /* usWinAscent; */ writeUSHORT(out, -FONT_UNITS_FLOOR(font->metrics.minY)); /* usWinDescent; */ #endif writeULONG(out, 3); /* ulCodePageRange1; */ -- cgit v1.2.3