File 0009-provide-version-5-OS-2-table.patch of Package fonttosfnt.20912

From 7585bbe83fecb53077e95eed9f151b2d7558e4b7 Mon Sep 17 00:00:00 2001
From: Christopher Zimmermann <madroach@gmerlin.de>
Date: Sun, 12 Jul 2020 15:36:18 +0200
Subject: [PATCH 09/14] 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 99d0aba..971190f 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; */
@@ -1008,16 +1008,31 @@ writeOS2(FILE* out, FontPtr font)
     if (font->flags & FACE_ITALIC)	i |= 1 << 0;
     if (font->flags & FACE_BOLD)	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;
 }
 
-- 
2.28.0

openSUSE Build Service is sponsored by