The svgs will no longer contain NaNs.

This commit is contained in:
be5invis 2016-01-14 08:42:33 +08:00
parent fc799f50c9
commit c2cfbb4061
2 changed files with 16 additions and 1 deletions

View File

@ -133,11 +133,25 @@ if(argv.ttf) (function(){
if(argv.svg) (function(){
console.log(' Writing outline as SVG -> ' + argv.svg);
function cov(x){ return Math.round(x * 10000) / 10000 };
var foundNaN = false;
var glyfname = '';
function cov(x) {
if(!isFinite(x)){
if(!foundNaN) {
console.log("*** NaN value found in " + argv.svg + '(' + glyfname + ')' + " ***")
foundNaN = true
}
return 0
}
return Math.round(x * 10000) / 10000
};
function mix(a, b, p){ return a + (b - a) * p };
function toSVGPath(glyph){
var buf = '';
foundNaN = false;
glyfname = glyph.name;
if(glyph.contours) for(var j = 0; j < glyph.contours.length; j++) {
var contour = glyph.contours[j];
var lx = 0;

View File

@ -441,6 +441,7 @@ define [determineMixR w v u sw] : begin
local adjust : clamp 0.975 1 (1 - (iwidth / idepth - 2) * 0.0125)
#console.log iwidth idepth (iwidth / idepth) adjust
r = r * adjust
if (r < 0.5) : set r 0.5
return r
define nHookSegments 12