Skip to content

Commit

Permalink
Removed the unused code of stroke.ptl.
Browse files Browse the repository at this point in the history
  • Loading branch information
be5invis committed Dec 18, 2015
1 parent e0bf066 commit 5f9e403
Show file tree
Hide file tree
Showing 12 changed files with 177 additions and 388 deletions.
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1 @@
*.patel linguist-language=PatEL
*.ptl linguist-language=PatEL
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ release-archives/
buildglyphs.js
parameters.js
support/glyph.js
support/stroke.js
support/simple-expand.js
support/spiroexpand.js
support/spirokit.js
testdrive/assets
3 changes: 2 additions & 1 deletion buildglyphs.ptl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import 'unorm' as unorm

import './support/glyph' as Glyph
import './support/stroke' as Stroke
import './support/simple-expand' as simpleExpand
import './support/point' as Point
import './support/spirokit' as spirokit
import './support/transform' as : Transform && [object [transformPoint tp] [untransform utp] inverse]
import './support/anchor' as Anchor
Expand Down
43 changes: 0 additions & 43 deletions glyphs/common-shapes.ptl
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ define [dwc newid unicode id] : create-glyph [fallback newid : 'dwc' + id] : gly
define [Ring u d l r transformShiftOnly] : create-glyph : glyph-construction
local my ((u + d) / 2)
local mx ((l + r) / 2)
local s : new Stroke
currentGlyph.gizmo = [if transformShiftOnly [Translate 0 0] globalTransform]
include : spiro-outline
g4 mx d
Expand Down Expand Up @@ -270,48 +269,6 @@ define [AIMSerifs top _left _right] : glyph-construction
include : CenterBottomSerif (right - STROKE * sideSerifK * HVCONTRAST) 0 JUT


define [xsStrand _xleft yleft _xright yright _halfstroke0 _halfstroke1 _ess _expansion _roundp] : begin
local expansion : _expansion || 0.25
local halfstroke0 : _halfstroke0 || HALFSTROKE
local halfstroke1 : _halfstroke1 || HALFSTROKE
local ess : _ess || (halfstroke0 + halfstroke1) / 2
local upright : Upright
# calculate italic correction
local outline : [new Stroke
:.set-transform globalTransform
:.start-from _xleft yleft
:.set-width (2 * halfstroke0) 0
:.line-to _xleft (yleft - 1000)
:.max-samples 1
:.to-outline].0.map : [p] -> [tp upright p]
local xItalicCorrection : -(outline.3.x - outline.0.x) / (2 * halfstroke0)
local yItalicCorrection : (outline.3.y - outline.0.y) / (2 * halfstroke0)

local roundsize : (_roundp || SMOOTHA * 0.4) * [if (yleft < yright) (-1) 1]
local roundleft (yleft - roundsize)
local roundright (yright + roundsize)
local xleft : _xleft + halfstroke0 * xItalicCorrection
local xright : _xright - halfstroke1 * xItalicCorrection
local sxleft : mix xleft xright (0.5 - expansion)
local sxright : mix xleft xright (0.5 + expansion)
local syleft : mix roundleft roundright (0.5 - expansion)
local syright : mix roundleft roundright (0.5 + expansion)

return : new Stroke
:.set-transform globalTransform
:.start-from xleft (yleft - halfstroke0 * yItalicCorrection)
:.set-width halfstroke0 halfstroke0
:.curve-to xleft roundleft sxleft syleft
:.set-width ess ess
:.line-to sxright syright
:.curve-to xright roundright xright (yright + halfstroke1 * yItalicCorrection)
:.set-width halfstroke1 halfstroke1
:.to-outline

define [sStrand yleft yright _expansion] : begin
return : xsStrand SB yleft RIGHTSB yright HALFSTROKE HALFSTROKE HALFSTROKE _expansion (SMOOTHA * 0.4)


