Optimized /five.

This commit is contained in:
be5invis 2015-11-24 07:39:30 +08:00
parent 97a8b468fe
commit 7a14ae47b1
12 changed files with 55 additions and 75 deletions

View File

@ -20,7 +20,16 @@ define [clamp l h x] : if (x < l) l : if (x > h) h x
define [fallback] : for [local j 0] (j < arguments.length) [inc j] : if (arguments.(j) !== nothing) : return arguments.(j)
define [TempFont] {.glyf {} .head {.} .hhea {.} ."OS/2" {.} .name {.} .post {.}}
define [normalize a] : begin
local m : Math.hypot a.x a.y
return {.x (a.x / m) .y (a.y / m)}
define [anchorDeriv] : begin
local h {.}
foreach a [items-of arguments] : foreach k [items-of [Object.keys a.anchors]] : begin
set h.(k) {.}
set {.x h.(k).x .y h.(k).y .type h.(k).type .mbx h.(k).mbx .mby h.(k).mby} a.anchors.(k)
return {.anchors h}
# Empty font base file
### File inclusion macro
@ -61,8 +70,6 @@ define-macro eject-contour : syntax-rules
`[eject-contour @::args] {'.syntactic-closure' `[currentGlyph.eject-contour @::args] env}
define-macro tag-contour : syntax-rules
`[tag-contour @name] {'.syntactic-closure' `(currentGlyph.contours.(currentGlyph.contours.length - 1).tag = @name) env}
define-macro dont-export : syntax-rules
`[dont-export] {".syntactic-closure" `[set currentGlyph.dontExport true] env}
define-macro assign-unicode : syntax-rules
`[assign-unicode @code] {".syntactic-closure" `[begin \\
currentGlyph.assign-unicode @code
@ -72,9 +79,8 @@ define-macro assign-unicode : syntax-rules
define-macro glyph-construction : syntax-rules
`[glyph-construction @::steps] {'.syntactic-closure' `[lambda [] [begin \\
local currentGlyph this
currentGlyph.gizmo = globalTransform
begin @::[steps.map formOf]
return nothing
return currentGlyph
]] env}
# contour tagging
@ -94,7 +100,7 @@ define [buildFont para recursive] : begin
define unicodeGlyphs {}
define UPM 1000
define serifed : not [not para.serif]
# Key metrics
define WIDTH para.width
define SB para.sb
@ -105,6 +111,8 @@ define [buildFont para recursive] : begin
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 operTop : mix parenMid parenTop 0.8
local operBot : mix parenMid parenBot 0.8
# Transform constructors
define [Italify angle shift] : begin
@ -124,9 +132,6 @@ define [buildFont para recursive] : begin
define DOWNWARD {.x CORRECTION_HX .y 0}
define RIGHTWARD {.x globalTransform.yx .y 1}
define LEFTWARD {.x (- globalTransform.yx) .y (-1)}
define [normalize a] : begin
local m : Math.hypot a.x a.y
return {.x (a.x / m) .y (a.y / m)}
# Style parameters
define O para.overshoot
@ -226,7 +231,7 @@ define [buildFont para recursive] : begin
define AS_BASE 'AS-BASE'
define [tm anchor] : return {
.x (anchor.x * globalTransform.xx + anchor.y * globalTransform.yx + globalTransform.x)
.x (anchor.x * globalTransform.xx + anchor.y * globalTransform.yx + globalTransform.x)
.y (anchor.x * globalTransform.xy + anchor.y * globalTransform.yy + globalTransform.y)
.type anchor.type
}
@ -240,12 +245,6 @@ define [buildFont para recursive] : begin
define markBottomrightLower {.anchors {.bottomright [tm {.x RIGHTSB .y DESCENDER .type BASE}]}}
define markBottomrightZero {.anchors {.bottomright [tm {.x RIGHTSB .y 0 .type BASE}]}}
define [anchorDeriv] : begin
local h {.}
foreach a [items-of arguments] : foreach k [items-of [Object.keys a.anchors]] : begin
set h.(k) {.}
set {.x h.(k).x .y h.(k).y .type h.(k).type .mbx h.(k).mbx .mby h.(k).mby} a.anchors.(k)
return {.anchors h}
define [StdAnchorGroup] : begin
local a : anchorDeriv.apply null arguments
set a.anchors.overlay {.type BASE
@ -279,6 +278,7 @@ define [buildFont para recursive] : begin
set dependencyProfile.(name) {}
define glyphObject [new Glyph name]
glyphObject.set-width WIDTH
glyphObject.gizmo = globalTransform
glyphList.push glyphObject
glyphs.(name) = glyphObject
actions.call glyphObject
@ -320,7 +320,7 @@ define [buildFont para recursive] : begin
widths heading unimportant important
alsothru alsothruthem bezcontrols quadcontrols archv arcvh complexThru
dispiro spiro-outline] : spirokit.SetupBuilders : object globalTransform CONTRAST STROKE Glyph para SUPERNESS
###### HERE WE GO!
### Metadata
@ -374,11 +374,13 @@ define [buildFont para recursive] : begin
line-to (RIGHTSB - STROKE) (CAP - STROKE)
line-to (SB + STROKE) (CAP - STROKE)
# Space
create-glyph 'space' : glyph-construction
set-width WIDTH
assign-unicode ' '
include eMarks
### HERE WE GO
$$include 'glyphs/common-shapes.patel'
$$include 'glyphs/overmarks.patel'

