Separated common shapes into glyphs/common-shapes.patel

This commit is contained in:
Belleve Invis 2015-07-21 06:47:15 +08:00
parent 625b22273a
commit b24242e59c
7 changed files with 1481 additions and 1505 deletions

View file

@ -122,69 +122,6 @@ set font.'OS/2'.bProportion 9 # Monospaced
### Font names
### Useful shapes
define [Ring u d l r] : begin {
local my [[u + d] / 2]
local mx [[l + r] / 2]
local s : new Stroke
:.set-transform globalTransform
:.start-from mx d
:.cubic-to [mx + [l - mx] * BKAPPA] d l [my + [d - my] * BKAPPA] l my
:.cubic-to l [my + [u - my] * BKAPPA] [mx + [l - mx] * BKAPPA] u mx u
:.cubic-to [mx + [r - mx] * BKAPPA] u r [my + [u - my] * BKAPPA] r my
:.cubic-to r [my + [d - my] * BKAPPA] [mx + [r - mx] * BKAPPA] d mx d
return s.points
}
define [ORing u d l r smooth] : begin {
local myu [u - smooth]
local myd [d + smooth]
local mx [[l + r] / 2]
local s : new Stroke
:.set-transform globalTransform
:.start-from mx d
:.cubic-to [mx + [l - mx] * BKAPPA] d l [myd + [d - myd] * BKAPPA] l myd
:.line-to l myu
:.cubic-to l [myu + [u - myu] * BKAPPA] [mx + [l - mx] * BKAPPA] u mx u
:.cubic-to [mx + [r - mx] * BKAPPA] u r [myu + [u - myu] * BKAPPA] r myu
:.line-to r myd
:.cubic-to r [myd + [d - myd] * BKAPPA] [mx + [r - mx] * BKAPPA] d mx d
return s.points
}
define [leftwardTopSerif x y length] : begin {
return : new Stroke
:.set-transform globalTransform
:.start-from [x + HALFSTROKE] y
:.heads-to LEFTWARD
:.set-width STROKE 0
:.line-to [x - length - globalTransform.yx * STROKE] y
:.to-outline
}
define [leftwardBottomSerif x y length] : begin {
return : new Stroke
:.set-transform globalTransform
:.start-from [x + HALFSTROKE] y
:.heads-to LEFTWARD
:.set-width 0 STROKE
:.line-to [x - length + globalTransform.yx * STROKE] y
:.to-outline
}
define [rightwardTopSerif x y length] : begin {
return : new Stroke
:.set-transform globalTransform
:.start-from [x - HALFSTROKE] y
:.heads-to RIGHTWARD
:.set-width 0 STROKE
:.line-to [x + length - globalTransform.yx * STROKE] y
:.to-outline
}
define [rightwardBottomSerif x y length] : begin {
return : new Stroke
:.set-transform globalTransform
:.start-from [x - HALFSTROKE] y
:.heads-to RIGHTWARD
:.set-width STROKE 0
:.line-to [x + length + globalTransform.yx * STROKE] y
:.to-outline
}
define-macro glyph-construction : syntax-rules {
@`[glyph-construction @::steps] ('.syntactic-closure' @`[lambda [] [begin {

File diff suppressed because it is too large Load diff

139
glyphs/common-shapes.patel Normal file
View file

@ -0,0 +1,139 @@
### COMMON SHAPES
define [Ring u d l r] : begin {
local my [[u + d] / 2]
local mx [[l + r] / 2]
local s : new Stroke
:.set-transform globalTransform
:.start-from mx d
:.cubic-to [mx + [l - mx] * BKAPPA] d l [my + [d - my] * BKAPPA] l my
:.cubic-to l [my + [u - my] * BKAPPA] [mx + [l - mx] * BKAPPA] u mx u
:.cubic-to [mx + [r - mx] * BKAPPA] u r [my + [u - my] * BKAPPA] r my
:.cubic-to r [my + [d - my] * BKAPPA] [mx + [r - mx] * BKAPPA] d mx d
return s.points
}
define [ORing u d l r smooth] : begin {
local myu [u - smooth]
local myd [d + smooth]
local mx [[l + r] / 2]
local s : new Stroke
:.set-transform globalTransform
:.start-from mx d
:.cubic-to [mx + [l - mx] * BKAPPA] d l [myd + [d - myd] * BKAPPA] l myd
:.line-to l myu
:.cubic-to l [myu + [u - myu] * BKAPPA] [mx + [l - mx] * BKAPPA] u mx u
:.cubic-to [mx + [r - mx] * BKAPPA] u r [myu + [u - myu] * BKAPPA] r myu
:.line-to r myd
:.cubic-to r [myd + [d - myd] * BKAPPA] [mx + [r - mx] * BKAPPA] d mx d
return s.points
}
define [leftwardTopSerif x y length] : begin {
return : new Stroke
:.set-transform globalTransform
:.start-from [x + HALFSTROKE] y
:.heads-to LEFTWARD
:.set-width STROKE 0
:.line-to [x - length - globalTransform.yx * STROKE] y
:.to-outline
}
define [leftwardBottomSerif x y length] : begin {
return : new Stroke
:.set-transform globalTransform
:.start-from [x + HALFSTROKE] y
:.heads-to LEFTWARD
:.set-width 0 STROKE
:.line-to [x - length + globalTransform.yx * STROKE] y
:.to-outline
}
define [rightwardTopSerif x y length] : begin {
return : new Stroke
:.set-transform globalTransform
:.start-from [x - HALFSTROKE] y
:.heads-to RIGHTWARD
:.set-width 0 STROKE
:.line-to [x + length - globalTransform.yx * STROKE] y
:.to-outline
}
define [rightwardBottomSerif x y length] : begin {
return : new Stroke
:.set-transform globalTransform
:.start-from [x - HALFSTROKE] y
:.heads-to RIGHTWARD
:.set-width STROKE 0
:.line-to [x + length + globalTransform.yx * STROKE] y
:.to-outline
}
define [sStrand leftlimit rightlimit _expansion _roundp] : begin {
local expansion : _expansion || 0.25
local roundsize : [SMOOTHA * [_roundp || 0.4]] * [if [leftlimit < rightlimit] [-1] 1]
local roundleft [leftlimit - roundsize]
local roundright [rightlimit + roundsize]
local sxleft [SB + HALFSTROKE + [RIGHTSB - SB - STROKE] * [0.5 - expansion]]
local sxright [WIDTH - sxleft]
local syleft [roundleft + [roundright - roundleft] * [0.5 - expansion]]
local syright [roundleft + [roundright - roundleft] * [0.5 + expansion]]
return : new Stroke
:.set-transform globalTransform
:.start-from [SB + HALFSTROKE] leftlimit
:.set-width HALFSTROKE HALFSTROKE
:.curve-to [SB + HALFSTROKE] roundleft sxleft syleft
:.line-to sxright syright
:.curve-to [RIGHTSB - HALFSTROKE] roundright [RIGHTSB - HALFSTROKE] rightlimit
:.to-outline
}
define [nBowl left middle right fine] : begin {
local bandLeft : new Stroke
:.set-transform globalTransform
:.start-from right 0
:.heads-to UPWARD
:.set-width STROKE 0
:.line-to right [XH - SMALLSMOOTHB]
:.arc-vh-to middle XO
:.heads-to LEFTWARD
:.to-outline
local bandRight : new Stroke
:.set-transform globalTransform
:.start-from middle [XO - STROKE]
:.set-width 0 STROKE
:.heads-to LEFTWARD
:.arc-hv-to left [XH - SMALLSMOOTHA]
:.heads-to DOWNWARD
:.set-width 0 fine
:.to-outline
return : bandLeft.concat bandRight
}
define [sHookUpper top smooth hook] : begin {
return : new Stroke
:.set-transform globalTransform
:.start-from [RIGHTSB - OXHOOK] [top - hook]
:.set-width STROKE 0
:.curve-to [MIDDLE + KAPPA_HOOK * [MIDDLE - para.sb]] [top - O] MIDDLE [top - O]
:.heads-to LEFTWARD
:.arc-hv-to SB [top - smooth]
:.to-outline
}
define [twoHookUpper top smooth hook] : begin {
return : new Stroke
:.set-transform globalTransform
:.start-from [SB + OXHOOK] [top - hook]
:.set-width 0 STROKE
:.curve-to [MIDDLE - KAPPA_HOOK * [MIDDLE - para.sb]] [top - O] MIDDLE [top - O]
:.heads-to RIGHTWARD
:.arc-hv-to RIGHTSB [top - smooth]
:.to-outline
}
define [sHookLower bottom smooth hook] : begin {
return : new Stroke
:.set-transform globalTransform
:.start-from RIGHTSB smooth
:.set-width 0 STROKE
:.arc-vh-to MIDDLE [bottom + O]
:.heads-to LEFTWARD
:.curve-to [MIDDLE - KAPPA_HOOK * [MIDDLE - para.sb]] [bottom + O] [SB + OXHOOK] [bottom + hook]
:.to-outline
}

View file

@ -645,51 +645,15 @@ create-glyph 'M' : glyph-construction {
:.to-outline
}
define [sStrand leftlimit rightlimit _expansion _roundp] : begin {
local strand : new Stroke
strand.gizmo = globalTransform
local expansion : _expansion || 0.25
local roundsize : [SMOOTHA * [_roundp || 0.4]] * [if [leftlimit < rightlimit] [-1] 1]
local roundleft [leftlimit - roundsize]
local roundright [rightlimit + roundsize]
local sxleft [SB + HALFSTROKE + [RIGHTSB - SB - STROKE] * [0.5 - expansion]]
local sxright [WIDTH - sxleft]
local syleft [roundleft + [roundright - roundleft] * [0.5 - expansion]]
local syright [roundleft + [roundright - roundleft] * [0.5 + expansion]]
return : strand.start-from [SB + HALFSTROKE] leftlimit
:.set-width HALFSTROKE HALFSTROKE
:.curve-to [SB + HALFSTROKE] roundleft sxleft syleft
:.line-to sxright syright
:.curve-to [RIGHTSB - HALFSTROKE] roundright [RIGHTSB - HALFSTROKE] rightlimit
:.to-outline
}
### S
create-glyph 'S' : glyph-construction {
set-width WIDTH
assign-unicode 'S'
include capitalMarks
local ssmootha SMOOTHA
local bowltop : create-stroke
bowltop.start-from [RIGHTSB - OXHOOK] [CAP - HOOK]
:.set-width STROKE 0
:.curve-to [MIDDLE + KAPPA_HOOK * [MIDDLE - para.sb]] CAPO MIDDLE CAPO
:.heads-to LEFTWARD
:.arc-hv-to SB [CAP - ssmootha]
local bowlbottom : create-stroke
bowlbottom.start-from RIGHTSB ssmootha :.set-width 0 STROKE
:.arc-vh-to MIDDLE O
:.heads-to LEFTWARD
:.curve-to [MIDDLE - KAPPA_HOOK * [MIDDLE - para.sb]] O [SB + OXHOOK] HOOK
put-shapes : bowltop.to-outline
put-shapes : bowlbottom.to-outline
put-shapes : sStrand [CAP - ssmootha] ssmootha
put-shapes : sHookUpper CAP SMOOTHA HOOK
put-shapes : sHookLower 0 SMOOTHA HOOK
put-shapes : sStrand [CAP - SMOOTHA] SMOOTHA
}
create-glyph 'dollar' : glyph-construction {
set-width WIDTH; assign-unicode '$'

View file

@ -354,30 +354,12 @@ create-glyph 'u' : glyph-construction {
}
### n h m
create-glyph 'nbowl' : glyph-construction {
put-shapes : create-stroke
:.start-from RIGHTSB 0
:.heads-to UPWARD
:.set-width STROKE 0
:.line-to RIGHTSB [XH - SMALLSMOOTHB]
:.arc-vh-to MIDDLE XO
:.heads-to LEFTWARD
:.to-outline
put-shapes : create-stroke
:.start-from MIDDLE [XO - STROKE]
:.set-width 0 STROKE
:.heads-to LEFTWARD
:.arc-hv-to [SB + STROKE * ITALICCOR] [XH - SMALLSMOOTHA]
:.heads-to DOWNWARD
:.set-width 0 [STROKE * 0.4]
:.to-outline
}
create-glyph 'n' : glyph-construction {
set-width WIDTH
assign-unicode 'n'
include eMarks
include glyphs.nbowl
put-shapes : nBowl [SB + STROKE * ITALICCOR] MIDDLE RIGHTSB [STROKE * 0.4]
put-shapes : create-stroke
:.start-from SB 0
:.heads-to UPWARD
@ -391,7 +373,7 @@ create-glyph 'h' : glyph-construction {
assign-unicode 'h'
include bMarks
include glyphs.nbowl
put-shapes : nBowl [SB + STROKE * ITALICCOR] MIDDLE RIGHTSB [STROKE * 0.4]
put-shapes : create-stroke
:.start-from SB 0
:.heads-to UPWARD
@ -812,28 +794,10 @@ create-glyph 's' : glyph-construction {
assign-unicode 's'
include eMarks
local slope 0.015
local expand 0.175
local coexpand [[1 - expand] / 2]
local ssmootha [SMOOTHA * 0.87]
local bowltop : create-stroke
bowltop.start-from [RIGHTSB - OXHOOK] [XH - SHOOK]
:.set-width STROKE 0
:.curve-to [MIDDLE + KAPPA_AHOOK * [MIDDLE - para.sb]] XO MIDDLE XO
:.heads-to LEFTWARD
:.arc-hv-to SB [XH - ssmootha]
put-shapes : sHookUpper XH [SMOOTHA * 0.87] SHOOK
put-shapes : sHookLower 0 [SMOOTHA * 0.87] SHOOK
local bowlbottom : create-stroke
bowlbottom.start-from RIGHTSB ssmootha :.set-width 0 STROKE
:.arc-vh-to MIDDLE O
:.heads-to LEFTWARD
:.curve-to [MIDDLE - [KAPPA_AHOOK + TAILADJSKAPPA * globalTransform.yx] * [MIDDLE - para.sb]] O [SB + OXHOOK - + TAILADJSX * globalTransform.yx] [SHOOK - TAILADJSY * globalTransform.yx]
put-shapes : bowltop.to-outline
put-shapes : bowlbottom.to-outline
put-shapes : sStrand [XH - ssmootha] ssmootha 0.2 0.45
put-shapes : sStrand [XH - [SMOOTHA * 0.87]] [SMOOTHA * 0.87] 0.2 0.45
}
### r

View file

@ -52,18 +52,8 @@ create-glyph 'two' : glyph-construction {
assign-unicode '2'
include capitalMarks
local ssmootha SMOOTHA
put-shapes : create-stroke
:.start-from [SB + OXHOOK] [CAP - HOOK]
:.set-width 0 STROKE
:.curve-to [MIDDLE - KAPPA_HOOK * [MIDDLE - SB]] CAPO MIDDLE CAPO
:.heads-to RIGHTWARD
:.arc-hv-to RIGHTSB [CAP - ssmootha]
:.to-outline
put-shapes : sStrand STROKE [CAP - ssmootha]
put-shapes : twoHookUpper CAP SMOOTHA HOOK
put-shapes : sStrand STROKE [CAP - SMOOTHA]
put-shapes : create-stroke
:.start-from SB 0

View file

@ -1,5 +1,5 @@
SUPPORT_FILES = support/glyph.js support/stroke.js parameters.js
GLYPH_SEGMENTS = glyphs/latin-capital.patel glyphs/latin-lower.patel glyphs/numbers.patel
GLYPH_SEGMENTS = glyphs/common-shapes.patel glyphs/latin-capital.patel glyphs/latin-lower.patel glyphs/numbers.patel
FILES = $(SUPPORT_FILES) buildglyphs.js