define [halfXStrand _leftx lefty rightx righty turn straight tension _fine] : glyph-construction
local leftx : _leftx + (HALFSTROKE * HVCONTRAST * [if (rightx > _leftx) 1 (-1)])
local fine : (_fine || STROKE) * 0.5
Expand Down
20 changes: 13 additions & 7 deletions glyphs/letters-unified-basic.ptl
Original file line number Diff line number Diff line change
Expand Up @@ -845,8 +845,8 @@ symbol-block 'K'
quadcontrols 0 [if SLAB 0.125 0.25] 8
g4 attach2 (top * 0.61) [widths.center fine]
if SLAB : begin
include : RightwardTopSerif (RIGHTSB - (STROKE * [if SLAB 1.15 1.05] * (WIDTH * 2 / UPM) / 2 - HALFSTROKE) * HVCONTRAST) top (SIDEJUT)
include : RightwardBottomSerif (RIGHTSB - O) 0 SIDEJUT
include : RightwardTopSerif (RIGHTSB - (STROKE * [if SLAB 1.15 1.05] * (WIDTH * 2 / UPM) / 2 - HALFSTROKE) * HVCONTRAST * [if para.isItalic 1 0] - HALFSTROKE * 0.5 * HVCONTRAST) top (SIDEJUT + HALFSTROKE * 0.5 * HVCONTRAST)
include : RightwardBottomSerif (RIGHTSB - O * [if para.isItalic 1 0]) 0 SIDEJUT

create-glyph 'K' : glyph-construction
set-width WIDTH
Expand Down Expand Up @@ -2297,7 +2297,7 @@ define {LongSShape} : symbol-block 'f'
widths.center
flat (MIDDLE - FBALANCE) 0 [heading UPWARD]
curl (MIDDLE - FBALANCE) (CAP - FHOOK)
straight.right.end (MIDDLE - FBALANCE + HOOKX) (CAP - HALFSTROKE - fovershoot) [heading RIGHTWARD]
straight.right.end (MIDDLE - FBALANCE + HOOKX) (CAP - HALFSTROKE - fovershoot)
if SLAB : begin
include : CenterBottomSerif (MIDDLE - FBALANCE) 0 JUT
tag-contour 'serifMB'
Expand All @@ -2319,10 +2319,10 @@ define {LongSShape} : symbol-block 'f'
local w [fallback fine STROKE]
include : dispiro
widths.center w
straight.right.start (MIDDLE - hookx) (bottom + w / 2 + fovershoot) [heading RIGHTWARD]
straight.right.start (MIDDLE - hookx) (bottom + w / 2 + fovershoot)
flat MIDDLE (bottom + hooky)
curl MIDDLE (top - hooky)
straight.right.end (MIDDLE + hookx) (top - w / 2 - fovershoot) [heading RIGHTWARD]
straight.right.end (MIDDLE + hookx) (top - w / 2 - fovershoot)

create-glyph 'longs.italic' : glyph-construction
set-width WIDTH
Expand Down Expand Up @@ -2398,7 +2398,10 @@ define {LongSShape} : symbol-block 'f'

create-glyph 'f.italic' : glyph-construction
include glyphs.'longs.italic' AS_BASE
include : HBarTop (MIDDLE - LONGJUT) (MIDDLE + LONGJUT) fbar
include : dispiro
widths.rhs
flat (MIDDLE - LONGJUT - HALFSTROKE * TANSLANT) fbar
curl (MIDDLE + LONGJUT - HALFSTROKE * TANSLANT) fbar
alias 'fltail' 0x192 'f.italic'