View File

@ -304,9 +304,8 @@ define [LegShape xt xb xs top bottom _fine] : glyph-construction
widths.lhs fine
flat xt top [heading DOWNWARD]
curl xb (bottom + LONGJUT)
alsothruthem {{0.5 0.94}} important
flat (xs + 1) (bottom + fine) [heading LEFTWARD]
curl xs (bottom + fine) [heading LEFTWARD]
alsothruthem {{0.5 0.94}}
g4.left.end xs (bottom + fine) [heading LEFTWARD]
define [LeftHook x y xextend] : glyph-construction
local fine : adviceBlackness 4.25

View File

@ -123,11 +123,9 @@ create-glyph 'cyrI' : glyph-construction
create-glyph 'cyri.upright' : glyph-construction
include eMarks
dont-export
include : CyrIShape XH
create-glyph 'cyri.italic' : glyph-construction
dont-export
include glyphs.u AS_BASE
italic-variant 'cyri' 0x438

View File

@ -401,7 +401,6 @@ create-glyph 'L' : glyph-construction
create-glyph 'I.straight' : glyph-construction
dont-export
include capitalMarks
include : VBar MIDDLE 0 CAP
@ -419,7 +418,6 @@ define [ISerifShape top] : glyph-construction
curl (MIDDLE + WIDTH * 0.26 + STROKE * globalTransform.yx) 0
create-glyph 'I.serifed' : glyph-construction
dont-export
include capitalMarks
include : ISerifShape CAP
@ -473,7 +471,6 @@ create-glyph 'Z' : glyph-construction
create-glyph 'J.straight' : glyph-construction
set-width WIDTH
dont-export
include capitalMarks
set-anchor 'overlay' BASE (RIGHTSB - STROKE * CORRECTION_HX - JBALANCE2) (CAP * BARPOS)
@ -493,7 +490,6 @@ create-glyph 'J.straight' : glyph-construction
create-glyph 'J.shorthook' : glyph-construction
set-width WIDTH
dont-export
include capitalMarks
local slope (STROKE * 0.00092)
@ -511,7 +507,6 @@ create-glyph 'J.shorthook' : glyph-construction
create-glyph 'J.serifed' : glyph-construction
set-width WIDTH
dont-export
include glyphs.'J.straight' AS_BASE
include : LeftwardTopSerif (RIGHTSB - HALFSTROKE * CORRECTION_HX - JBALANCE2) CAP LONGJUT

View File

