Added fix for sxHeight and sCapHeight.

This commit is contained in:
be5invis 2015-09-18 22:53:53 +08:00
parent 8e8e27f144
commit ebaa4fb807
2 changed files with 9 additions and 0 deletions

View File

@ -470,6 +470,7 @@ define [buildFont para recursive] : begin {
set font.hhea.lineGap [CAP * 0.2]
set font.'OS/2'.sTypoLineGap [CAP * 0.2]
set font.'OS/2'.sxHeight XH
set font.'OS/2'.sCapHeight CAP
set font.post.italicAngle [0 - para.italicangle]
}
@ -524,6 +525,7 @@ define [buildFont para recursive] : begin {
set font.hhea.lineGap : upmscale * font.hhea.lineGap
set font.'OS/2'.sTypoLineGap : upmscale * font.'OS/2'.sTypoLineGap
set font.'OS/2'.sxHeight : upmscale * font.'OS/2'.sxHeight
set font.'OS/2'.sCapHeight : upmscale * font.'OS/2'.sCapHeight
if [upmscale != 1] : foreach glyph [items-of glyphList] : begin {
glyph.advanceWidth = glyph.advanceWidth * upmscale

View File

@ -1,6 +1,11 @@
var path = require('path');
var fs = require('fs');
var TTFReader = require('node-sfnt').TTFReader;
var TTFWriter = require('node-sfnt').TTFWriter;
var toml = require('toml');
var param = toml.parse(fs.readFileSync(path.join(path.dirname(require.main.filename), 'parameters.toml'), 'utf-8'))
function toArrayBuffer(buffer) {
var length = buffer.length;
var view = new DataView(new ArrayBuffer(length), 0, length);
@ -36,5 +41,7 @@ function writettf(ttf, file){
var ttf = readttf(process.argv[2]);
// Fixes xAvgCharWidth
ttf['OS/2'].xAvgCharWidth = ttf.head.unitsPerEm / 2; // 0.5em
ttf['OS/2'].sxHeight = param.iosevka.xheight
ttf['OS/2'].sCapHeight = param.iosevka.cap
ttf.post.isFixedPitch = 1 // mono
fs.writeFileSync(process.argv[3], toBuffer(new TTFWriter(options).write(ttf)));