italic-variant 'f' 'f'
Expand Down Expand Up @@ -2608,7 +2611,10 @@ symbol-block 't'
include g
set-anchor 'bottomright' BASE g.knots.(g.knots.length - 1).x g.knots.(g.knots.length - 1).y
set-anchor 'below' BASE [mix tcenter g.knots.(g.knots.length - 1).x : linreg 18 0.375 126 0.5 STROKE] bot
include : HBarTop (tcenter + HALFSTROKE - LONGJUT + TBALANCE2) (tcenter + HALFSTROKE + LONGJUT + TBALANCE2) XH
include : dispiro
widths.rhs
flat (tcenter + HALFSTROKE - LONGJUT + TBALANCE2 - HALFSTROKE * TANSLANT) XH
curl (tcenter + HALFSTROKE + LONGJUT + TBALANCE2 - HALFSTROKE * TANSLANT) XH

create-glyph 't' : glyph-construction
set-width WIDTH
Expand Down
15 changes: 6 additions & 9 deletions glyphs/overmarks.ptl
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,12 @@ symbol-block 'Above marks'
local tildeWaveX 0.52
local tildeWaveEnd : [smoothreg {16 60 90} {(-0.025) (-0.05) 0}] (markHalfStroke * 2)

local s : new Stroke
local outlines : s.set-transform globalTransform
:.start-from leftEnd [mix tbot ttop tildeWaveEnd]
:.set-width markHalfStroke markHalfStroke
:.cubic-to [mix leftEnd rightEnd tildeWaveX] [mix bot top tildeWave] [mix leftEnd rightEnd (1 - tildeWaveX)] [mix bot top (1 - tildeWave)] rightEnd [mix tbot ttop (1 - tildeWaveEnd)]
:.set-samples 32
:.to-outline

include outlines
local knots : list
new Point.transformed globalTransform leftEnd [mix tbot ttop tildeWaveEnd] true
new Point.transformed globalTransform [mix leftEnd rightEnd tildeWaveX] [mix bot top tildeWave] false true
new Point.transformed globalTransform [mix leftEnd rightEnd (1 - tildeWaveX)] [mix bot top (1 - tildeWave)] false true
new Point.transformed globalTransform rightEnd [mix tbot ttop (1 - tildeWaveEnd)] true
include : simpleExpand knots markHalfStroke (-markHalfStroke) 32

create-glyph 'macronAbove' : glyph-construction
set-width 0
Expand Down
4 changes: 2 additions & 2 deletions makesupport.mk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
PATELC = node ./node_modules/patel/bin/patel-c
SUPPORT_FILES_FROM_aki = support/glyph.js support/stroke.js support/spiroexpand.js support/spirokit.js parameters.js
SUPPORT_FILES_FROM_aki = support/glyph.js support/simple-expand.js support/spiroexpand.js support/spirokit.js parameters.js
SUPPORT_FILES = $(SUPPORT_FILES_FROM_aki) support/point.js extract.js generate.js emptyfont.toml parameters.toml
GLYPH_SEGMENTS = glyphs/common-shapes.ptl glyphs/overmarks.ptl glyphs/letters-unified-basic.ptl glyphs/letters-unified-extended.ptl glyphs/numbers.ptl glyphs/symbol-punctuation.ptl glyphs/symbol-math.ptl glyphs/symbol-geometric.ptl glyphs/symbol-other.ptl glyphs/symbol-letter.ptl glyphs/autobuilds.ptl
SCRIPTS = $(SUPPORT_FILES) buildglyphs.js
Expand All @@ -11,7 +11,7 @@ buildglyphs.js : buildglyphs.ptl $(GLYPH_SEGMENTS)
$(SUPPORT_FILES_FROM_aki) :
$(PATELC) --optimize --strict $< -o $@
support/glyph.js : support/glyph.ptl
support/stroke.js : support/stroke.ptl
support/simple-expand.js : support/simple-expand.ptl
support/spirokit.js : support/spirokit.ptl
support/spiroexpand.js : support/spiroexpand.ptl
parameters.js : parameters.ptl
Expand Down
4 changes: 2 additions & 2 deletions pass1-cleanup.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@
print " Simplify: ", font.fontname
font.selection.all()
font.transform(psMat.scale(5))
font.simplify(0.025, ("smoothcurves", "choosehv"), 0.1)
font.simplify(0.25, ("smoothcurves", "choosehv"), 0.1)
font.transform(psMat.scale(0.2))
font.simplify(0.2, ("smoothcurves", "choosehv"), 0.1)
font.simplify(0.5, ("smoothcurves", "choosehv"), 0.1)