@ -194,7 +194,6 @@ create-glyph 't' : glyph-construction
### a u
create-glyph 'a.upright' : glyph-construction
set-width WIDTH
dont-export
include eMarks
set-anchor 'trailing' BASE (RIGHTSB - markHalfStroke) 0
local bartop (XH * BARPOS * 1.02 + HALFSTROKE)
@ -223,7 +222,6 @@ create-glyph 'a.upright' : glyph-construction
create-glyph 'a.italic' : glyph-construction
set-width WIDTH
dont-export
include eMarks
set-anchor 'trailing' BASE (RIGHTSB - markHalfStroke) 0
include : oRight
@ -311,22 +309,18 @@ create-glyph 'm' : glyph-construction
### i j l
create-glyph 'dotlessi.straight' : glyph-construction
dont-export
include eMarks
include : VBar (MIDDLE) 0 XH
create-glyph 'dotlessi.hooky' : glyph-construction
dont-export
include glyphs.'dotlessi.straight' AS_BASE
include : LeftwardTopSerif MIDDLE XH LONGJUT
create-glyph 'dotlessi.zshaped' : glyph-construction
dont-export
include glyphs.'dotlessi.hooky' AS_BASE
include : RightwardBottomSerif MIDDLE 0 LONGJUT
create-glyph 'dotlessi.serifed' : glyph-construction
dont-export
include eMarks
local balance IBALANCE
@ -362,7 +356,6 @@ create-glyph 'i' : glyph-construction
create-glyph 'dotlessj.straight' : glyph-construction
dont-export
include pMarks
set-anchor 'above' BASE (MIDDLE + JBALANCE - STROKE * 0.166 * CORRECTION_HX) XH
set-anchor 'overlay' BASE (MIDDLE + JBALANCE - STROKE * 0.166 * CORRECTION_HX) (XH / 2)
@ -378,7 +371,6 @@ create-glyph 'dotlessj.straight' : glyph-construction
g4 hookx (DESCENDER + JHOOK)
create-glyph 'dotlessj.serifed' : glyph-construction
dont-export
include pMarks
include glyphs.'dotlessj.straight' AS_BASE
include : LeftwardTopSerif (MIDDLE + JBALANCE) XH LONGJUT
@ -395,24 +387,20 @@ create-glyph 'j' : glyph-construction
create-glyph 'l.straight' : glyph-construction
include bMarks
dont-export
include : VBar MIDDLE 0 CAP
create-glyph 'l.hooky' : glyph-construction
include bMarks
dont-export
include : VBar MIDDLE 0 (CAP - STROKE)
include : LeftwardTopSerif MIDDLE CAP LONGJUT
create-glyph 'l.zshaped' : glyph-construction
include bMarks
dont-export
include glyphs.'l.hooky'
include : RightwardBottomSerif MIDDLE 0 LONGJUT
create-glyph 'l.serifed' : glyph-construction
include bMarks
dont-export
local balance LBALANCE
include : VBar (MIDDLE + balance) 0 CAP
include : LeftwardTopSerif (MIDDLE + balance) CAP (LONGJUT - balance)
@ -564,7 +552,6 @@ create-glyph 'r' : glyph-construction
define fovershoot : fallback para.fovershoot (O * 6)
create-glyph 'longs.upright' : glyph-construction
set-width WIDTH
dont-export
include bMarks
include : dispiro
widths.center
@ -586,7 +573,6 @@ define [LongSShape top bottom hookx hooky fine] : glyph-construction
create-glyph 'longs.italic' : glyph-construction
set-width WIDTH
dont-export
include ifMarks
include : LongSShape CAP (-HOOK) HOOKX HOOK

View File

@ -575,7 +575,7 @@ create-glyph 'zhuangtonesix' : glyph-construction
create-glyph 'zhuangToneFive' : glyph-construction
assign-unicode 0x1BC
include capitalMarks
include : FiveShape CAP 0.57
include : FiveShape CAP FIVEBARPOS
create-glyph 'zhuangtonefive' : glyph-construction
assign-unicode 0x1BD

