mirror of
https://github.com/be5invis/Iosevka.git
synced 2026-10-28 16:38:35 +00:00
424 lines
16 KiB
Plaintext
424 lines
16 KiB
Plaintext
###### Automatic builds
|
|
$$include '../meta/macros.ptl'
|
|
|
|
import [mix linreg clamp fallback] from '../support/utils'
|
|
|
|
export : define [apply] : begin
|
|
glyph-module-entry commonShapes overmarks
|
|
|
|
define [suggestName _name] : begin
|
|
local name _name
|
|
if glyphs.(name) : begin
|
|
local j 2
|
|
while glyphs.(name + j) : inc j
|
|
set name (name + j)
|
|
return name
|
|
|
|
# Build miniature glyphs : circled, superscripts, subscripts...
|
|
# Circled
|
|
|
|
define circleWidthClasses {{'hwid' WIDTH 0.12} {'fwid' FULLWIDTH0 0.08}}
|
|
define [AdjustDigitCount digits width] : Math.max 1 (digits * WIDTH / width)
|
|
define [EnclosureStrokeScale dscale digits width] : dscale / [Math.pow [AdjustDigitCount digits width] 0.66]
|
|
|
|
define [circleInner dscale miniatureFont unicode parts width bal baly] : begin
|
|
define gni : '.ci.' + [parts.join '_'] + '.' + [{dscale width bal baly}.join '.']
|
|
if (glyphs.(gni)) : return glyphs.(gni)
|
|
define lg : create-glyph gni : glyph-construction
|
|
local tw 0
|
|
foreach [glyphid : items-of parts] : begin
|
|
local g miniatureFont.(glyphid)
|
|
include g
|
|
apply-transform : Translate (-g.advanceWidth) 0
|
|
set tw : tw + g.advanceWidth
|
|
apply-transform : Translate tw 0
|
|
apply-transform : Upright
|
|
apply-transform : Scale [Math.min 1 (width / tw)] 1
|
|
set tw : Math.min width tw
|
|
local shift 0
|
|
if (g.anchors.above && g.anchors.below) : begin
|
|
if bal : set shift : CAP / 2 - [mix baly [mix g.anchors.above.y g.anchors.below.y 0.5] bal]
|
|
: else : set shift : CAP / 2 - [mix g.anchors.above.y g.anchors.below.y 0.5]
|
|
apply-transform : Translate (-tw / 2) (-CAP / 2 + shift)
|
|
apply-transform : Scale dscale
|
|
apply-transform : Translate (width / 2) (CAP / 2 * dscale)
|
|
apply-transform : Italify
|
|
set currentGlyph.cmpPriority 12
|
|
refair currentGlyph
|
|
set-width 0
|
|
return lg
|
|
|
|
define [CircCrowd digits width] : 2 + 2 * [AdjustDigitCount digits width]
|
|
define [CircScale digits width] : 0.65 / [Math.pow [AdjustDigitCount digits width] 0.5]
|
|
|
|
define [circleDimens digits dscale w m] : begin
|
|
define width : fallback w WIDTH
|
|
define dscale : linreg WIDTH 0.55 UPM 0.6 width
|
|
define spatt : linreg WIDTH 0.175 UPM 0.27 width
|
|
define sw0 : [EnclosureStrokeScale dscale digits width] * [adviceBlackness [CircCrowd digits width]] / [CircScale digits width]
|
|
define sw : Math.max sw0 [fallback m 0]
|
|
define top : CAP * dscale + [Math.max (CAP * spatt) (sw * 3)]
|
|
define bot : 0 - [Math.max (CAP * spatt) (sw * 3)]
|
|
define left : Math.max
|
|
SB + O * 3
|
|
Math.min
|
|
width / 2 - (top - bot) / 2
|
|
width / 2 - CAP / 2 * dscale - sw * 2.5
|
|
define right : Math.min
|
|
width - SB - O * 3
|
|
Math.max
|
|
width / 2 + (top - bot) / 2
|
|
width / 2 + CAP / 2 * dscale + sw * 2.5
|
|
return : object width dscale sw0 sw top bot left right
|
|
|
|
define [CircledMiniatureFont digits width records] : begin
|
|
local pendingGlyphs : records.map : [record] => record.1
|
|
return : Miniature
|
|
glyphs -- [pendingGlyphs.reduce : [a b] => [a.concat b]]
|
|
crowd -- [CircCrowd digits width]
|
|
scale -- [CircScale digits width]
|
|
unfair -- true
|
|
sbscale -- 1
|
|
|
|
define [CircName prefix digits parts suffix] : suggestName : prefix + '-' + digits + '-' + [parts.join '_'] + '.' + suffix
|
|
|
|
define [createCircledGlyphs digits records] : begin
|
|
foreach {suffix ww} [items-of circleWidthClasses] : do
|
|
local miniatureFont : CircledMiniatureFont digits ww records
|
|
foreach {unicode parts w bal baly} [items-of records] : do
|
|
define [object width dscale sw top bot left right] : circleDimens digits dscale ww
|
|
create-glyph [CircName 'circle' digits parts suffix] : glyph-construction
|
|
set-width width
|
|
if (w == ww && unicode) : assign-unicode unicode
|
|
include : circleInner dscale miniatureFont unicode parts width bal baly
|
|
include : OShape top bot left right sw (SMALLSMOOTHA * width / WIDTH) (SMALLSMOOTHB * width / WIDTH)
|
|
|
|
apply-transform : Upright
|
|
apply-transform : Translate 0 (symbolMid - CAP * dscale / 2)
|
|
apply-transform : Italify
|
|
|
|
define [createBoxedGlyphs digits records] : begin
|
|
foreach {suffix ww} [items-of circleWidthClasses] : do
|
|
local miniatureFont : CircledMiniatureFont digits ww records
|
|
foreach {unicode parts w bal baly} [items-of records] : do
|
|
define [object width dscale sw top bot left right] : circleDimens digits dscale ww
|
|
create-glyph [CircName 'boxed' digits parts suffix] : glyph-construction
|
|
set-width width
|
|
if (w == ww && unicode) : assign-unicode unicode
|
|
include : circleInner dscale miniatureFont unicode parts width bal baly
|
|
include : union
|
|
HBarTop left right top sw
|
|
HBarBottom left right bot sw
|
|
VBarLeft left bot top sw
|
|
VBarRight right bot top sw
|
|
|
|
apply-transform : Upright
|
|
apply-transform : Translate 0 (symbolMid - CAP * dscale / 2)
|
|
apply-transform : Italify
|
|
|
|
define [createInsetCircledGlyphs digits records] : begin
|
|
foreach {suffix ww} [items-of circleWidthClasses] : do
|
|
local miniatureFont : CircledMiniatureFont digits ww records
|
|
foreach {unicode parts w bal baly} [items-of records] : do
|
|
define [object width dscale sw top bot left right] : circleDimens digits dscale ww
|
|
create-glyph [CircName 'inset-circle' digits parts suffix] : glyph-construction
|
|
set-width width
|
|
if (w == ww && unicode) : assign-unicode unicode
|
|
include : difference
|
|
OShapeOutline top bot left right sw (SMALLSMOOTHA * width / WIDTH) (SMALLSMOOTHB * width / WIDTH)
|
|
circleInner dscale miniatureFont unicode parts width bal baly
|
|
|
|
apply-transform : Upright
|
|
apply-transform : Translate 0 (symbolMid - CAP * dscale / 2)
|
|
apply-transform : Italify
|
|
|
|
define [createInsetBoxedGlyphs digits records] : begin
|
|
foreach {suffix ww} [items-of circleWidthClasses] : do
|
|
local miniatureFont : CircledMiniatureFont digits ww records
|
|
foreach {unicode parts w bal baly} [items-of records] : do
|
|
define [object width dscale sw top bot left right] : circleDimens digits dscale ww
|
|
create-glyph [CircName 'inset-boxed' digits parts suffix] : glyph-construction
|
|
set-width width
|
|
if (w == ww && unicode) : assign-unicode unicode
|
|
include : difference
|
|
spiro-outline
|
|
corner left top
|
|
corner left bot
|
|
corner right bot
|
|
corner right top
|
|
close
|
|
circleInner dscale miniatureFont unicode parts width bal baly
|
|
|
|
apply-transform : Upright
|
|
apply-transform : Translate 0 (symbolMid - CAP * dscale / 2)
|
|
apply-transform : Italify
|
|
|
|
define [createDoubleCircledGlyphs digits records] : begin
|
|
foreach {suffix ww gap} [items-of circleWidthClasses] : do
|
|
local miniatureFont : CircledMiniatureFont digits ww records
|
|
foreach {unicode parts w bal baly} [items-of records] : do
|
|
define [object width dscale sw0 sw top bot left right] : circleDimens digits dscale ww (ww * gap)
|
|
define sw1 : Math.min sw0 (sw / 3)
|
|
create-glyph [CircName 'double-circle' digits parts suffix] : glyph-construction
|
|
set-width width
|
|
if (w == ww && unicode) : assign-unicode unicode
|
|
include : circleInner dscale miniatureFont unicode parts width bal baly
|
|
include : OShape top bot left right sw1 (SMALLSMOOTHA * width / WIDTH) (SMALLSMOOTHB * width / WIDTH)
|
|
include : OShape
|
|
top - sw + sw1
|
|
bot + sw - sw1
|
|
left + sw * HVCONTRAST - sw1 * HVCONTRAST
|
|
right - sw * HVCONTRAST + sw1 * HVCONTRAST
|
|
begin sw1
|
|
SMALLSMOOTHA * width / WIDTH - sw + sw1
|
|
SMALLSMOOTHB * width / WIDTH - sw + sw1
|
|
|
|
apply-transform : Upright
|
|
apply-transform : Translate 0 (symbolMid - CAP * dscale / 2)
|
|
apply-transform : Italify
|
|
|
|
define [BraceCrowd digits width] : 2.75 + [AdjustDigitCount digits width]
|
|
define [BraceScale digits width] : 0.65 / [Math.pow [AdjustDigitCount digits width] 0.5]
|
|
define [bracedDottdeDimens digits width] : begin
|
|
define dscale : linreg WIDTH 0.55 UPM 0.65 width
|
|
define pscale : linreg WIDTH 0.6 UPM 0.75 width
|
|
define sw0 : [EnclosureStrokeScale dscale digits width] * [adviceBlackness [BraceCrowd digits width]] / [BraceScale digits width]
|
|
define sw : Math.min STROKE sw0
|
|
define l : Math.max (SB + O * 3) (width / 2 - [Math.max (WIDTH * digits) CAP] / 2)
|
|
define r : width - l
|
|
return : object width sw dscale pscale l r
|
|
|
|
define [createBracedGlyphs digits records] : begin
|
|
foreach {suffix ww} [items-of circleWidthClasses] : do
|
|
define pendingGlyphs : records.map : [record] => record.1
|
|
define miniatureFont : Miniature
|
|
glyphs -- [pendingGlyphs.reduce : [a b] => [a.concat b]]
|
|
crowd -- [BraceCrowd digits ww]
|
|
scale -- [BraceScale digits ww]
|
|
sbscale -- 1
|
|
unfair -- true
|
|
|
|
define gnb : CircName '.braced-brace' digits {} suffix
|
|
define braceGlyph : create-glyph gnb : glyph-construction
|
|
define [object width dscale pscale sw l r] : bracedDottdeDimens digits ww
|
|
local s : TANSLANT * symbolMid / 2
|
|
set-width width
|
|
include : dispiro
|
|
widths.lhs sw
|
|
g4 ([mix l r 0.15] - s) (parenTop * pscale)
|
|
g4.down.mid (l - s + O) (symbolMid * pscale)
|
|
g4 ([mix l r 0.15] - s) (parenBot * pscale)
|
|
|
|
include : dispiro
|
|
widths.rhs sw
|
|
g4 ([mix r l 0.15] + s) (parenTop * pscale)
|
|
g4.down.mid (r + s - O) (symbolMid * pscale)
|
|
g4 ([mix r l 0.15] + s) (parenBot * pscale)
|
|
|
|
include : Upright
|
|
include : Translate 0 (symbolMid - symbolMid * pscale)
|
|
include : Italify
|
|
|
|
foreach {unicode parts w bal baly} [items-of records] : do
|
|
define [object width dscale pscale sw l r] : bracedDottdeDimens digits ww
|
|
local gn : CircName 'braced' digits parts suffix
|
|
local gni : CircName '.braced-inner' digits parts suffix
|
|
|
|
local lg : create-glyph gni : glyph-construction
|
|
local tw 0
|
|
local lastg null
|
|
foreach [glyphid : items-of parts] : begin
|
|
local g miniatureFont.(glyphid)
|
|
if tw : begin # Add a little kern
|
|
set tw : tw - SB
|
|
apply-transform : Translate SB 0
|
|
include g
|
|
apply-transform : Translate (-g.advanceWidth) 0
|
|
set tw : tw + g.advanceWidth
|
|
set lastg g
|
|
apply-transform : Translate tw 0
|
|
apply-transform : Upright
|
|
apply-transform : Scale [Math.min 1 (width / tw)] 1
|
|
set tw : Math.min width tw
|
|
apply-transform : Translate (-tw / 2) 0
|
|
apply-transform : Scale dscale
|
|
|
|
local shift 0
|
|
if (lastg.anchors.above && lastg.anchors.below) : begin
|
|
local gMiddleY [mix lastg.anchors.above.y lastg.anchors.below.y 0.5]
|
|
if bal : set shift : CAP / 2 - [mix baly gMiddleY bal]
|
|
: else : set shift : CAP / 2 - gMiddleY
|
|
|
|
apply-transform : Translate (width / 2) (symbolMid - (CAP / 2 - shift) * dscale)
|
|
apply-transform : Italify
|
|
set currentGlyph.cmpPriority 11
|
|
refair currentGlyph
|
|
set-width 0
|
|
|
|
sketch
|
|
set-width width
|
|
include lg
|
|
include braceGlyph
|
|
|
|
if (w == ww) : save gn unicode
|
|
: else : save gn
|
|
|
|
define [createDottedGlyphs digits records] : begin
|
|
foreach {suffix ww} [items-of circleWidthClasses] : do
|
|
local pendingGlyphs : records.map : [record] => record.1
|
|
local miniatureFont : Miniature
|
|
glyphs -- [[pendingGlyphs.reduce : [a b] => [a.concat b]].concat {'period'}]
|
|
crowd -- [BraceCrowd digits ww]
|
|
scale -- [BraceScale digits ww]
|
|
sbscale -- 1
|
|
unfair -- true
|
|
|
|
foreach {unicode parts w} [items-of records] : do
|
|
local gn : CircName 'dotted' digits parts suffix
|
|
define [object width dscale pscale sw l r] : bracedDottdeDimens 1 ww
|
|
sketch
|
|
set-width width
|
|
local tw 0
|
|
foreach [glyphid : items-of : parts.concat {'period'}] : begin
|
|
local g miniatureFont.(glyphid)
|
|
if tw : begin # Add a little kern
|
|
set tw : tw - SB
|
|
apply-transform : Translate SB 0
|
|
include g
|
|
apply-transform : Translate (-g.advanceWidth) 0
|
|
set tw : tw + g.advanceWidth
|
|
apply-transform : Translate tw 0
|
|
set tw : tw - SB
|
|
apply-transform : Upright
|
|
if (tw > width)
|
|
: then : apply-transform : Scale [Math.min 1 (width / tw)] 1
|
|
: else : apply-transform : Translate (width / 2 - tw / 2) 0
|
|
apply-transform : Italify
|
|
set currentGlyph.cmpPriority 11
|
|
|
|
if (w == ww) : save gn unicode
|
|
: else : save gn
|
|
|
|
# Circled & Braced
|
|
define [digitGlyphNames j] : [(j+'').split ''].map: c => unicodeGlyphs.(['0'.charCodeAt 0] + (c - 0)).name
|
|
|
|
if [not recursive] : do "Single-digit circled"
|
|
local compositions : list
|
|
list 0xA9 {'C'} FULLWIDTH2
|
|
list 0x1F12F {'turnC'} FULLWIDTH2
|
|
list 0xAE {'R'} FULLWIDTH2
|
|
list 0x2117 {'P'} FULLWIDTH2
|
|
list 0x24EA {'zero'} FULLWIDTH1
|
|
compositions.push { null {'space'} FULLWIDTH1 }
|
|
foreach [j : range 1 till 9] : compositions.push : list
|
|
0x2460 + j - 1
|
|
digitGlyphNames j
|
|
begin FULLWIDTH1
|
|
foreach [j : range 0 26] : compositions.push {(0x24B6 + j) {unicodeGlyphs.(['A'.charCodeAt 0] + j).name} FULLWIDTH1}
|
|
foreach [j : range 0 26] : compositions.push {(0x24D0 + j) {unicodeGlyphs.(['a'.charCodeAt 0] + j).name} FULLWIDTH1 0.5 (XH/2)}
|
|
createCircledGlyphs 1 compositions
|
|
|
|
if [not recursive] : do "Double-digit circled"
|
|
local compositions : list
|
|
compositions.push { null {'space'} FULLWIDTH1 }
|
|
foreach [j : range 10 till 20] : compositions.push : list
|
|
0x2460 + j - 1
|
|
digitGlyphNames j
|
|
begin FULLWIDTH1
|
|
foreach [j : range 21 till 35] : compositions.push : list
|
|
0x3251 + j - 21
|
|
digitGlyphNames j
|
|
begin FULLWIDTH1
|
|
foreach [j : range 36 till 50] : compositions.push : list
|
|
0x32B1 + j - 36
|
|
digitGlyphNames j
|
|
begin FULLWIDTH1
|
|
createCircledGlyphs 2 compositions
|
|
|
|
if [not recursive] : do "Single-digit inset circled"
|
|
local compositions : list
|
|
list 0x24FF {'zero'} FULLWIDTH1
|
|
foreach [j : range 1 till 9] : compositions.push : list
|
|
0x2776 + j - 1
|
|
digitGlyphNames j
|
|
begin FULLWIDTH1
|
|
foreach [j : range 0 26] : compositions.push {(0x1F150 + j) {unicodeGlyphs.(['A'.charCodeAt 0] + j).name} FULLWIDTH1}
|
|
createInsetCircledGlyphs 1 compositions
|
|
|
|
if [not recursive] : do "Double-digit inset circled"
|
|
local compositions : list
|
|
foreach [j : range 10 till 10] : compositions.push : list
|
|
0x2776 + j - 1
|
|
digitGlyphNames j
|
|
begin FULLWIDTH1
|
|
foreach [j : range 11 till 20] : compositions.push : list
|
|
0x24EB + j - 11
|
|
digitGlyphNames j
|
|
begin FULLWIDTH1
|
|
createInsetCircledGlyphs 2 compositions
|
|
|
|
if [not recursive] : do
|
|
local compositions {}
|
|
compositions.push { null {'space'} FULLWIDTH1 }
|
|
foreach [j : range 0 26] : compositions.push {(0x1F130 + j) {unicodeGlyphs.(['A'.charCodeAt 0] + j).name} FULLWIDTH1}
|
|
createBoxedGlyphs 1 compositions
|
|
|
|
if [not recursive] : do
|
|
local compositions {}
|
|
foreach [j : range 0 26] : compositions.push {(0x1F170 + j) {unicodeGlyphs.(['A'.charCodeAt 0] + j).name} FULLWIDTH1}
|
|
createInsetBoxedGlyphs 1 compositions
|
|
|
|
if [not recursive] : do "Single-digit double circled"
|
|
local compositions {}
|
|
compositions.push { null {'space'} FULLWIDTH1 }
|
|
foreach [j : range 1 till 9] : compositions.push : list
|
|
0x24F5 + j - 1
|
|
digitGlyphNames j
|
|
begin FULLWIDTH1
|
|
createDoubleCircledGlyphs 1 compositions
|
|
|
|
if [not recursive] : do "Double-digit double circled"
|
|
local compositions {}
|
|
compositions.push { null {'space'} FULLWIDTH1 }
|
|
foreach [j : range 10 till 10] : compositions.push : list
|
|
0x24F5 + j - 1
|
|
digitGlyphNames j
|
|
begin FULLWIDTH1
|
|
createDoubleCircledGlyphs 2 compositions
|
|
|
|
if [not recursive] : do "Single-digit braced"
|
|
local compositions {}
|
|
foreach [j : range 1 till 9] : compositions.push : list
|
|
0x2474 + j - 1
|
|
digitGlyphNames j
|
|
begin FULLWIDTH1
|
|
foreach [j : range 0 26] : compositions.push {(0x249C + j) {unicodeGlyphs.(['a'.charCodeAt 0] + j).name} FULLWIDTH1 0.5 (XH/2)}
|
|
foreach [j : range 0 26] : compositions.push {(0x1F110 + j) {unicodeGlyphs.(['A'.charCodeAt 0] + j).name} FULLWIDTH1}
|
|
createBracedGlyphs 1 compositions
|
|
|
|
if [not recursive] : do "Double-digit braced"
|
|
local compositions {}
|
|
foreach [j : range 10 till 20] : compositions.push : list
|
|
0x2474 + j - 1
|
|
digitGlyphNames j
|
|
begin FULLWIDTH1
|
|
createBracedGlyphs 2 compositions
|
|
|
|
if [not recursive] : do "Single-digit dotted"
|
|
local compositions : list
|
|
list 0x1F100 {'zero'} FULLWIDTH1
|
|
foreach [j : range 1 till 9] : compositions.push : list
|
|
0x2488 + j - 1
|
|
digitGlyphNames j
|
|
begin FULLWIDTH1
|
|
createDottedGlyphs 1 compositions
|
|
|
|
if [not recursive] : do "Double-digit dotted"
|
|
local compositions : list
|
|
foreach [j : range 10 till 20] : compositions.push : list
|
|
0x2488 + j - 1
|
|
digitGlyphNames j
|
|
begin FULLWIDTH1
|
|
createDottedGlyphs 2 compositions
|
|
|