Rebuild /B, /D, /P, /R, /five and /eight with sporos.

This commit is contained in:
be5invis 2015-08-18 01:07:56 +08:00
parent 0a005cae57
commit b6ca69bbaf
7 changed files with 106 additions and 74 deletions

View File

@ -356,13 +356,27 @@ define [vdual newid unicode id spacing] : create-glyph [fallback newid : 'double
apply-transform : Translate 0 [spacing / 2] apply-transform : Translate 0 [spacing / 2]
apply-transform : Italify apply-transform : Italify
} }
define [hookstart y] (.type 'interpolate' .af [lambda [before after] : begin {
define [hookend y] (.type 'interpolate' .af [lambda [before after] : begin { local atBottom : after.y > y
local ltr : after.x > before.x
before.x = before.x - OXHOOK * [if ltr [-1] 1]
local hv : archv
local mx [[mix after.x before.x SBALANCE] + [if atBottom 1 [-1]] * OMIDCOR_S]
return : list {
g4 mx y
hv.af.call this (.x mx .y y) after hv
}
}])
define [hookend y dontextend] (.type 'interpolate' .af [lambda [before after] : begin {
local atBottom : before.y > y local atBottom : before.y > y
local ltr : after.x > before.x local ltr : after.x > before.x
after.x = after.x + OXHOOK * [if ltr [-1] 1] after.x = after.x + OXHOOK * [if ltr [-1] 1]
local vh : arcvh local vh : arcvh
local mx [[mix before.x after.x SBALANCE] + [if atBottom 1 [-1]] * OMIDCOR_S] local mx [[mix before.x after.x SBALANCE] + [if atBottom 1 [-1]] * OMIDCOR_S]
if [!dontextend && atBottom && ltr] : begin {
after.x = after.x + TAILADJX * globalTransform.yx
after.y = after.y - TAILADJY * globalTransform.yx
}
return : list { return : list {
vh.af.call this before (.x mx .y y) vh vh.af.call this before (.x mx .y y) vh
g4 mx y g4 mx y

View File

@ -193,35 +193,30 @@ define [BShape top] : glyph-construction {
local tkappa [COKAPPA - 0.22] local tkappa [COKAPPA - 0.22]
local bkappa [COKAPPA - 0.2] local bkappa [COKAPPA - 0.2]
local turntop : [top + [bowl - STROKE]] / 2 local turntop : [top - [bowl - STROKE]] * 0.5
local turnbottom : bowl / 2 local turnbottom : bowl * 0.45
include : create-stroke include : spiro {
:.start-from [SB - O] top widths.rhs
:.heads-to RIGHTWARD flat [SB - O] top [heading RIGHTWARD]
:.set-width 0 STROKE curl [RIGHTSB - SB * 0.5 - turntop - OMIDCOR_S] top
:.line-to [RIGHTSB - SB * 0.5 - turnbottom] top archv
:.arc-hv-to [RIGHTSB - SB * 0.5] turntop g4 [RIGHTSB - SB * 0.5 - O] [mix top [bowl - STROKE] [SMOOTHB / [SMOOTHA + SMOOTHB]]]
:.arc-vh-to [RIGHTSB - SB * 0.5 - turnbottom] [bowl - STROKE] arcvh
:.line-to [SB - O] [bowl - STROKE] flat [RIGHTSB - SB * 0.5 - turntop + OMIDCOR_S] [bowl - STROKE]
:.heads-to LEFTWARD curl [SB - O] [bowl - STROKE] [heading LEFTWARD]
}
include : create-stroke include : spiro {
:.start-from [SB - O] 0 widths.rhs
:.heads-to RIGHTWARD flat [SB - O] bowl [heading RIGHTWARD]
:.set-width STROKE 0 curl [RIGHTSB - turnbottom - OMIDCOR_S] bowl
:.line-to [RIGHTSB - turnbottom] 0 archv
:.arc-hv-to RIGHTSB turnbottom g4 [RIGHTSB - O] [mix bowl 0 [SMOOTHB / [SMOOTHA + SMOOTHB]]]
:.arc-vh-to [RIGHTSB - turnbottom] bowl arcvh
:.line-to [SB - O] bowl flat [RIGHTSB - turnbottom + OMIDCOR_S] 0
:.heads-to LEFTWARD curl [SB - O] 0 [heading LEFTWARD]
}
include : create-stroke include : VBarLeft SB 0 top
:.start-from SB 0
:.heads-to UPWARD
:.set-width 0 STROKE
:.line-to SB top
:.heads-to UPWARD
} }
create-glyph 'B' : glyph-construction { create-glyph 'B' : glyph-construction {
set-width WIDTH set-width WIDTH
@ -257,7 +252,7 @@ define [PShape top] : glyph-construction {
local bowlBottom [[top - STROKE] * 0.55 - HALFSTROKE] local bowlBottom [[top - STROKE] * 0.55 - HALFSTROKE]
local turn : mix bowlTop bowlBottom [SMOOTHB / [SMOOTHA + SMOOTHB]] local turn : mix bowlTop bowlBottom [SMOOTHB / [SMOOTHA + SMOOTHB]]
local turnRadius : [bowlTop - bowlBottom] / 2 local turnRadius : [bowlTop - bowlBottom] * 0.45
include : spiro { include : spiro {
widths.rhs widths.rhs
flat [SB * 1.25 - O] bowlTop [heading RIGHTWARD] flat [SB * 1.25 - O] bowlTop [heading RIGHTWARD]
@ -268,7 +263,7 @@ define [PShape top] : glyph-construction {
flat [RIGHTSB - turnRadius + OMIDCOR_S] bowlBottom flat [RIGHTSB - turnRadius + OMIDCOR_S] bowlBottom
curl [SB * 1.25 - O] bowlBottom [heading LEFTWARD] curl [SB * 1.25 - O] bowlBottom [heading LEFTWARD]
} }
include : VBarLeft SB 0 top include : VBarLeft [SB * 1.25] 0 top
} }
define [RShape top] : glyph-construction { define [RShape top] : glyph-construction {
include : PShape top include : PShape top
@ -300,14 +295,15 @@ create-glyph 'C' : glyph-construction {
assign-unicode 'C' assign-unicode 'C'
include capitalMarks include capitalMarks
include : create-stroke include : spiro {
:.start-from [RIGHTSB - OXHOOK] [CAP - HOOK] widths.lhs
:.set-width STROKE 0 g4 RIGHTSB [CAP - HOOK]
:.curve-to [MIDDLE + KAPPA_HOOK * [MIDDLE - para.sb]] CAPO [MIDDLE - OMIDCOR_S] CAPO hookstart CAPO
:.arc-hv-to SB [CAP - SMOOTHA] flat SB [CAP - SMOOTHA]
:.line-to SB SMOOTHB curl SB SMOOTHB
:.arc-vh-to [MIDDLE + OMIDCOR_S] O hookend O
:.curve-to [MIDDLE + ITALICCORS + KAPPA_HOOK * [MIDDLE - SB]] O [RIGHTSB - OXHOOK] HOOK g4 RIGHTSB HOOK
}
} }
define [GShape top sma smb] : glyph-construction { define [GShape top sma smb] : glyph-construction {
include : create-stroke include : create-stroke

View File

@ -109,13 +109,12 @@ create-glyph 'c' : glyph-construction {
include : spiro { include : spiro {
widths.lhs widths.lhs
g4 [RIGHTSB - OXHOOK] [XH - HOOK] g4 RIGHTSB [XH - HOOK]
g4 [[mix SB RIGHTSB SBALANCE] - OMIDCOR_S] [XH - O] hookstart XO
archv
flat [SB + O] [XH - SMALLSMOOTHA] flat [SB + O] [XH - SMALLSMOOTHA]
curl [SB + O] [0 + SMALLSMOOTHB] curl [SB + O] [0 + SMALLSMOOTHB]
hookend O hookend O
g4 [RIGHTSB + TAILADJX * globalTransform.yx] [HOOK - TAILADJY * globalTransform.yx] g4 RIGHTSB HOOK
} }
} }
define [SmallEShape top stroke barpos] : glyph-construction { define [SmallEShape top stroke barpos] : glyph-construction {
@ -133,7 +132,7 @@ define [SmallEShape top stroke barpos] : glyph-construction {
flat [SB + O] [XH - SMALLSMOOTHA] flat [SB + O] [XH - SMALLSMOOTHA]
curl [SB + O] [0 + SMALLSMOOTHB] curl [SB + O] [0 + SMALLSMOOTHB]
hookend O hookend O
g4 [RIGHTSB + TAILADJX * globalTransform.yx - O] [HOOK - TAILADJY * globalTransform.yx] g4 [RIGHTSB - O] HOOK
} }
include : create-stroke include : create-stroke
:.start-from [SB + [stroke / 2]] barbottom :.start-from [SB + [stroke / 2]] barbottom
@ -166,7 +165,7 @@ create-glyph 'e.italic' : glyph-construction {
flat [SB + O] [XH - SMALLSMOOTHA] flat [SB + O] [XH - SMALLSMOOTHA]
curl [SB + O] [0 + SMALLSMOOTHB] curl [SB + O] [0 + SMALLSMOOTHB]
hookend O hookend O
g4 [RIGHTSB + TAILADJX * globalTransform.yx - O] [HOOK - TAILADJY * globalTransform.yx] g4 [RIGHTSB - O] HOOK
} }
} }
create-glyph 'e' : glyph-construction { create-glyph 'e' : glyph-construction {

View File

@ -176,25 +176,25 @@ create-glyph 'eight' : glyph-construction {
set-width WIDTH set-width WIDTH
assign-unicode '8' assign-unicode '8'
local sma : SMOOTHA * 0.975 local sma : SMOOTHA * 0.975 + ITALICCORS * ITALICCOR
local smb : SMOOTHB * 0.975 local smb : SMOOTHB * 0.975 - ITALICCORS * ITALICCOR
local p 0.96 local p 0.96
include : xsStrand [mix RIGHTSB SB p] [CAP - sma * p] RIGHTSB sma include : spiro {
include : xsStrand SB smb [mix SB RIGHTSB p] [CAP - smb * p] widths.lhs
g4 [MIDDLE - OMIDCOR_S + ITALICCORS] [CAP - O - STROKE]
include : create-stroke archv 1
:.start-from [mix SB RIGHTSB p] [CAP - smb * p] g4 [[mix SB RIGHTSB p] - STROKE] [CAP - smb * p]
:.set-width STROKE 0 g4 [SB + STROKE] smb [widths 0 STROKE]
:.arc-vh-to [MIDDLE - OMIDCOR_S] [CAP - O] arcvh 1
:.arc-hv-to [mix RIGHTSB SB p] [CAP - sma * p] g4 [MIDDLE + OMIDCOR_S - ITALICCORS] [O + STROKE]
archv 1
include : create-stroke g4 [RIGHTSB - STROKE] sma [widths 0 STROKE]
:.start-from SB smb g4 [[mix RIGHTSB SB p] + STROKE] [CAP - sma * p] [widths STROKE 0]
:.set-width STROKE 0 arcvh 1
:.arc-vh-to [MIDDLE + OMIDCOR_S] O close
:.arc-hv-to RIGHTSB sma }
} }
create-glyph 'nine' : glyph-construction { create-glyph 'nine' : glyph-construction {

View File

@ -7,6 +7,8 @@ font = fontforge.open(source)
font.selection.all() font.selection.all()
font.removeOverlap() font.removeOverlap()
font.em = 1000 font.em = 1000
font.round()
font.removeOverlap()
font.simplify(1) font.simplify(1)
font.addExtrema() font.addExtrema()
font.canonicalContours() font.canonicalContours()

View File

@ -107,7 +107,7 @@ define [Glyph.prototype.put-shapes contours] : begin {
define [Glyph.prototype.include component copyAnchors] : begin { define [Glyph.prototype.include component copyAnchors] : begin {
local glyph : match component { local glyph : match component {
[aFunction it] : return : component.call this [aFunction it] : return : component.call this
[Stroke.is it] (.contours [component.to-outline 0 0]) [Stroke.is it] (.contours [component.to-outline])
(:: contours) (.contours contours) (:: contours) (.contours contours)
otherwise component otherwise component
} }

View File

@ -140,8 +140,15 @@ define [computeOffsetPoint curve t j sl foffset fpdx fpdy] : begin {
} }
define [Stroke.prototype.to-outline d1 d2 _samples straight] : begin { define [Stroke.prototype.to-outline d1 d2 _samples straight] : begin {
local d1s ([set d1 [if [this.points.0.d1 >= 0] this.points.0.d1 this.defaultd1]]) local width : [d1 || this.defaultd1] + [d2 || this.defaultd2]
local d2s ([set d2 [if [this.points.0.d2 >= 0] this.points.0.d2 this.defaultd2]]) local bias : [d1 || this.defaultd1] - [d2 || this.defaultd2]
if [this.points.0.d1 >= 0 && this.points.0.d2 >= 0] : begin {
local width : this.points.0.d1 + this.points.0.d2
local bias : this.points.0.d1 - this.points.0.d2
}
local widths (width)
local biases (bias)
local pdxs (0) local pdxs (0)
local pdys (0) local pdys (0)
local ts (0) local ts (0)
@ -163,8 +170,12 @@ define [Stroke.prototype.to-outline d1 d2 _samples straight] : begin {
if [not p1.subdivided] : begin { if [not p1.subdivided] : begin {
ts.push arcLengthSofar ts.push arcLengthSofar
brk.[subSegments.length - 1] = true brk.[subSegments.length - 1] = true
d1s.push : set d1 [if [p1.d1 >= 0] p1.d1 d1] if [p1.d1 >= 0 && p1.d2 >= 0] : begin {
d2s.push : set d2 [if [p1.d2 >= 0] p1.d2 d2] set width : p1.d1 + p1.d2
set bias : p1.d1 - p1.d2
}
widths.push width
biases.push bias
local normalpt : seg.normal 1 local normalpt : seg.normal 1
pdxs.push : if [p1.pdx !== nothing] [p1.pdx - normalpt.x] 0 pdxs.push : if [p1.pdx !== nothing] [p1.pdx - normalpt.x] 0
pdys.push : if [p1.pdy !== nothing] [p1.pdy - normalpt.y] 0 pdys.push : if [p1.pdy !== nothing] [p1.pdy - normalpt.y] 0
@ -179,8 +190,12 @@ define [Stroke.prototype.to-outline d1 d2 _samples straight] : begin {
if [not p3.subdivided] : begin { if [not p3.subdivided] : begin {
ts.push arcLengthSofar ts.push arcLengthSofar
brk.[subSegments.length - 1] = true brk.[subSegments.length - 1] = true
d1s.push : set d1 [if [p3.d1 >= 0] p3.d1 d1] if [p3.d1 >= 0 && p3.d2 >= 0] : begin {
d2s.push : set d2 [if [p3.d2 >= 0] p3.d2 d2] set width : p3.d1 + p3.d2
set bias : p3.d1 - p3.d2
}
widths.push width
biases.push bias
local normalpt : seg.normal 1 local normalpt : seg.normal 1
pdxs.push : if [p3.pdx !== nothing] [p3.pdx - normalpt.x] 0 pdxs.push : if [p3.pdx !== nothing] [p3.pdx - normalpt.x] 0
pdys.push : if [p3.pdy !== nothing] [p3.pdy - normalpt.y] 0 pdys.push : if [p3.pdy !== nothing] [p3.pdy - normalpt.y] 0
@ -195,8 +210,12 @@ define [Stroke.prototype.to-outline d1 d2 _samples straight] : begin {
if [not p2.subdivided] : begin { if [not p2.subdivided] : begin {
ts.push arcLengthSofar ts.push arcLengthSofar
brk.[subSegments.length - 1] = true brk.[subSegments.length - 1] = true
d1s.push : set d1 [if [p2.d1 >= 0] p2.d1 d1] if [p2.d1 >= 0 && p2.d2 >= 0] : begin {
d2s.push : set d2 [if [p2.d2 >= 0] p2.d2 d2] set width : p2.d1 + p2.d2
set bias : p2.d1 - p2.d2
}
widths.push width
biases.push bias
local normalpt : seg.normal 1 local normalpt : seg.normal 1
pdxs.push : if [p2.pdx !== nothing] [p2.pdx - normalpt.x] 0 pdxs.push : if [p2.pdx !== nothing] [p2.pdx - normalpt.x] 0
pdys.push : if [p2.pdy !== nothing] [p2.pdy - normalpt.y] 0 pdys.push : if [p2.pdy !== nothing] [p2.pdy - normalpt.y] 0
@ -209,8 +228,10 @@ define [Stroke.prototype.to-outline d1 d2 _samples straight] : begin {
if [this.points.0.pdx !== nothing] : set pdxs.0 [this.points.0.pdx - [subSegments.0.normal 0].x] if [this.points.0.pdx !== nothing] : set pdxs.0 [this.points.0.pdx - [subSegments.0.normal 0].x]
if [this.points.0.pdy !== nothing] : set pdys.0 [this.points.0.pdy - [subSegments.0.normal 0].y] if [this.points.0.pdy !== nothing] : set pdys.0 [this.points.0.pdy - [subSegments.0.normal 0].y]
local f1 : smooth [xs-array ts] [ys-array d1s] local fWidth : smooth [xs-array ts] [ys-array widths]
local f2 : smooth [xs-array ts] [ys-array [d2s.map [[x] -> [-x]]]] local fBias : smooth [xs-array ts] [ys-array biases]
local [f1 t] : [[fWidth t] + [fBias t]] / 2
local [f2 t] : - [[fWidth t] - [fBias t]] / 2
local fpdx : smooth [xs-array ts] [ys-array pdxs] local fpdx : smooth [xs-array ts] [ys-array pdxs]
local fpdy : smooth [xs-array ts] [ys-array pdys] local fpdy : smooth [xs-array ts] [ys-array pdys]