#font.em = 2000
font.layers["Fore"].is_quadratic = True
Expand Down
54 changes: 54 additions & 0 deletions support/faircontext.ptl
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import './transform' as : Transform && [object [transformPoint tp] [untransform utp] inverse]
import './point' as Point

define [fallback] : for [local j 0] (j < arguments.length) [inc j] : if (arguments.(j) !== nothing) : return arguments.(j)
define [linreg x0 y0 x1 y1 x] : y0 + (x - x0) * (y1 - y0) / (x1 - x0)

define-macro xytransform : syntax-rules
`[xytransform @tfm @x @y] : let [t : env.newt] `[begin \\
set @t @x
set @x : @x * @tfm.xx + @y * @tfm.yx + @tfm.x
set @y : @t * @tfm.xy + @y * @tfm.yy + @tfm.y
]

define SEGMENTS 5
export all : define [FairConversionContext] : begin
set this.gizmo [Transform.Id]
set this.contour {}
set this.pendings {}
return nothing

define [fair start points] : return points

define [FairConversionContext.prototype.moveTo x y] : begin
xytransform this.gizmo x y
this.contour.push : new Point x y true

define [FairConversionContext.prototype.lineTo x y] : begin
xytransform this.gizmo x y
if this.pendings.length
: then
local last : this.contour.(this.contour.length - 1)
this.pendings.push : new Point x y true
set this.contour : this.contour.concat : fair last this.pendings
set this.pendings {}
: else : this.contour.push : new Point x y true

define [FairConversionContext.prototype.cubicTo x1 y1 x2 y2 x y unimportant] : begin
xytransform this.gizmo x1 y1
xytransform this.gizmo x2 y2
xytransform this.gizmo x y
piecewise
(!unimportant && this.pendings.length) : begin
local last : this.contour.(this.contour.length - 1)
this.pendings.push : new Point x y true
set this.contour : this.contour.concat : fair last this.pendings
set this.pendings {}
(!unimportant) : begin
this.contour.push : new Point x1 y1 false true
this.contour.push : new Point x2 y2 false true
this.contour.push : new Point x y true
true : begin
this.pendings.push : new Point x1 y1 false true
this.pendings.push : new Point x2 y2 false true
this.pendings.push : new Point x y true
38 changes: 0 additions & 38 deletions support/intersection.js

This file was deleted.

96 changes: 96 additions & 0 deletions support/simple-expand.ptl
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
import 'bezier-js' as Bezier
define TINY 0.001
define LITTLE 0.01

define [dforward p0 p1 p2 p3] {
.x (p0.x + ((-11) / 6 * p0.x + 3 * p1.x - 3 / 2 * p2.x + p3.x / 3) / TINY * LITTLE)
.y (p0.y + ((-11) / 6 * p0.y + 3 * p1.y - 3 / 2 * p2.y + p3.y / 3) / TINY * LITTLE)
}
define [dbackward p0 p1 p2 p3] {
.x (p0.x + (11 / 6 * p0.x - 3 * p1.x + 3 / 2 * p2.x - p3.x / 3) / TINY * LITTLE)
.y (p0.y + (11 / 6 * p0.y - 3 * p1.y + 3 / 2 * p2.y - p3.y / 3) / TINY * LITTLE)
}

define [computeOffsetPoint curve t offset] : begin
local onpoint : curve.compute t
local normal : curve.normal t
return {.x onpoint.x + offset * normal.x .y onpoint.y + offset * normal.y}

