ver 0.0.17

This commit is contained in:
be5invis 2015-08-10 09:41:29 +08:00
parent 957e49caa4
commit 6ecbfe6f15
5 changed files with 217 additions and 158 deletions

View File

@ -33,24 +33,6 @@ define [buildFont para recursive] : begin {
define glyphs (.'.notdef' glyphList.0) define glyphs (.'.notdef' glyphList.0)
define unicodeGlyphs () define unicodeGlyphs ()
# Transform constructors
define [Italify angle] : begin {
local slope [Math.tan [[fallback angle para.italicangle] / 180 * Math.PI]]
return (.xx 1 .yx slope .xy 0 .yy 1 .x [-slope * 0.5 * para.xheight] .y 0)
}
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]]
define UPWARD (.x [-ITALICCOR] .y 0)
define DOWNWARD (.x ITALICCOR .y 0)
define RIGHTWARD (.x globalTransform.yx .y 1)
define LEFTWARD (.x [- globalTransform.yx] .y [-1])
# metrics # metrics
define DESCENDER para.descender define DESCENDER para.descender
define WIDTH para.width define WIDTH para.width
@ -76,6 +58,28 @@ define [buildFont para recursive] : begin {
define ACCENT para.accent define ACCENT para.accent
define ACCENTX para.accentx define ACCENTX para.accentx
# Common metrics for symbols
local parenTop [[XH * 0.625] + [CAP - XH] * 2.5]
local parenBot [[XH * 0.625] - [CAP - XH] * 2.5]
local parenMid [mix parenTop parenBot 0.5]
# Transform constructors
define [Italify angle] : begin {
local slope [Math.tan [[fallback angle para.italicangle] / 180 * Math.PI]]
return (.xx 1 .yx slope .xy 0 .yy 1 .x [-slope * parenMid] .y 0)
}
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]]
define UPWARD (.x [-ITALICCOR] .y 0)
define DOWNWARD (.x ITALICCOR .y 0)
define RIGHTWARD (.x globalTransform.yx .y 1)
define LEFTWARD (.x [- globalTransform.yx] .y [-1])
# derived metrics # derived metrics
define XO : XH - O define XO : XH - O
@ -308,6 +312,7 @@ define [buildFont para recursive] : begin {
$$include 'glyphs/symbol-math.patel' $$include 'glyphs/symbol-math.patel'
$$include 'glyphs/symbol-letter.patel' $$include 'glyphs/symbol-letter.patel'
$$include 'glyphs/symbol-geometric.patel' $$include 'glyphs/symbol-geometric.patel'
$$include 'glyphs/symbol-other.patel'
$$include 'glyphs/autobuilds.patel' $$include 'glyphs/autobuilds.patel'
### Zoom all glyphs by para.upmscale ### Zoom all glyphs by para.upmscale

View File

@ -91,10 +91,6 @@ create-glyph 'at' : glyph-construction {
### Brackets ### Brackets
local parenTop [[XH * 0.625] + [CAP - XH] * 2.5]
local parenBot [[XH * 0.625] - [CAP - XH] * 2.5]
local parenMid [mix parenTop parenBot 0.5]
local parenOutside 0.15 local parenOutside 0.15
local parenInside 0.65 local parenInside 0.65
local bracketOutside 0.15 local bracketOutside 0.15

View File

@ -1,151 +1,209 @@
###### GEOMETRIC SHAPES ###### GEOMETRIC SHAPES
### Arrowheads
let [arrowSize : [RIGHTSB - SB] / 3] [halfstroke : [adviceBlackness 4] / 2] [fine : adviceBlackness 4.5] [arrowTop : mix parenMid parenTop 0.75] [arrowBot : mix parenMid parenBot 0.75] : begin {
define [ArrowHead x1 y1 x2 y2] : create-glyph : glyph-construction {
set this.gizmo : Translate 0 0
include : create-stroke
:.start-from 0 0
:.heads-to UPWARD
:.set-width 0 fine
:.line-to [arrowSize * 1] arrowSize
:.set-width 0 fine
:.set-samples 1
include : create-stroke
:.start-from 0 0
:.heads-to DOWNWARD
:.set-width fine 0
:.line-to [arrowSize * 1] [-arrowSize]
:.set-width fine 0
:.set-samples 1
apply-transform : Translate O 0
local (.x xo .y yo) : tp globalTransform (.x x1 .y y1)
local (.x xt .y yt) : tp globalTransform (.x x2 .y y2)
apply-transform : Rotate : Math.atan2 [yo - yt] [xo - xt]
apply-transform : Translate xt yt
}
define [ArrowShape x1 y1 x2 y2] : glyph-construction {
local mag : Math.hypot [y2 - y1] [x2 - x1]
local p : [mag - halfstroke * 1.1] / mag
include : ArrowHead x1 y1 x2 y2
include : create-stroke
:.start-from x1 y1
:.set-width halfstroke halfstroke
:.line-to [mix x1 x2 p] [mix y1 y2 p]
}
define [arrow id unicode x1 y1 x2 y2] : create-glyph id : glyph-construction {
assign-unicode unicode
include : ArrowShape x1 y1 x2 y2
}
define [doublearrow id unicode x1 y1 x2 y2] : create-glyph id : glyph-construction {
assign-unicode unicode
local xm : mix x1 x2 0.5
local ym : mix y1 y2 0.5
include : ArrowShape xm ym x1 y1
include : ArrowShape xm ym x2 y2
}
arrow 'arrowleft' 0x2190 RIGHTSB parenMid SB parenMid
arrow 'arrowright' 0x2192 SB parenMid RIGHTSB parenMid
arrow 'arrowup' 0x2191 MIDDLE arrowBot MIDDLE arrowTop
arrow 'arrowdown' 0x2193 MIDDLE arrowTop MIDDLE arrowBot
doublearrow 'arrowleftright' 0x2194 SB parenMid RIGHTSB parenMid
doublearrow 'arrowupdown' 0x2195 MIDDLE arrowTop MIDDLE arrowBot
arrow 'arrowupleft' 0x2196 RIGHTSB arrowBot SB arrowTop
arrow 'arrowupright' 0x2197 SB arrowBot RIGHTSB arrowTop
arrow 'arrowdownright' 0x2198 SB arrowTop RIGHTSB arrowBot
arrow 'arrowdownleft' 0x2199 RIGHTSB arrowTop SB arrowBot
}
### Standard geometric shapes ### Standard geometric shapes
define squareRadius : [RIGHTSB - SB] / 2 let : begin {
define [hollowScale w] : [w - [adviceBlackness 5]] / w define squareRadius : [RIGHTSB - SB] / 2
define [hollow newid unicode oldid zx zy] : create-glyph newid : glyph-construction { define [hollowScale w] : [w - [adviceBlackness 5]] / w
assign-unicode unicode define [hollow newid unicode oldid zx zy] : create-glyph newid : glyph-construction {
include glyphs.(oldid) assign-unicode unicode
reverse-last include glyphs.(oldid)
local zoom : hollowScale squareRadius reverse-last
include : FlipAround MIDDLE parenMid [fallback zx zoom] [fallback zy zx zoom] local zoom : hollowScale squareRadius
include glyphs.(oldid) include : FlipAround MIDDLE parenMid [fallback zx zoom] [fallback zy zx zoom]
} include glyphs.(oldid)
create-glyph 'blacksquare' : glyph-construction {
assign-unicode 0x25A0
start-from SB [parenMid + squareRadius]
line-to RIGHTSB [parenMid + squareRadius]
line-to RIGHTSB [parenMid - squareRadius]
line-to SB [parenMid - squareRadius]
}
create-glyph 'blackrectangle' : glyph-construction {
assign-unicode 0x25AC
start-from SB [parenMid + squareRadius / 1.5]
line-to RIGHTSB [parenMid + squareRadius / 1.5]
line-to RIGHTSB [parenMid - squareRadius / 1.5]
line-to SB [parenMid - squareRadius / 1.5]
}
create-glyph 'blacklongrectangle' : glyph-construction {
assign-unicode 0x25AE
start-from SB [parenMid + squareRadius * 1.5]
line-to RIGHTSB [parenMid + squareRadius * 1.5]
line-to RIGHTSB [parenMid - squareRadius * 1.5]
line-to SB [parenMid - squareRadius * 1.5]
}
create-glyph 'blacktriangleup' : glyph-construction {
assign-unicode 0x25B2
start-from MIDDLE [parenMid + squareRadius]
line-to RIGHTSB [parenMid - squareRadius]
line-to SB [parenMid - squareRadius]
}
create-glyph 'blackdiamond' : glyph-construction {
assign-unicode 0x25C6
start-from MIDDLE [parenMid + squareRadius]
line-to RIGHTSB parenMid
line-to MIDDLE [parenMid - squareRadius]
line-to SB parenMid
}
create-glyph 'blacktriangledown' : glyph-construction {
assign-unicode 0x25BC
start-from MIDDLE [parenMid - squareRadius]
line-to SB [parenMid + squareRadius]
line-to RIGHTSB [parenMid + squareRadius]
}
create-glyph 'blackcircle' : glyph-construction {
assign-unicode 0x25CF
include : list : Ring [parenMid + squareRadius] [parenMid - squareRadius] SB RIGHTSB
}
create-glyph 'dottedcircle' : glyph-construction {
assign-unicode 0x25CC
local n 12
local fine : [adviceBlackness 5] / 2
foreach j [range 0 n] : begin {
local angle : Math.PI * 2 * j / n
local cx : MIDDLE + [RIGHTSB - MIDDLE] * [Math.cos angle]
local cy : [XH / 2] + [RIGHTSB - MIDDLE] * [Math.sin angle]
include : list : Ring [cy + fine] [cy - fine] [cx - fine] [cx + fine] true
} }
apply-transform : Upright create-glyph 'blacksquare' : glyph-construction {
apply-transform : Translate 0 [parenMid - [XH / 2]] assign-unicode 0x25A0
apply-transform : Italify start-from SB [parenMid + squareRadius]
include eMarks line-to RIGHTSB [parenMid + squareRadius]
foreach k [items-of : Object.keys this.anchors] : begin { line-to RIGHTSB [parenMid - squareRadius]
set this.anchors.(k) (.x [this.anchors.(k).x + [parenMid - [XH / 2]] * globalTransform.yx] line-to SB [parenMid - squareRadius]
.y [this.anchors.(k).y + [parenMid - [XH / 2]]]
.type this.anchors.(k).type )
} }
create-glyph 'blackrectangle' : glyph-construction {
assign-unicode 0x25AC
start-from SB [parenMid + squareRadius / 1.5]
line-to RIGHTSB [parenMid + squareRadius / 1.5]
line-to RIGHTSB [parenMid - squareRadius / 1.5]
line-to SB [parenMid - squareRadius / 1.5]
}
create-glyph 'blacklongrectangle' : glyph-construction {
assign-unicode 0x25AE
start-from SB [parenMid + squareRadius * 1.5]
line-to RIGHTSB [parenMid + squareRadius * 1.5]
line-to RIGHTSB [parenMid - squareRadius * 1.5]
line-to SB [parenMid - squareRadius * 1.5]
}
create-glyph 'blacktriangleup' : glyph-construction {
assign-unicode 0x25B2
start-from MIDDLE [parenMid + squareRadius]
line-to RIGHTSB [parenMid - squareRadius]
line-to SB [parenMid - squareRadius]
}
create-glyph 'blackdiamond' : glyph-construction {
assign-unicode 0x25C6
start-from MIDDLE [parenMid + squareRadius]
line-to RIGHTSB parenMid
line-to MIDDLE [parenMid - squareRadius]
line-to SB parenMid
}
create-glyph 'blacktriangledown' : glyph-construction {
assign-unicode 0x25BC
start-from MIDDLE [parenMid - squareRadius]
line-to SB [parenMid + squareRadius]
line-to RIGHTSB [parenMid + squareRadius]
}
create-glyph 'blackcircle' : glyph-construction {
assign-unicode 0x25CF
include : list : Ring [parenMid + squareRadius] [parenMid - squareRadius] SB RIGHTSB
}
create-glyph 'dottedcircle' : glyph-construction {
assign-unicode 0x25CC
local n 12
local fine : [adviceBlackness 5] / 2
foreach j [range 0 n] : begin {
local angle : Math.PI * 2 * j / n
local cx : MIDDLE + [RIGHTSB - MIDDLE] * [Math.cos angle]
local cy : [XH / 2] + [RIGHTSB - MIDDLE] * [Math.sin angle]
include : list : Ring [cy + fine] [cy - fine] [cx - fine] [cx + fine] true
}
apply-transform : Upright
apply-transform : Translate 0 [parenMid - [XH / 2]]
apply-transform : Italify
include eMarks
foreach k [items-of : Object.keys this.anchors] : begin {
set this.anchors.(k) (.x [this.anchors.(k).x + [parenMid - [XH / 2]] * globalTransform.yx]
.y [this.anchors.(k).y + [parenMid - [XH / 2]]]
.type this.anchors.(k).type )
}
}
hollow 'whitesquare' 0x25A1 'blacksquare'
hollow 'whiterectangle' 0x25AD 'blackrectangle' [hollowScale squareRadius] [hollowScale [squareRadius / 1.5]]
hollow 'whitelongrectangle' 0x25AF 'blacklongrectangle' [hollowScale squareRadius] [hollowScale [squareRadius * 1.5]]
hollow 'whitecircle' 0x25CB 'blackcircle'
hollow 'whitebullet' 0x25E6 'bullet' [hollowScale [PERIODSIZE - O]]
hollow 'whitediamond' 0x25C7 'blackdiamond'
} }
hollow 'whitesquare' 0x25A1 'blacksquare'
hollow 'whiterectangle' 0x25AD 'blackrectangle' [hollowScale squareRadius] [hollowScale [squareRadius / 1.5]]
hollow 'whitelongrectangle' 0x25AF 'blacklongrectangle' [hollowScale squareRadius] [hollowScale [squareRadius * 1.5]]
hollow 'whitecircle' 0x25CB 'blackcircle'
hollow 'whitebullet' 0x25E6 'bullet' [hollowScale [PERIODSIZE - O]]
hollow 'whitediamond' 0x25C7 'blackdiamond'
### Blocks ### Blocks
create-glyph 'fullblock' : glyph-construction { let : begin {
assign-unicode 0x2588 create-glyph 'fullblock' : glyph-construction {
start-from 0 font.hhea.ascent assign-unicode 0x2588
line-to WIDTH font.hhea.ascent start-from 0 font.hhea.ascent
line-to WIDTH font.hhea.descent line-to WIDTH font.hhea.ascent
line-to 0 font.hhea.descent
}
define [Shade fn] : glyph-construction {
local top font.hhea.ascent
local bottom font.hhea.descent
local segx 6
local segy 16
foreach j [range 0 segx] : foreach k [range 0 segy] : if [fn j k] : begin {
start-from [mix 0 WIDTH [j / segx]] [mix bottom top [k / segy]]
line-to [mix 0 WIDTH [j / segx]] [mix bottom top [[k + 1] / segy]]
line-to [mix 0 WIDTH [[j + 1] / segx]] [mix bottom top [[k + 1] / segy]]
line-to [mix 0 WIDTH [[j + 1] / segx]] [mix bottom top [k / segy]]
}
}
create-glyph 'lightshade' : glyph-construction {
assign-unicode 0x2591
include : Shade [[j k] -> [[k % 2] && [j + [k - 1] / 2] % 2]]
}
create-glyph 'mediumshade' : glyph-construction {
assign-unicode 0x2592
include : Shade [[j k] -> [[j + k] % 2]]
}
create-glyph 'heavyshade' : glyph-construction {
assign-unicode 0x2593
include : Shade [[j k] -> [[k % 2] || [j + k / 2] % 2]]
}
let : foreach fill [range 1 8] : begin {
create-glyph ['vfill' + fill] : glyph-construction {
assign-unicode [0x2580 + fill]
start-from 0 [mix font.hhea.descent font.hhea.ascent [fill / 8]]
line-to WIDTH [mix font.hhea.descent font.hhea.ascent [fill / 8]]
line-to WIDTH font.hhea.descent line-to WIDTH font.hhea.descent
line-to 0 font.hhea.descent line-to 0 font.hhea.descent
} }
create-glyph ['hfill' + fill] : glyph-construction { define [Shade fn] : glyph-construction {
assign-unicode [0x2590 - fill] local top font.hhea.ascent
local bottom font.hhea.descent
local segx 6
local segy 16
foreach j [range 0 segx] : foreach k [range 0 segy] : if [fn j k] : begin {
start-from [mix 0 WIDTH [j / segx]] [mix bottom top [k / segy]]
line-to [mix 0 WIDTH [j / segx]] [mix bottom top [[k + 1] / segy]]
line-to [mix 0 WIDTH [[j + 1] / segx]] [mix bottom top [[k + 1] / segy]]
line-to [mix 0 WIDTH [[j + 1] / segx]] [mix bottom top [k / segy]]
}
}
create-glyph 'lightshade' : glyph-construction {
assign-unicode 0x2591
include : Shade [[j k] -> [[k % 2] && [j + [k - 1] / 2] % 2]]
}
create-glyph 'mediumshade' : glyph-construction {
assign-unicode 0x2592
include : Shade [[j k] -> [[j + k] % 2]]
}
create-glyph 'heavyshade' : glyph-construction {
assign-unicode 0x2593
include : Shade [[j k] -> [[k % 2] || [j + k / 2] % 2]]
}
let : foreach fill [range 1 8] : begin {
create-glyph ['vfill' + fill] : glyph-construction {
assign-unicode [0x2580 + fill]
start-from 0 [mix font.hhea.descent font.hhea.ascent [fill / 8]]
line-to WIDTH [mix font.hhea.descent font.hhea.ascent [fill / 8]]
line-to WIDTH font.hhea.descent
line-to 0 font.hhea.descent
}
create-glyph ['hfill' + fill] : glyph-construction {
assign-unicode [0x2590 - fill]
start-from 0 font.hhea.ascent
line-to [WIDTH * fill / 8] font.hhea.ascent
line-to [WIDTH * fill / 8] font.hhea.descent
line-to 0 font.hhea.descent
}
}
create-glyph 'upHalfblock' : glyph-construction {
assign-unicode 0x2580
start-from 0 font.hhea.ascent start-from 0 font.hhea.ascent
line-to [WIDTH * fill / 8] font.hhea.ascent line-to WIDTH font.hhea.ascent
line-to [WIDTH * fill / 8] font.hhea.descent line-to WIDTH [mix font.hhea.descent font.hhea.ascent 0.5]
line-to 0 font.hhea.descent line-to 0 [mix font.hhea.descent font.hhea.ascent 0.5]
}
create-glyph 'rightHalfBlock' : glyph-construction {
assign-unicode 0x2590
start-from [WIDTH * 0.5] font.hhea.ascent
line-to WIDTH font.hhea.ascent
line-to WIDTH font.hhea.descent
line-to [WIDTH * 0.5] font.hhea.descent
} }
} }
create-glyph 'upHalfblock' : glyph-construction {
assign-unicode 0x2580
start-from 0 font.hhea.ascent
line-to WIDTH font.hhea.ascent
line-to WIDTH [mix font.hhea.descent font.hhea.ascent 0.5]
line-to 0 [mix font.hhea.descent font.hhea.ascent 0.5]
}
create-glyph 'rightHalfBlock' : glyph-construction {
assign-unicode 0x2590
start-from [WIDTH * 0.5] font.hhea.ascent
line-to WIDTH font.hhea.ascent
line-to WIDTH font.hhea.descent
line-to [WIDTH * 0.5] font.hhea.descent
}
### Box drawing glyphs ### Box drawing glyphs
let : begin { let : begin {
local light : adviceBlackness 3.5 local light : adviceBlackness 3.5

View File

@ -1,5 +1,5 @@
SUPPORT_FILES = support/glyph.js support/stroke.js parameters.js generate.js empty.json SUPPORT_FILES = support/glyph.js support/stroke.js parameters.js generate.js empty.json
GLYPH_SEGMENTS = glyphs/common-shapes.patel glyphs/overmarks.patel glyphs/latin-basic-capital.patel glyphs/latin-basic-lower.patel glyphs/greek.patel glyphs/cyrillic-basic.patel glyphs/latin-extend.patel glyphs/cyrillic-extended.patel glyphs/numbers.patel glyphs/symbol-ascii.patel glyphs/symbol-punctuation.patel glyphs/symbol-math.patel glyphs/symbol-geometric.patel glyphs/symbol-letter.patel glyphs/autobuilds.patel GLYPH_SEGMENTS = glyphs/common-shapes.patel glyphs/overmarks.patel glyphs/latin-basic-capital.patel glyphs/latin-basic-lower.patel glyphs/greek.patel glyphs/cyrillic-basic.patel glyphs/latin-extend.patel glyphs/cyrillic-extended.patel glyphs/numbers.patel glyphs/symbol-ascii.patel glyphs/symbol-punctuation.patel glyphs/symbol-math.patel glyphs/symbol-geometric.patel glyphs/symbol-other.patel glyphs/symbol-letter.patel glyphs/autobuilds.patel
OBJDIR = build OBJDIR = build
SUPPRESS_ERRORS = 2> /dev/null SUPPRESS_ERRORS = 2> /dev/null

View File

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