mirror of
https://github.com/be5invis/Iosevka.git
synced 2026-10-28 16:38:35 +00:00
166 lines
5.6 KiB
Plaintext
166 lines
5.6 KiB
Plaintext
import '../support/glyph' as Glyph
|
|
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
|
|
import '../support/monotonic-interpolate' as smoothreg
|
|
import '../support/fairify' as fairify
|
|
|
|
import [mix linreg clamp fallback TempFont includeGlyphPart compsiteMarkSet] from '../support/utils'
|
|
import [calculateMetrics setFontMetrics MarksetDiv GenDivFrame] from '../meta/aesthetics'
|
|
import [assignFontNames] from '../meta/naming'
|
|
import '../meta/features' as Features
|
|
|
|
$$include '../meta/macros.ptl'
|
|
|
|
define [$NamedParameterPair$ l r] : begin
|
|
set this.left l
|
|
set this.right r
|
|
return this
|
|
|
|
define [$donothing$] nothing
|
|
|
|
# contour tagging
|
|
define [tagged tag component] : begin
|
|
set component.tag tag
|
|
return component
|
|
|
|
define [buildGlyphs para recursive recursiveCodes] : begin
|
|
define variantSelector para.variantSelector
|
|
local glyphList {}
|
|
local glyphs {.}
|
|
local unicodeGlyphs {}
|
|
|
|
define metrics : calculateMetrics para
|
|
define [object globalTransform UPM MIDDLE CAP XH SB RIGHTSB CONTRAST STROKE SUPERNESS WIDTH TANSLANT OVERLAYPOS DESCENDER MVERTSTROKE_D symbolMid parenTop parenBot operTop operBot plusTop plusBot tackTop tackBot adviceBlackness] metrics
|
|
|
|
define fontMetrics {.head {.} .hhea {.} .OS_2 {.} .post {.}}
|
|
setFontMetrics para metrics fontMetrics
|
|
|
|
# Anchor parameters
|
|
define [object MARK BASE] Anchor
|
|
define {AS_BASE ALSO_METRICS} {'AS-BASE' 'ALSO-METRICS'}
|
|
|
|
define MarkSet : MarksetDiv 1 metrics
|
|
define DivFrame : GenDivFrame metrics
|
|
|
|
### Glyph slots and dependency profile generation (used for recursive subfonts)
|
|
local dependencyProfile {.}
|
|
local nTemp 0
|
|
define [newtemp] : set nTemp (nTemp + 1)
|
|
local nPending 0
|
|
local pickHash : if recursive
|
|
then : let [h {.}] : begin
|
|
foreach j [items-of recursive] : set h.(j) j
|
|
set nPending recursive.length
|
|
* h
|
|
else nothing
|
|
|
|
define [getDependencyProfile glyph] : begin
|
|
local dp {}
|
|
foreach d [items-of glyph.dependencies] : begin
|
|
dp.push d
|
|
if dependencyProfile.(d): foreach [k : items-of dependencyProfile.(d)] : dp.push k
|
|
return dp
|
|
|
|
define [create-glyph] : match [Array.prototype.slice.call arguments 0]
|
|
`[@name @actions] : begin
|
|
if (pickHash && [not pickHash.(name)]) : return nothing
|
|
|
|
if para.verbose : console.log name
|
|
local glyphObject [new Glyph name]
|
|
glyphList.push glyphObject
|
|
glyphs.(name) = glyphObject
|
|
glyphObject.set-width WIDTH
|
|
glyphObject.gizmo = globalTransform
|
|
|
|
actions.call glyphObject
|
|
|
|
set dependencyProfile.(name) : getDependencyProfile glyphObject
|
|
dec nPending
|
|
return glyphObject
|
|
|
|
`[@actions] : begin
|
|
local glyphName ('.temp-' + [newtemp])
|
|
if para.verbose : console.log glyphName
|
|
local glyphObject [new Glyph glyphName]
|
|
glyphObject.set-width WIDTH
|
|
glyphObject.gizmo = globalTransform
|
|
actions.call glyphObject
|
|
return glyphObject
|
|
|
|
define [$save$ _name unicode] : begin
|
|
define t this
|
|
define name : if [not _name] ('--autoname-' + [newtemp]) _name
|
|
local g : create-glyph name [lambda]
|
|
if g : begin
|
|
g.include t AS_BASE
|
|
if (t <@ Glyph) : begin
|
|
set g.advanceWidth t.advanceWidth
|
|
set g.shortName t.shortName
|
|
set g.cmpPriority t.cmpPriority
|
|
set g.flatten t.flatten
|
|
if name : set dependencyProfile.(name) : getDependencyProfile g
|
|
if (g && unicode) : begin
|
|
g.assign-unicode unicode
|
|
set unicodeGlyphs.(g.unicode.((g.unicode.length - 1))) g
|
|
return g
|
|
|
|
define [save-glyph name unicode g] : $save$.call g name unicode
|
|
|
|
### Spiro constructions
|
|
# Basic knots
|
|
define spirofns : spirokit.SetupBuilders : object globalTransform CONTRAST STROKE Glyph para SUPERNESS
|
|
|
|
# IDKY, but wrapping "metrics" prevents Node.js on Arch modifying it.
|
|
define $$Capture$$ : object [metrics : Object.create metrics] $NamedParameterPair$ $donothing$ para recursive recursiveCodes variantSelector glyphs glyphList unicodeGlyphs create-glyph $save$ save-glyph spirofns MarkSet MARK BASE AS_BASE ALSO_METRICS pickHash dependencyProfile getDependencyProfile buildGlyphs newtemp tagged includeGlyphPart compsiteMarkSet DivFrame fontMetrics
|
|
|
|
### HERE WE GO
|
|
run-glyph-module '../glyphs/common-shapes.js'
|
|
run-glyph-module '../glyphs/space.js'
|
|
run-glyph-module '../glyphs/overmarks.js'
|
|
|
|
# Unified letters
|
|
run-glyph-module '../glyphs/letters-unified-basic.js'
|
|
run-glyph-module '../glyphs/letters-unified-extended.js'
|
|
|
|
# Numbers
|
|
run-glyph-module '../glyphs/numbers.js'
|
|
|
|
# Symbols
|
|
run-glyph-module '../glyphs/symbol-punctuation.js'
|
|
run-glyph-module '../glyphs/symbol-arrow.js'
|
|
run-glyph-module '../glyphs/symbol-geometric.js'
|
|
run-glyph-module '../glyphs/symbol-math.js'
|
|
run-glyph-module '../glyphs/symbol-letter.js'
|
|
run-glyph-module '../glyphs/symbol-braille.js'
|
|
run-glyph-module '../glyphs/symbol-mosaic.js'
|
|
run-glyph-module '../glyphs/symbol-other.js'
|
|
|
|
# Autobuilds
|
|
run-glyph-module '../glyphs/autobuild-accents.js'
|
|
run-glyph-module '../glyphs/autobuild-enclosure.js'
|
|
run-glyph-module '../glyphs/autobuild-transformed.js'
|
|
|
|
return : object metrics glyphs glyphList unicodeGlyphs
|
|
|
|
# Main build procedure
|
|
export as build : define [buildFont font para] : begin
|
|
|
|
define gs : buildGlyphs para
|
|
|
|
assignFontNames para gs.metrics font
|
|
setFontMetrics para gs.metrics font
|
|
|
|
local otl : Features.apply para gs.glyphs gs.glyphList gs.unicodeGlyphs
|
|
set font.GSUB otl.GSUB
|
|
set font.GPOS otl.GPOS
|
|
set font.GDEF otl.GDEF
|
|
|
|
if (para.forceMonospace && para.spacing == 0) : begin
|
|
set gs.glyphList : gs.glyphList.filter [lambda [g] : g.advanceWidth <= para.width]
|
|
|
|
set font.glyfMap gs.glyphs
|
|
set font.glyf gs.glyphList
|
|
return font
|