define [intersection z1 c1 c2 z2] : begin
define d1 {.x (c1.x - z1.x) .y (c1.y - z1.y)}
define d2 {.x (c2.x - z2.x) .y (c2.y - z2.y)}
local det : d2.x * d1.y - d2.y * d1.x
if ([Math.abs det] <= 1e-8) : return null
local u : ((z2.y - z1.y) * d2.x - (z2.x - z1.x) * d2.y) / det
local v : ((z2.y - z1.y) * d1.x - (z2.x - z1.x) * d1.y) / det
if (u <= 0 || v <= 0) : return null
return { .x (z1.x + d1.x * u), .y (z1.y + d1.y * u) }

export all : define [strokeExpand points f1 f2 samples] : begin
local shapes {}
local subSegments {}

local p0 points.0
for [local j 1] (j < points.length) [inc j] : begin
local p1 points.(j)
piecewise
p1.onCurve : begin
subSegments.push : local seg : new Bezier p0.x p0.y ((p0.x + p1.x) / 2) ((p0.y + p1.y) / 2) p1.x p1.y
p0 = p1
p1.cubic : begin
local p2 points.((j + 1))
local p3 points.((j + 2))
subSegments.push : local seg : new Bezier p0.x p0.y p1.x p1.y p2.x p2.y p3.x p3.y
p0 = p3
j = j + 2
true : begin
local p2 points.((j + 1))
subSegments.push : local seg : new Bezier p0.x p0.y p1.x p1.y p2.x p2.y
p0 = p2
j = j + 1

local left {}
local right {}

for [local j 0] (j < subSegments.length) [inc j] : begin
local curve subSegments.(j)

left.push [begin [local last [computeOffsetPoint curve 0 f1]] {.x last.x .y last.y .onCurve true}]
right.push [begin [local last [computeOffsetPoint curve 0 f2]] {.x last.x .y last.y .onCurve true}]
foreach sample [range 0 samples] : begin
local t : sample / samples
local tn : (sample + 1) / samples

local lthis : computeOffsetPoint curve t f1
local rthis : computeOffsetPoint curve t f2
local lnext : computeOffsetPoint curve tn f1
local rnext : computeOffsetPoint curve tn f2
local lnthis1 : computeOffsetPoint curve (t + TINY) f1
local rnthis1 : computeOffsetPoint curve (t + TINY) f2
local lnnext1 : computeOffsetPoint curve (tn - TINY) f1
local rnnext1 : computeOffsetPoint curve (tn - TINY) f2
local lnthis2 : computeOffsetPoint curve (t + 2 * TINY) f1
local rnthis2 : computeOffsetPoint curve (t + 2 * TINY) f2
local lnnext2 : computeOffsetPoint curve (tn - 2 * TINY) f1
local rnnext2 : computeOffsetPoint curve (tn - 2 * TINY) f2
local lnthis3 : computeOffsetPoint curve (t + 3 * TINY) f1
local rnthis3 : computeOffsetPoint curve (t + 3 * TINY) f2
local lnnext3 : computeOffsetPoint curve (tn - 3 * TINY) f1
local rnnext3 : computeOffsetPoint curve (tn - 3 * TINY) f2

local dlthis [dforward lthis lnthis1 lnthis2 lnthis3]
local drthis [dforward rthis rnthis1 rnthis2 rnthis3]
local dlnext [dbackward lnext lnnext1 lnnext2 lnnext3]
local drnext [dbackward rnext rnnext2 rnnext2 rnnext3]

local il : intersection lthis dlthis lnext dlnext
if il
: then : left.push {.x il.x .y il.y .onCurve false} {.x lnext.x .y lnext.y .onCurve true}
: else : left.push {.x lnext.x .y lnext.y .onCurve true}

local ir : intersection rthis drthis rnext drnext
if ir
: then : right.push {.x ir.x .y ir.y .onCurve false} {.x rnext.x .y rnext.y .onCurve true}
: else : right.push {.x rnext.x .y rnext.y .onCurve true}
shapes.push : left.concat [right.reverse]
return shapes
Loading

0 comments on commit 5f9e403

Please sign in to comment.