I am using the to-quad conversion in libspiro-js directly instead of it in node-sfnt.
This commit is contained in:
parent
9c3f165b1b
commit
563720db82
|
@ -421,16 +421,16 @@ define [buildFont para recursive] : begin
|
|||
if closed
|
||||
then
|
||||
local g : new Glyph
|
||||
libspiro.spiroToBezierOnContext [lhs.slice 0 (-1)] true g
|
||||
libspiro.spiroToBezierOnContext [lhs.slice 0 (-1)] true g true
|
||||
local lhsContour g.contours.0
|
||||
set g.contours {}
|
||||
libspiro.spiroToBezierOnContext [rhs.reverse :.slice 0 (-1)] true g
|
||||
libspiro.spiroToBezierOnContext [rhs.reverse :.slice 0 (-1)] true g true
|
||||
local rhsContour g.contours.0
|
||||
set g.contours {[lhsContour.concat rhsContour]}
|
||||
else
|
||||
local g : new Glyph
|
||||
lhs.0.type = rhs.0.type = lhs.(lhs.length - 1).type = rhs.(rhs.length - 1).type = 'corner'
|
||||
libspiro.spiroToBezierOnContext [lhs.concat : rhs.reverse] true g
|
||||
libspiro.spiroToBezierOnContext [lhs.concat : rhs.reverse] true g true
|
||||
return g.contours
|
||||
define [spiro-outline] : let [k : {}.slice.call arguments 0] : glyph-construction
|
||||
local {.knots knots .closed closed .lastafs lastafs} : prepareSpiroKnots k this
|
||||
|
|
|
@ -552,8 +552,7 @@ create-glyph 'longs.upright' : glyph-construction
|
|||
widths.center
|
||||
flat (MIDDLE - FBALANCE) 0 [heading UPWARD]
|
||||
curl (MIDDLE - FBALANCE) (CAP - FHOOK)
|
||||
flat (MIDDLE - FBALANCE + HOOKX - 0.01) (CAP - HALFSTROKE - fovershoot) [heading RIGHTWARD]
|
||||
curl (MIDDLE - FBALANCE + HOOKX) (CAP - HALFSTROKE - fovershoot) [heading RIGHTWARD]
|
||||
straight.right.end (MIDDLE - FBALANCE + HOOKX) (CAP - HALFSTROKE - fovershoot) [heading RIGHTWARD]
|
||||
|
||||
define [eshHook attach] : glyph-construction
|
||||
include : create-stroke
|
||||
|
@ -567,12 +566,10 @@ define [LongSShape top bottom hookx hooky fine] : glyph-construction
|
|||
local w [fallback fine STROKE]
|
||||
include : spiro
|
||||
widths.center w
|
||||
flat (MIDDLE - hookx) (bottom + w / 2 + fovershoot) [heading RIGHTWARD]
|
||||
curl (MIDDLE - hookx + 0.01) (bottom + w / 2 + fovershoot) [heading RIGHTWARD]
|
||||
straight.right.start (MIDDLE - hookx) (bottom + w / 2 + fovershoot) [heading RIGHTWARD]
|
||||
flat MIDDLE (bottom + hooky)
|
||||
curl MIDDLE (top - hooky)
|
||||
flat (MIDDLE + hookx - 0.01) (top - w / 2 - fovershoot) [heading RIGHTWARD]
|
||||
curl (MIDDLE + hookx) (top - w / 2 - fovershoot) [heading RIGHTWARD]
|
||||
straight.right.end (MIDDLE + hookx) (top - w / 2 - fovershoot) [heading RIGHTWARD]
|
||||
|
||||
create-glyph 'longs.italic' : glyph-construction
|
||||
set-width WIDTH
|
||||
|
|
|
@ -33,19 +33,16 @@ if len(sys.argv) <= 3:
|
|||
font.unlinkReferences()
|
||||
|
||||
# Outline simplify
|
||||
print "Simplify, pass 1: ", font.fontname
|
||||
print "Simplify: ", font.fontname
|
||||
font.layers["Fore"].is_quadratic = False
|
||||
font.selection.all()
|
||||
font.simplify(font.em / 2000.0, ("smoothcurves", "choosehv"), 0.1)
|
||||
|
||||
print "Simplify, pass 2: ", font.fontname
|
||||
print "Finalize: ", font.fontname
|
||||
oldem = font.em
|
||||
font.em = 1000
|
||||
font.layers["Fore"].is_quadratic = True
|
||||
font.transform(psMat.skew(-font.italicangle / 180 * math.pi))
|
||||
|
||||
# Feature merging and output
|
||||
print "Finalize: ", font.fontname
|
||||
font.em = oldem
|
||||
|
||||
font.canonicalContours()
|
||||
|
|
|
@ -65,8 +65,8 @@ for(var j = 0; j < ttf.glyf.length; j++){
|
|||
var rymin = (upm / targetupm) * Math.round(ymin * targetupm / upm);
|
||||
var rymax = (upm / targetupm) * Math.round(ymax * targetupm / upm);
|
||||
for(var l = 0; l < c.length; l++){
|
||||
c[l].y = (upm / targetupm) * Math.round(mix(rymin, rymax, ratio(ymin, c[l].y, ymax)) * targetupm / upm)
|
||||
c[l].x = (upm / targetupm) * Math.round((mix(rxmin, rxmax, ratio(xmin, c[l].x, xmax)) - c[l].y * skew) * targetupm / upm)
|
||||
c[l].y = (upm / targetupm) * (mix(rymin, rymax, ratio(ymin, c[l].y, ymax)) * targetupm / upm)
|
||||
c[l].x = (upm / targetupm) * ((mix(rxmin, rxmax, ratio(xmin, c[l].x, xmax)) - c[l].y * skew) * targetupm / upm)
|
||||
}
|
||||
glyph.contours[k] = c.filter(function(p){ return !p.removable })
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user