diff options
author | Jan Friesse <jfriesse@gmail.com> | 2022-11-02 09:41:57 +0100 |
---|---|---|
committer | Marge Bot <emma+marge@anholt.net> | 2024-07-28 17:04:52 +0000 |
commit | e3971be7b20580a54b3c26281a5912433b9a7319 (patch) | |
tree | cfc40a3a126a33b90d40535f2cb555dcc1724bb3 /write.c | |
parent | 7532e3ad70441041395c77d12424edd31cf63a42 (diff) |
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: <https://gitlab.freedesktop.org/xorg/app/fonttosfnt/-/merge_requests/18>
Diffstat (limited to 'write.c')
-rw-r--r-- | write.c | 14 |
1 files changed, 7 insertions, 7 deletions
@@ -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; */ |