Added many mathematical operators, covering WGL4 requirements and basic set theory operators.

This commit is contained in:
be5invis 2015-08-08 07:40:15 +08:00
parent 849610dcca
commit ec75ce7f6c
8 changed files with 309 additions and 62 deletions

View file

@ -41,6 +41,7 @@ define [buildFont para recursive] : begin {
define [Upright angle] [inverse : Italify angle]
define [Scale sx sy] (.xx sx .yx 0 .xy 0 .yy [fallback sy sx] .x 0 .y 0)
define [Translate x y] (.xx 1 .yx 0 .xy 0 .yy 1 .x x .y y)
define [Rotate angle] (.xx [Math.cos angle] .yx [-[Math.sin angle]] .xy [Math.sin angle] .yy [Math.cos angle] .x 0 .y 0)
define globalTransform : Italify para.italicAngle
define ITALICCOR : 1 / [Math.sqrt [1 - globalTransform.yx * globalTransform.yx]]
@ -121,6 +122,8 @@ define [buildFont para recursive] : begin {
define WHITENESS : [[XH - STROKE * 2.5] * [RIGHTSB - SB] * [1 / 3]] / [XH * [RIGHTSB - SB]]
define [adviceBlackness crowdedness] : Math.min STROKE [[RIGHTSB - SB] * [1 - WHITENESS] / crowdedness]
define OPERATORSTROKE : adviceBlackness 3.25
# Anchor parameters
define BASE 'base'
define MARK 'mark'

View file

@ -322,3 +322,17 @@ define [dual newid unicode id spacing] : create-glyph [fallback newid : 'double'
include glyphs.(id)
apply-transform : Translate [spacing / 2] 0
}
define [vdual newid unicode id spacing] : create-glyph [fallback newid : 'double' + id] : glyph-construction {
if unicode : assign-unicode unicode
include : create-glyph : glyph-construction {
include glyphs.(id)
apply-transform : Upright
}
apply-transform : Translate 0 [-spacing]
include : create-glyph : glyph-construction {
include glyphs.(id)
apply-transform : Upright
}
apply-transform : Translate 0 [spacing / 2]
apply-transform : Italify
}

View file

@ -18,10 +18,7 @@ alias 'Chi' 0x3A7 'X'
alias 'omicron' 0x3BF 'o'
# Capital
create-glyph 'Lambda' : glyph-construction {
assign-unicode 0x39B
include capitalMarks
define [LambdaShape STROKE] : glyph-construction {
local TURN [XH * 0.1]
local curviness 0.1
include : create-stroke
@ -46,6 +43,11 @@ create-glyph 'Lambda' : glyph-construction {
line-to [MIDDLE + STROKE / 2] CAP
line-to MIDDLE [CAP - STROKE]
}
create-glyph 'Lambda' : glyph-construction {
assign-unicode 0x39B
include capitalMarks
include : LambdaShape STROKE
}
create-glyph 'Delta' : glyph-construction {
assign-unicode 0x394
include glyphs.Lambda AS_BASE
@ -56,20 +58,19 @@ create-glyph 'Gamma' : glyph-construction {
include glyphs.L AS_BASE
include : FlipAround MIDDLE CAPMIDDLE 1 [-1]
}
define [SigmaShape top bottom] : glyph-construction {
define [SigmaShape top bottom _fine] : glyph-construction {
local cor 1.15
local fine : fallback _fine STROKE
include : create-stroke :.start-from SB top :.heads-to RIGHTWARD :.set-width 0 STROKE
:.line-to RIGHTSB top :.heads-to RIGHTWARD
include : create-stroke :.start-from SB bottom :.heads-to RIGHTWARD :.set-width STROKE 0
:.line-to RIGHTSB bottom :.heads-to RIGHTWARD
include : HBarTop SB RIGHTSB top fine
include : HBarBottom SB RIGHTSB bottom fine
local midx : mix SB RIGHTSB 0.4
start-from SB [bottom + STROKE]
line-to [SB + STROKE * cor] [bottom + STROKE]
line-to [midx + STROKE * cor] [mix bottom top 0.5]
line-to [SB + STROKE * cor] [top - STROKE]
line-to SB [top - STROKE]
start-from SB [bottom + fine]
line-to [SB + fine * cor] [bottom + fine]
line-to [midx + fine * cor] [mix bottom top 0.5]
line-to [SB + fine * cor] [top - fine]
line-to SB [top - fine]
line-to midx [mix bottom top 0.5]
reverse-last
}
@ -93,10 +94,11 @@ create-glyph 'Xi' : glyph-construction {
include : HBar SB RIGHTSB [CAP - HALFSTROKE]
include : HBar SB RIGHTSB [0 + HALFSTROKE]
}
define [PiShape top bottom shrink] : glyph-construction {
include : HBar SB RIGHTSB [top - HALFSTROKE]
include : VBar [[mix SB RIGHTSB [fallback shrink 0.05]] + HALFSTROKE] bottom top
include : VBar [[mix RIGHTSB SB [fallback shrink 0.05]] - HALFSTROKE] bottom top
define [PiShape top bottom shrink _fine] : glyph-construction {
local fine : fallback _fine STROKE
include : HBar SB RIGHTSB [top - [fine / 2]] fine
include : VBar [[mix SB RIGHTSB [fallback shrink 0.05]] + [fine / 2]] bottom top fine
include : VBar [[mix RIGHTSB SB [fallback shrink 0.05]] - [fine / 2]] bottom top fine
}
create-glyph 'Pi' : glyph-construction {
assign-unicode 0x3A0

View file

@ -373,22 +373,24 @@ create-glyph 'Q' : glyph-construction {
line-to [MIDDLE + STROKE * [1 - 0.5 / 3]] [STROKE * 0.5]
reverse-last
}
define [UShape top bottom stroke] : glyph-construction {
include : create-stroke
:.start-from SB top
:.heads-to DOWNWARD
:.set-width [fallback stroke STROKE] 0
:.line-to SB [bottom + SMOOTHB]
:.arc-vh-to MIDDLE [bottom + O]
:.heads-to RIGHTWARD
:.arc-hv-to RIGHTSB [bottom + SMOOTHA]
:.line-to RIGHTSB top
:.heads-to UPWARD
}
create-glyph 'U' : glyph-construction {
set-width WIDTH
assign-unicode 'U'
include capitalMarks
include : create-stroke
:.start-from SB CAP
:.heads-to DOWNWARD
:.set-width STROKE 0
:.line-to SB SMOOTHB
:.arc-vh-to MIDDLE O
:.heads-to RIGHTWARD
:.arc-hv-to RIGHTSB SMOOTHA
:.line-to RIGHTSB CAP
:.heads-to UPWARD
include : UShape CAP 0
}

View file

@ -749,14 +749,14 @@ define [eshHook attach] : glyph-construction {
:.arc-hv-to attach.x attach.y
:.line-to attach.x [attach.y + STROKE]
}
define [LongSShape top bottom hookx hooky] : glyph-construction {
define [LongSShape top bottom hookx hooky fine] : glyph-construction {
include : create-stroke
:.start-from [MIDDLE - hookx] [bottom + HALFSTROKE + O * 6]
:.start-from [MIDDLE - hookx] [bottom + [[fallback fine STROKE] / 2] + O * 6]
:.heads-to RIGHTWARD
:.set-width HALFSTROKE HALFSTROKE
:.set-width [[fallback fine STROKE] / 2] [[fallback fine STROKE] / 2]
:.arc-hv-to MIDDLE [bottom + hooky]
:.line-to MIDDLE [top - hooky]
:.arc-vh-to [MIDDLE + hookx] [top - HALFSTROKE - O * 6]
:.arc-vh-to [MIDDLE + hookx] [top - [[fallback fine STROKE] / 2] - O * 6]
:.heads-to RIGHTWARD
}
create-glyph 'longs.italic' : glyph-construction {

View file

@ -284,17 +284,16 @@ create-glyph 'plus' : glyph-construction {
set-width WIDTH
assign-unicode '+'
include glyphs.hyphen
include : VBar MIDDLE [parenMid - [RIGHTSB - SB] * 0.55] [parenMid + [RIGHTSB - SB] * 0.55]
include : HBar SB RIGHTSB parenMid OPERATORSTROKE
include : VBar MIDDLE [parenMid - [RIGHTSB - SB] * 0.55] [parenMid + [RIGHTSB - SB] * 0.55] OPERATORSTROKE
}
local equalHalfSpace : [parenTop - parenBot] * 0.11
create-glyph 'equal' : glyph-construction {
set-width WIDTH
assign-unicode '='
include : HBar SB RIGHTSB [parenMid - XH * 0.2]
include : HBar SB RIGHTSB [parenMid + XH * 0.2]
include : HBar SB RIGHTSB [parenMid + equalHalfSpace] OPERATORSTROKE
include : HBar SB RIGHTSB [parenMid - equalHalfSpace] OPERATORSTROKE
}
create-glyph 'bar' : glyph-construction {
set-width WIDTH
@ -351,14 +350,14 @@ create-glyph 'less' : glyph-construction {
include : create-stroke
:.start-from RIGHTSB top
:.set-width HALFSTROKE HALFSTROKE
:.set-width [OPERATORSTROKE / 2] [OPERATORSTROKE / 2]
:.line-to SB [mix top bot 0.5]
:.heads-to LEFTWARD
:.set-samples 1
include : create-stroke
:.start-from SB [mix top bot 0.5]
:.set-width HALFSTROKE HALFSTROKE
:.set-width [OPERATORSTROKE / 2] [OPERATORSTROKE / 2]
:.heads-to RIGHTWARD
:.line-to RIGHTSB bot
:.set-samples 1

View file

@ -2,50 +2,108 @@
### Letter-like
alias 'micro' 0xB5 'mu'
turned 'forall' 0x2200 'A' MIDDLE [CAP / 2]
create-glyph 'exists' : glyph-construction {
assign-unicode 0x2203
include : FShape 0.5
include : HBarBottom [SB * 1.5 - O] RIGHTSB 0
create-glyph 'forall' : glyph-construction {
assign-unicode 0x2200
include : LambdaShape OPERATORSTROKE
include : HBar [SB + OPERATORSTROKE] [RIGHTSB - OPERATORSTROKE] [XH / 2] OPERATORSTROKE
include : FlipAround MIDDLE [CAP / 2]
}
alias 'increment' 0x2206 'Delta'
create-glyph 'exists' : glyph-construction {
assign-unicode 0x2203
include : HBarTop [SB * 1.5 - O] RIGHTSB CAP OPERATORSTROKE
include : HBarBottom [SB * 1.5 - O] RIGHTSB 0 OPERATORSTROKE
include : HBar [SB * 1.5 - O] [RIGHTSB - HALFSTROKE] [CAP * 0.5] OPERATORSTROKE
include : VBarLeft [SB * 1.5] 0 CAP OPERATORSTROKE
include : FlipAround MIDDLE [CAP / 2]
}
create-glyph 'emptyset' : glyph-construction {
assign-unicode 0x2205
include : smallo CAP 0 SB RIGHTSB OPERATORSTROKE
local fine : OPERATORSTROKE / 2
include : create-stroke
:.start-from [SB + O + fine] [mix CAP 0 1.05]
:.set-width fine fine
:.line-to [RIGHTSB - O - fine] [mix 0 CAP 1.05]
}
create-glyph 'increment' : glyph-construction {
assign-unicode 0x2206
include : LambdaShape OPERATORSTROKE
include : HBarBottom [SB + [OPERATORSTROKE / 2]] [RIGHTSB - [OPERATORSTROKE / 2]] 0 OPERATORSTROKE
}
turned 'nabla' 0x2207 'increment' MIDDLE [CAP / 2]
create-glyph 'sum' : glyph-construction {
assign-unicode 0x2211
include : SigmaShape parenTop parenBot
include : SigmaShape parenTop parenBot OPERATORSTROKE
}
create-glyph 'product' : glyph-construction {
assign-unicode 0x220F
include : PiShape parenTop parenBot 0
include : PiShape parenTop parenBot 0 OPERATORSTROKE
}
turned 'coproduct' 0x2210 'product' MIDDLE parenMid
create-glyph 'infty' : glyph-construction {
assign-unicode 0x221E
local s : [RIGHTSB - SB - O * 4] / CAP
include [Miniature ('eight') 5 s].eight
apply-transform : Upright
apply-transform : Translate [-MIDDLE] [-CAP / 2]
apply-transform : Rotate [Math.PI / 2]
apply-transform : Scale s
apply-transform : Translate MIDDLE parenMid
apply-transform : Italify
}
create-glyph 'propto' : glyph-construction {
assign-unicode 0x221D
local s : [RIGHTSB - SB - O * 2] / [CAP - SMOOTH]
include [Miniature ('eight') 5 s].eight
this.contours.pop
apply-transform : Upright
apply-transform : Translate [-MIDDLE] [-CAP / 2]
apply-transform : Rotate [Math.PI / 2]
apply-transform : Scale s
apply-transform : Translate [MIDDLE + SMOOTH / 2 * s] parenMid
apply-transform : Italify
}
create-glyph 'partial' : glyph-construction {
assign-unicode 0x2202
include : smallo [CAP * 0.65] 0 SB RIGHTSB OPERATORSTROKE
include : create-stroke
:.start-from [RIGHTSB - O] SMALLSMOOTHA
:.set-width OPERATORSTROKE 0
:.line-to [RIGHTSB - O] [XH - SMALLSMOOTHB]
:.cubic-to [RIGHTSB - O] [mix XH CAP 0.65] [mix SB RIGHTSB 0.7] [mix XH CAP 1.225] [mix SB RIGHTSB 0.075] [mix XH CAP 0.8]
}
### Others
### standard-sized operators
create-glyph 'minus' : glyph-construction {
set-width WIDTH
assign-unicode 0x2212
alias 'minus' 0x2212 'hyphen'
include : HBar SB RIGHTSB parenMid OPERATORSTROKE
}
create-glyph 'plusminus' : glyph-construction {
assign-unicode 0xB1
set-width WIDTH
include glyphs.underscore
include : HBarBottom SB RIGHTSB 0 OPERATORSTROKE
include glyphs.plus
}
turned 'minusplus' 0x2213 'plusminus' MIDDLE parenMid
create-glyph 'multiply' : glyph-construction {
assign-unicode 0xD7
local radius : [RIGHTSB - SB] / 2
include : create-stroke
:.start-from [MIDDLE - radius] [parenMid - radius]
:.set-width HALFSTROKE HALFSTROKE
:.set-width [OPERATORSTROKE / 2] [OPERATORSTROKE / 2]
:.line-to [MIDDLE + radius] [parenMid + radius]
include : create-stroke
:.start-from [MIDDLE + radius] [parenMid - radius]
:.set-width HALFSTROKE HALFSTROKE
:.set-width [OPERATORSTROKE / 2] [OPERATORSTROKE / 2]
:.line-to [MIDDLE - radius] [parenMid + radius]
}
create-glyph 'divide' : glyph-construction {
assign-unicode 0xF7
include glyphs.hyphen
include glyphs.minus
local radius : [RIGHTSB - SB] / 2
include : list {
Ring [parenMid + radius + DOTRADIUS] [parenMid + radius - DOTRADIUS] [MIDDLE - DOTRADIUS + O] [MIDDLE + DOTRADIUS - O]
@ -55,10 +113,179 @@ create-glyph 'divide' : glyph-construction {
create-glyph 'negate' : glyph-construction {
assign-unicode 0xAC
include glyphs.hyphen
include glyphs.minus
include : VBar [RIGHTSB - HALFSTROKE] [parenMid - [RIGHTSB - SB] * 0.55] [parenMid + HALFSTROKE]
include : VBarRight RIGHTSB [parenMid - [RIGHTSB - SB] * 0.55] parenMid OPERATORSTROKE
}
local operTop : mix parenMid parenTop 0.8
local operBot : mix parenMid parenBot 0.8
create-glyph 'vee' : glyph-construction {
assign-unicode 0x2228
include : create-stroke
:.start-from SB operTop
:.set-width [OPERATORSTROKE / 2] [OPERATORSTROKE / 2]
:.line-to MIDDLE operBot
:.heads-to DOWNWARD
:.set-samples 1
include : create-stroke
:.start-from RIGHTSB operTop
:.set-width [OPERATORSTROKE / 2] [OPERATORSTROKE / 2]
:.line-to MIDDLE operBot
:.heads-to DOWNWARD
:.set-samples 1
}
create-glyph 'Vee' : glyph-construction {
assign-unicode 0x22C1
include : create-stroke
:.start-from SB parenTop
:.set-width [OPERATORSTROKE / 2] [OPERATORSTROKE / 2]
:.line-to MIDDLE parenBot
:.heads-to DOWNWARD
:.set-samples 1
include : create-stroke
:.start-from RIGHTSB parenTop
:.set-width [OPERATORSTROKE / 2] [OPERATORSTROKE / 2]
:.line-to MIDDLE parenBot
:.heads-to DOWNWARD
:.set-samples 1
}
turned 'wedge' 0x2227 'vee' MIDDLE parenMid
turned 'Wedge' 0x22C0 'Vee' MIDDLE parenMid
create-glyph 'cup' : glyph-construction {
assign-unicode 0x222A
include : UShape operTop operBot OPERATORSTROKE
}
create-glyph 'Cup' : glyph-construction {
assign-unicode 0x22C3
include : UShape parenTop parenBot OPERATORSTROKE
}
turned 'cap' 0x2229 'cup' MIDDLE parenMid
turned 'Cap' 0x22C2 'Cup' MIDDLE parenMid
create-glyph 'lesseq' : glyph-construction {
assign-unicode 0x2264
local fine : adviceBlackness 4
local top : [mix parenMid parenTop 0.5] - fine
local bot : [mix parenMid parenBot 0.5] + fine
include : create-stroke
:.start-from RIGHTSB [top + fine]
:.set-width [OPERATORSTROKE / 2] [OPERATORSTROKE / 2]
:.line-to SB [[mix top bot 0.5] + fine]
:.heads-to LEFTWARD
:.set-samples 1
include : create-stroke
:.start-from SB [[mix top bot 0.5] + fine]
:.set-width [OPERATORSTROKE / 2] [OPERATORSTROKE / 2]
:.heads-to RIGHTWARD
:.line-to RIGHTSB [bot + fine]
:.set-samples 1
include : create-stroke
:.start-from SB [[mix top bot 0.5] - fine]
:.set-width [OPERATORSTROKE / 2] [OPERATORSTROKE / 2]
:.heads-to RIGHTWARD
:.line-to RIGHTSB [bot - fine]
:.set-samples 1
}
create-glyph 'greatereq' : glyph-construction {
assign-unicode 0x2265
local fine : adviceBlackness 4
local top : [mix parenMid parenTop 0.5] - fine
local bot : [mix parenMid parenBot 0.5] + fine
include : create-stroke
:.start-from SB [top + fine]
:.set-width [OPERATORSTROKE / 2] [OPERATORSTROKE / 2]
:.line-to RIGHTSB [[mix top bot 0.5] + fine]
:.heads-to RIGHTWARD
:.set-samples 1
include : create-stroke
:.start-from RIGHTSB [[mix top bot 0.5] + fine]
:.set-width [OPERATORSTROKE / 2] [OPERATORSTROKE / 2]
:.heads-to LEFTWARD
:.line-to SB [bot + fine]
:.set-samples 1
include : create-stroke
:.start-from RIGHTSB [[mix top bot 0.5] - fine]
:.set-width [OPERATORSTROKE / 2] [OPERATORSTROKE / 2]
:.heads-to LEFTWARD
:.line-to SB [bot - fine]
:.set-samples 1
}
create-glyph 'subst' : glyph-construction {
assign-unicode 0x2282
local top : mix parenMid parenTop 0.5
local bot : mix parenMid parenBot 0.5
include : create-stroke
:.start-from RIGHTSB top
:.heads-to LEFTWARD
:.set-width OPERATORSTROKE 0
:.line-to [SB + [top - bot] / 2] top
:.arc-hv-to SB parenMid
:.arc-vh-to [SB + [top - bot] / 2] bot
:.line-to RIGHTSB bot
:.heads-to RIGHTWARD
}
create-glyph 'element' : glyph-construction {
assign-unicode 0x2208
include glyphs.subst
include : HBar [SB + HALFSTROKE] RIGHTSB parenMid OPERATORSTROKE
}
turned nothing 0x2283 'subst' MIDDLE parenMid
turned nothing 0x220B 'element' MIDDLE parenMid
create-glyph 'sym' : glyph-construction {
assign-unicode 0x223C
local wavex : [MIDDLE - SB] * 0.3
local wavey : [operTop - parenMid] * 0.15
local endwavey : wavey + 0
local fine OPERATORSTROKE
include : create-stroke
:.start-from SB [parenMid - endwavey]
:.set-width [fine / 2] [fine / 2]
:.cubic-to [SB + wavex] [parenMid + wavey] [MIDDLE - wavex] [parenMid + wavey] MIDDLE parenMid
:.cubic-to [MIDDLE + wavex] [parenMid - wavey] [RIGHTSB - wavex] [parenMid - wavey] RIGHTSB [parenMid + endwavey]
}
create-glyph 'ident' : glyph-construction {
assign-unicode 0x2261
include : HBar SB RIGHTSB [parenMid + equalHalfSpace * 1.5] OPERATORSTROKE
include : HBar SB RIGHTSB parenMid OPERATORSTROKE
include : HBar SB RIGHTSB [parenMid - equalHalfSpace * 1.5] OPERATORSTROKE
}
vdual 'approx' 0x2248 'sym' [equalHalfSpace * 1.75]
define [notGlyph newid unicode oldid top bot prop shift] : create-glyph [fallback newid : 'not' + oldid] : glyph-construction {
assign-unicode unicode
include glyphs.(oldid)
local fine : OPERATORSTROKE / 2
include : create-stroke
:.start-from [[fallback shift 0] + [mix SB RIGHTSB [fallback prop 0.25]]] [fallback bot operBot]
:.set-width fine fine
:.line-to [[fallback shift 0] + [mix RIGHTSB SB [fallback prop 0.25]]] [fallback top operTop]
}
define [notGlyph.right newid unicode oldid top bot prop shift] : notGlyph newid unicode oldid top bot prop [-OPERATORSTROKE * 0.5]
define [notGlyph.left newid unicode oldid top bot prop shift] : notGlyph newid unicode oldid top bot prop [OPERATORSTROKE * 0.5]
notGlyph 'noteq' 0x2260 'equal'
notGlyph 'notident' 0x2262 'ident'
notGlyph.left 'notless' 0x226E 'less'
notGlyph.right 'notgreater' 0x226F 'greater'
notGlyph 'notapprox' 0x2249 'approx' [mix parenMid operTop 0.75] [mix parenMid operBot 0.75]
notGlyph 'notsym' 0x2241 'sym' [mix parenMid operTop 0.75] [mix parenMid operBot 0.75]
notGlyph.left 'notsubst' 0x2284 'subst'
notGlyph.right 'notturnsubst' 0x2285 'turnsubst'
notGlyph.left 'notelement' 0x2209 'element'
notGlyph.right 'notturnelement' 0x220C 'turnelement'
notGlyph.left 'notlesseq' 0x2270 'lesseq'
notGlyph.right 'notgreatereq' 0x2271 'greatereq'
notGlyph.right 'nonexist' 0x2204 'exists' [CAP - DESCENDER / 2] [DESCENDER / 2] 0.4
### Others
alias 'mathbullet' 0x2219 'bullet'
create-glyph 'sqrt' : glyph-construction {
@ -66,14 +293,14 @@ create-glyph 'sqrt' : glyph-construction {
include : create-stroke
:.start-from SB [mix parenBot parenTop 0.45]
:.set-width HALFSTROKE HALFSTROKE
:.set-width [OPERATORSTROKE / 2] [OPERATORSTROKE / 2]
:.line-to MIDDLE parenBot
:.heads-to DOWNWARD
:.set-samples 1
include : create-stroke
:.start-from WIDTH parenTop
:.set-width HALFSTROKE HALFSTROKE
:.set-width [OPERATORSTROKE / 2] [OPERATORSTROKE / 2]
:.line-to MIDDLE parenBot
:.heads-to DOWNWARD
:.set-samples 1
@ -81,6 +308,6 @@ create-glyph 'sqrt' : glyph-construction {
create-glyph 'integrate' : glyph-construction {
assign-unicode 0x222B
include : LongSShape parenTop parenBot HOOK [HOOK * 0.75]
include : LongSShape parenTop parenBot HOOK [HOOK * 0.75] OPERATORSTROKE
}
dual 'doubleintegrate' 0x222C 'integrate' [0.5 * WIDTH]

View file

@ -40,7 +40,7 @@ define regular (
.family 'Iosevka'
.style 'Regular'
.weight 400
.version 'r0.0.13'
.version 'r0.0.14'
.variantSelector (.)
.copyright 'Copyright (c) 2015 Belleve Invis.'
)