From 1fa97fdc6dc900728be8523be89096b4cb117d4d Mon Sep 17 00:00:00 2001 From: Christopher Zimmermann Date: Sun, 12 Jul 2020 15:36:18 +0200 Subject: provide version 5 OS/2 table this was an attempt to fix linespacing, which did not help, but would still keep it around to avoid double efforts. --- write.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/write.c b/write.c index 35b4e73..29bdf62 100644 --- a/write.c +++ b/write.c @@ -980,7 +980,7 @@ writeOS2(FILE* out, FontPtr font) { int i; - writeUSHORT(out, 0x0001); + writeUSHORT(out, 5); /* version */ writeSHORT(out, FONT_UNITS(font->metrics.awidth)); /* xAvgCharWidth; */ writeUSHORT(out, font->weight); /* usWeightClass; */ writeUSHORT(out, font->width); /* usWidthClass; */ @@ -1011,16 +1011,31 @@ writeOS2(FILE* out, FontPtr font) i |= 1 << 5; if (!i) i |= 1 << 6; +#ifndef NO_TYPO_METRICS + i |= 1 << 7; /* USE_TYPO_METRICS instead usWin metrics for line spacing. */ +#endif writeUSHORT(out, i); /* fsSelection; */ writeUSHORT(out, 0x20); /* usFirstCharIndex; */ writeUSHORT(out, 0xFFFD); /* usLastCharIndex; */ writeUSHORT(out, FONT_UNITS_CEIL(font->metrics.ascent)); /* sTypoAscender; */ writeUSHORT(out, FONT_UNITS_FLOOR(font->metrics.descent)); /* sTypoDescender; */ writeUSHORT(out, 0); /* sTypoLineGap; */ +#ifdef NO_TYPO_METRICS + writeUSHORT(out, FONT_UNITS_CEIL(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.minY)); /* usWinDescent; */ - writeULONG(out, 3); /* ulCodePageRange1; */ - writeULONG(out, 0); /* ulCodePageRange2; */ +#endif + writeULONG(out, 3); /* ulCodePageRange1; */ + writeULONG(out, 0); /* ulCodePageRange2; */ + writeSHORT(out, FONT_UNITS_CEIL(font->metrics.xHeight)); /* sxHeight; */ + writeSHORT(out, FONT_UNITS_CEIL(font->metrics.capHeight)); /* sCapHeight; */ + writeUSHORT(out, 0); /* usDefaultChar; */ + writeUSHORT(out, 20); /* usBreakChar; */ + writeUSHORT(out, 0); /* usMaxContext; */ + writeUSHORT(out, 0); /* usLowerOpticalPointSize; */ + writeUSHORT(out, 0xffff); /* usUpperOpticalPointSize; */ return 0; } -- cgit v1.2.3