View File

@ -105,20 +105,23 @@ create-glyph 'four' : glyph-construction
include : CenterBottomSerif (vert + HALFSTROKE * CORRECTION_HX) 0 JUT
define [FiveShape top bp] : glyph-construction
local ycurly : mix 0 (top * bp + HALFSTROKE) (SMOOTHA / (SMOOTHA + SMOOTHB))
local xleft : SB + TBALANCE * (0.6 - globalTransform.yx * 2)
local t1 : top * bp * 0.8
local t2 : top * bp
local ycurly : mix 0 t2 (SMOOTHA / (SMOOTHA + SMOOTHB))
local xleft : mix SB RIGHTSB 0.025
local xright : [mix RIGHTSB SB 0.05] - OXE
include : dispiro
widths.rhs
flat xleft (top * bp + HALFSTROKE) [heading RIGHTWARD]
curl ([mix SB RIGHTSB 0.4] - CORRECTION_OMIDS) (top * bp + HALFSTROKE)
g4 (xleft - OXHOOK) (t2 - AHOOK * top / CAP)
hookstart (t2 - O)
g4 (RIGHTSB - OX) ycurly
hookend O
g4 SB HOOK
include : VBarLeft xleft (top * bp + HALFSTROKE) top
include : HBarTop xleft (RIGHTSB - TBALANCE / 2) top
include : VBarLeft xleft (t2 - AHOOK * top / CAP) top
include : HBarTop xleft xright top
if SLAB : begin
include : DownwardRightSerif (RIGHTSB - TBALANCE / 2) top VJUT
include : DownwardRightSerif xright top VJUT
create-glyph 'five' : glyph-construction
include capitalMarks

View File

@ -118,8 +118,6 @@ create-glyph 'negate' : glyph-construction
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

View File

@ -77,7 +77,7 @@ create-glyph 'singleGuillemetLeft' : glyph-construction
include : dispiro
widths.center (sw * cor)
g4 [mix MIDDLE SB extension] [mix top bot 0.5] [heading RIGHTWARD]
quadcontrols 0.4 0.75
quadcontrols (1 - 0.4) (1 - 0.75)
g4 [mix MIDDLE RIGHTSB extension] bot [widths.center sw]
apply-transform : Translate (-(RIGHTSB - SB) * 0.05) 0

View File

