summaryrefslogtreecommitdiff
path: root/write.c
diff options
context:
space:
mode:
authorChristopher Zimmermann <madroach@gmerlin.de>2020-08-16 21:56:15 +0200
committerPeter Hutterer <peter.hutterer@who-t.net>2020-09-22 22:00:38 +0000
commitca9ad454496bebbc37125959d049cf2173c07c2a (patch)
treef0710170f3eb15ef470640eaa177476528c9d9e7 /write.c
parent0447b81053d4ccaa1e1b0087bf6076abae431cae (diff)
use PIXEL_SIZE to calculate lineGap
Diffstat (limited to 'write.c')
-rw-r--r--write.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/write.c b/write.c
index 79b2c08..90a1d5b 100644
--- a/write.c
+++ b/write.c
@@ -238,7 +238,15 @@ fontMetrics(FontPtr font)
if (count) font->metrics.awidth = sumAwidth / count;
- font->metrics.height = UNDEF /* TODO */;
+ font->metrics.height = TWO_SIXTEENTH;
+
+ if(font->pxMetrics.size == UNDEF) {
+ font->pxMetrics.size = font->pxMetrics.height;
+ font->metrics.size = font->metrics.height;
+ }
+
+ font->metrics.size = font->pxMetrics.size
+ * TWO_SIXTEENTH / font->pxMetrics.height;
if(font->pxMetrics.ascent == UNDEF) {
font->metrics.ascent = font->metrics.maxY;
@@ -943,7 +951,7 @@ writehhea(FILE* out, FontPtr font)
writeULONG(out, 0x00010000); /* version */
writeSHORT(out, FONT_UNITS_CEIL(font->metrics.ascent)); /* ascender */
writeSHORT(out, -FONT_UNITS_CEIL(font->metrics.descent)); /* descender */
- writeSHORT(out, 0); /* lineGap */
+ 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 ?
* https://docs.microsoft.com/en-us/typography/opentype/spec/hhea */
@@ -1121,8 +1129,8 @@ writeOS2(FILE* out, FontPtr font)
writeUSHORT(out, 0x20); /* usFirstCharIndex; */
writeUSHORT(out, 0xFFFD); /* usLastCharIndex; */
writeUSHORT(out, FONT_UNITS_CEIL(font->metrics.ascent)); /* sTypoAscender; */
- writeUSHORT(out, -FONT_UNITS_CEIL(font->metrics.descent)); /* sTypoDescender; */
- writeUSHORT(out, 0); /* sTypoLineGap; */
+ writeSHORT(out, -FONT_UNITS_CEIL(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; */