@ -35,56 +35,56 @@ fdts-cc-slab : $(FILES) | $(OBJDIR)
# ttfs
fonts-default : fdts-default
@$(MAKE) -s -f onegroup.mk fonts $(PARAM_DEFAULT)
@$(MAKE) -f onegroup.mk fonts $(PARAM_DEFAULT)
fonts-slab : fdts-slab
@$(MAKE) -s -f onegroup.mk fonts $(PARAM_SLAB)
@$(MAKE) -f onegroup.mk fonts $(PARAM_SLAB)
fonts-cc : fdts-cc
@$(MAKE) -s -f onegroup.mk fonts $(PARAM_CC)
@$(MAKE) -f onegroup.mk fonts $(PARAM_CC)
fonts-cc-slab : fdts-cc-slab
@$(MAKE) -s -f onegroup.mk fonts $(PARAM_CC_SLAB)
@$(MAKE) -f onegroup.mk fonts $(PARAM_CC_SLAB)
### USED FOR TESTING AND RELEASING
### DO NOT TOUCH!
# testdrive
test-default : fonts-default
@$(MAKE) -s -f onegroup.mk test $(PARAM_DEFAULT)
@$(MAKE) -f onegroup.mk test $(PARAM_DEFAULT)
test-slab : fonts-slab
@$(MAKE) -s -f onegroup.mk test $(PARAM_SLAB)
@$(MAKE) -f onegroup.mk test $(PARAM_SLAB)
test-cc : fonts-cc
@$(MAKE) -s -f onegroup.mk test $(PARAM_CC)
@$(MAKE) -f onegroup.mk test $(PARAM_CC)
test-cc-slab : fonts-cc-slab
@$(MAKE) -s -f onegroup.mk test $(PARAM_CC_SLAB)
@$(MAKE) -f onegroup.mk test $(PARAM_CC_SLAB)
# Pages
pages-default : fonts-default
@$(MAKE) -s -f onegroup.mk pages $(PARAM_DEFAULT)
@$(MAKE) -f onegroup.mk pages $(PARAM_DEFAULT)
pages-slab : fonts-slab
@$(MAKE) -s -f onegroup.mk pages $(PARAM_SLAB)
@$(MAKE) -f onegroup.mk pages $(PARAM_SLAB)
pages-cc : fonts-cc
@$(MAKE) -s -f onegroup.mk pages $(PARAM_CC)
@$(MAKE) -f onegroup.mk pages $(PARAM_CC)
pages-cc-slab : fonts-cc-slab
@$(MAKE) -s -f onegroup.mk pages $(PARAM_CC_SLAB)
@$(MAKE) -f onegroup.mk pages $(PARAM_CC_SLAB)
# Release
release-default : fonts-default
@$(MAKE) -s -f onegroup.mk release $(PARAM_DEFAULT)
@$(MAKE) -f onegroup.mk release $(PARAM_DEFAULT)
release-slab : fonts-slab
@$(MAKE) -s -f onegroup.mk release $(PARAM_SLAB)
@$(MAKE) -f onegroup.mk release $(PARAM_SLAB)
release-cc : fonts-cc
@$(MAKE) -s -f onegroup.mk release $(PARAM_CC)
@$(MAKE) -f onegroup.mk release $(PARAM_CC)
release-cc-slab : fonts-cc-slab
@$(MAKE) -s -f onegroup.mk release $(PARAM_CC_SLAB)
@$(MAKE) -f onegroup.mk release $(PARAM_CC_SLAB)
# Archives
archives-default : fonts-default
@$(MAKE) -s -f onegroup.mk archives $(PARAM_DEFAULT)
@$(MAKE) -f onegroup.mk archives $(PARAM_DEFAULT)
archives-slab : fonts-slab
@$(MAKE) -s -f onegroup.mk archives $(PARAM_SLAB)
@$(MAKE) -f onegroup.mk archives $(PARAM_SLAB)
archives-cc : fonts-cc
@$(MAKE) -s -f onegroup.mk archives $(PARAM_CC)
@$(MAKE) -f onegroup.mk archives $(PARAM_CC)
archives-cc-slab : fonts-cc-slab
@$(MAKE) -s -f onegroup.mk archives $(PARAM_CC_SLAB)
@$(MAKE) -f onegroup.mk archives $(PARAM_CC_SLAB)
# Variant releases
releasepack-default : $(FILES) | $(OBJDIR)

View File

@ -13,13 +13,12 @@ FILES = $(SUPPORT_FILES) buildglyphs.js
ifeq ($(OS),Windows_NT)
SHELL = C:\\Windows\\System32\\cmd.exe
SUPPRESS_ERRORS = 2> NUL
NODE = node --noincremental_marking --max_executable_size=1024
else
SUPPRESS_ERRORS = 2> /dev/null
NODE = node
endif
NODE = node --max_old_space_size=4096
UPRIGHT = $(OBJDIR)/$(PREFIX)-regular.ttf $(OBJDIR)/$(PREFIX)-bold.ttf
ITALIC = $(OBJDIR)/$(PREFIX)-italic.ttf $(OBJDIR)/$(PREFIX)-bolditalic.ttf
TARGETS = $(UPRIGHT) $(ITALIC)

View File

@ -28,7 +28,7 @@ overlaypos = 0.52
ebarpos = 0.45
gbarpos = 0.42
pbarpos = 0.53
fivebarpos = 0.55
fivebarpos = 0.64
lllcrowdedness = 3.33333333