Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zigzag Shape fixes #2651

Merged
merged 6 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions changes/32.5.0.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
* Add variant selector for decorative angle brackets (U+276C...U+2771) (#2603, #2623).
* Refine shape of:
- ARMENIAN SMALL LETTER CA (`U+056E`).
- VERTICAL ZIGZAG LINE (`U+299A`).
- LEFT WIGGLY FENCE (`U+29D8`).
- RIGHT WIGGLY FENCE (`U+29D9`).
- LEFT DOUBLE WIGGLY FENCE (`U+29DA`).
- RIGHT DOUBLE WIGGLY FENCE (`U+29DB`).
- HORIZONTAL RESISTOR SEGMENT (`U+1CC09`).
- VERTICAL RESISTOR SEGMENT (`U+1CC0A`).
- HORIZONTAL ZIGZAG LINE (`U+1CEB0`).
* Optimize metrics for bowl of Cyrillic Lower Ef (`ф`) and Greek Small Letter Phi Symbol (`ϕ`).
39 changes: 39 additions & 0 deletions packages/font-glyphs/src/common/shapes.ptl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ $$include '../meta/macros.ptl'

import [mix linreg clamp fallback boole boolePn] from "@iosevka/util"
import [Transform] from "@iosevka/geometry/transform"
import [Point] from "@iosevka/geometry/point"
import [FunctionInterpolator AfCombine] from "@iosevka/geometry/spiro-control"
import [RadicalGeometry StrokeGeometry RemoveHolesGeometry] from "@iosevka/geometry"

Expand Down Expand Up @@ -797,3 +798,41 @@ glyph-block CommonShapes : begin
foreach { suffix { DrawAt kDotRadius overshoot } } [Object.entries DotVariants] : do
create-glyph "\(name).\(suffix)" : F DrawAt kDotRadius overshoot
select-variant name unicode (follow -- 'punctuationDot')

# Sharp Corner Interpolator
glyph-block-export TangentToNormal VectorDot
define [TangentToNormal offset contrast _tanSlope] : begin
local r : Math.hypot offset.x offset.y
return : new Point Point.Type.Corner
contrast * (-offset.y / r)
(offset.x + offset.y * [fallback _tanSlope TanSlope]) / r
define [VectorDot p1 p2] : p1.x * p2.x + p1.y * p2.y

define [SharpCornerImpl before after args] : begin
if [not (before.af && before.af.l !== undefined)] : throw : new Error "Unable to infer stroke information for previous knot"
if [not (after.af && after.af.l !== undefined)] : throw : new Error "Unable to infer stroke information for next knot"

local beforeT : new Point Point.Type.Corner (args.x - before.x) (args.y - before.y)
local afterT : new Point Point.Type.Corner (after.x - args.x) (after.y - args.y)

local beforeN : fallback before.af.d : TangentToNormal beforeT args.contrast [if args.upright 0]
local afterN : fallback after.af.d : TangentToNormal afterT args.contrast [if args.upright 0]

local beforeR : beforeN.addScale (-[VectorDot beforeN beforeT] / [VectorDot beforeT beforeT]) beforeT
local afterR : afterN.addScale (-[VectorDot afterN afterT ] / [VectorDot afterT afterT ]) afterT

local beforeD : afterT.scale ([VectorDot beforeR beforeR] / [VectorDot beforeR afterT ])
local afterD : beforeT.scale ([VectorDot afterR afterR ] / [VectorDot afterR beforeT])

local lOffset : [beforeD.scale before.af.l ].addScale after.af.l afterD
local rOffset : [beforeD.scale (-before.af.r)].addScale (-after.af.r) afterD

local midPoint : lOffset.mix rOffset 0.5
local refPoint : Point.translated midPoint args.x args.y

return : corner refPoint.x refPoint.y [widths.center.heading 1 { .x (lOffset.x - rOffset.x) .y (lOffset.y - rOffset.y) }]

glyph-block-export sharp-corner
define [sharp-corner] : with-params [x y [contrast HVContrast] [upright 0]] : begin
local args : object x y contrast upright
return : new FunctionInterpolator SharpCornerImpl args
16 changes: 5 additions & 11 deletions packages/font-glyphs/src/letter/armenian/ca.ptl
Original file line number Diff line number Diff line change
Expand Up @@ -41,25 +41,19 @@ glyph-block Letter-Armenian-Ca : begin

local x1 : mix df.leftSB df.rightSB 0.45
local x2 : mix df.leftSB df.rightSB 0.3
local xOffset : HSwToV : 0.5 * df.mvs
local y2 : mix XH Ascender 0.5
include : dispiro
widths.rhs df.mvs
flat (x1 + xOffset) Ascender [heading Downward]
curl (x2 + xOffset) y2 [heading Downward]

local x3 : mix df.leftSB df.rightSB 0.1
local x4 : mix df.leftSB df.rightSB 0.6

local rExt : Math.max df.rightSB : Math.min
x4 + [HSwToV : 1.5 * df.mvs] + jut
df.rightSB + jut - [HSwToV : 0.5 * df.mvs]

include : intersection [MaskBelowLine (x1 - xOffset) Ascender (x2 - xOffset) y2 100] : dispiro
widths.rhs df.mvs
flat (x3 + xOffset) Ascender
curl (x4 + xOffset) XH
flat (df.rightSB - OX) (XH - SmallArchDepthB)
include : dispiro
flat x1 Ascender [widths.center.heading df.mvs Downward]
sharp-corner x2 y2
curl x4 XH [widths.center df.mvs]
flat (df.rightSB - OX) (XH - SmallArchDepthB) [widths.rhs df.mvs]
curl (df.rightSB - OX) (0 + SmallArchDepthA)
arch.rhs 0 (sw -- df.mvs)
flat (df.leftSB + OX) (0 + SmallArchDepthB)
Expand Down
2 changes: 1 addition & 1 deletion packages/font-glyphs/src/meta/macros.ptl
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ define-macro glyph-block-import : syntax-rules
DiagCor NameUni PointingTo with-transform with-outlined remove-holes radicalize clear-geometry
clear-anchors ExtLineCenter ExtLineLhs ExtLineRhs DiagCorDs HCrossBar MaskAbove
MaskBelow MaskLeft MaskRight HalfRectTriangle MaskAboveLine MaskBelowLine
MaskLeftLine MaskRightLine DotVariants WithDotVariants]
MaskLeftLine MaskRightLine DotVariants WithDotVariants TangentToNormal VectorDot sharp-corner]

define vartiableFilter : if externEnv.$glyphBlockVariableUsage$
lambda [x] externEnv.$glyphBlockVariableUsage$.(x)
Expand Down
9 changes: 6 additions & 3 deletions packages/font-glyphs/src/symbol/math/geometry.ptl
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,12 @@ glyph-block Symbol-Math-Geometry : begin
straight.right.end right top

do 'Zigzags'
create-glyph 'vertZigzag' 0x299A : VZigzag Middle ParenBot ParenTop (radiusBox / 4) 9 0 GeometryStroke
create-glyph 'wigglyFenceLeft' 0x29D8 : VZigzag Middle ParenBot ParenTop (radiusBox / 4) 10 1 GeometryStroke
create-glyph 'wigglyFenceRight' 0x29D9 : VZigzag Middle ParenBot ParenTop (radiusBox / 4) 10 0 GeometryStroke
create-glyph 'vertZigzag' 0x299A : intersection [MaskAbove ParenBot] [MaskBelow ParenTop]
VZigzag.fromSide Middle ParenBot ParenTop (radiusBox / 4) 9 0 GeometryStroke
create-glyph 'wigglyFenceLeft' 0x29D8 : intersection [MaskAbove ParenBot] [MaskBelow ParenTop]
VZigzag.fromSide Middle ParenBot ParenTop (radiusBox / 4) 10 1 GeometryStroke
create-glyph 'wigglyFenceRight' 0x29D9 : intersection [MaskAbove ParenBot] [MaskBelow ParenTop]
VZigzag.fromSide Middle ParenBot ParenTop (radiusBox / 4) 10 0 GeometryStroke

define space : (rightBox - leftBox - [HSwToV GeometryStroke] * 2) / 3
create-glyph 'doubleWigglyFenceLeft' 0x29DA : glyph-proc
Expand Down
1 change: 1 addition & 0 deletions packages/font-glyphs/src/symbol/pictograph.ptl
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export : define [apply] : begin
run-glyph-module "./pictograph/faces.mjs"
run-glyph-module "./pictograph/flags.mjs"
run-glyph-module "./pictograph/game-sprite.mjs"
run-glyph-module "./pictograph/geometric.mjs"
run-glyph-module "./pictograph/heart.mjs"
run-glyph-module "./pictograph/hourglass.mjs"
run-glyph-module "./pictograph/i-ching.mjs"
Expand Down
88 changes: 1 addition & 87 deletions packages/font-glyphs/src/symbol/pictograph/game-sprite.ptl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ glyph-block Symbol-Pictograph-Game-Sprite : for-width-kinds WideWidth4
glyph-block-import Shared-Symbol-Shapes : TriangleShape
glyph-block-import Symbol-Pictograph-Stick-Figure : StickFigureKit WithD4Transform D4Transform
glyph-block-import Symbol-Geometric-Shared : GeometricDim
glyph-block-import Symbol-Mosaic-Block : HShade VShade

define top fontMetrics.os2.sTypoAscender
define bottom fontMetrics.os2.sTypoDescender
Expand Down Expand Up @@ -365,7 +364,7 @@ glyph-block Symbol-Pictograph-Game-Sprite : for-width-kinds WideWidth4
set scaffold.tipHeight : 1 / 4

define [RightRocket box] : glyph-proc
local rocketLeft : box.mixY (0.5 + scaffold.width / 2)
local rocketLeft : box.mixY (0.5 + scaffold.width / 2)
local rocketRight : box.mixY (0.5 - scaffold.width / 2)
local rocketBase : box.mixX scaffold.baseHeight
local rocketTip : box.mixX (1 - scaffold.tipHeight)
Expand Down Expand Up @@ -483,91 +482,6 @@ glyph-block Symbol-Pictograph-Game-Sprite : for-width-kinds WideWidth4
include : UpFrog squareBox : D4Transform midX 2 0


do "Square Spiral"
define directions : list
* {.dx 1 .dy 0 .heading Rightward}
* {.dx 0 .dy 1 .heading Upward}
* {.dx (-1) .dy 0 .heading Leftward}
* {.dx 0 .dy (-1) .heading Downward}

define spiralSw : AdviceStroke 4 : Math.sqrt (MosaicWidthScalar / 2)
define oneStep : Geom.Size / 4.5
define stepsPerTurn { 9 9 9 7 7 5 5 3 3 }
define [SquareSpiral startx starty startidx] : glyph-proc
local x1 startx
local y1 starty
foreach [idx : range 0 stepsPerTurn.length] : begin
local {.dx dx .dy dy .heading dir} directions.((startidx + idx) % 4)
local x2 : x1 + dx * oneStep * stepsPerTurn.(idx)
local y2 : y1 + dy * oneStep * stepsPerTurn.(idx)
include : dispiro
widths.lhs spiralSw
disable-contrast
flat x1 y1 [heading dir]
curl x2 y2 [heading dir]
set x1 x2
set y1 y2

create-glyph [MangleName "squareSpiralFromTopLeft"] [MangleUnicode 0x1CC7C] : glyph-proc
set-width MosaicWidth
include : SquareSpiral Geom.Left Geom.Top 3
create-glyph [MangleName "squareSpiralFromTopRight"] [MangleUnicode 0x1CC7D] : glyph-proc
set-width MosaicWidth
include : SquareSpiral Geom.Right Geom.Top 2
create-glyph [MangleName "squareSpiralFromBottomRight"] [MangleUnicode 0x1CC7E] : glyph-proc
set-width MosaicWidth
include : SquareSpiral Geom.Right Geom.Bot 1
create-glyph [MangleName "squareSpiralFromBottomLeft"] [MangleUnicode 0x1CC7F] : glyph-proc
set-width MosaicWidth
include : SquareSpiral Geom.Left Geom.Bot 0


do "Ladder"
create-glyph [MangleName "vertLadder"] [MangleUnicode 0x1CC84] : glyph-proc
set-width MosaicWidth
include : HShade 8 top bottom Geom.Left Geom.Right
include : VBar.l Geom.Left bottom top GeometryStroke
include : VBar.r Geom.Right bottom top GeometryStroke

create-glyph [MangleName "horiLadder"] [MangleUnicode 0x1CC85] : glyph-proc
set-width MosaicWidth
include : VShade (4 * MosaicWidthScalar) Geom.Top Geom.Bot left right
include : HBar.b left right Geom.Bot GeometryStroke
include : HBar.t left right Geom.Top GeometryStroke


do "Striped Triangles"
define stripes : 2 + 2 * MosaicWidthScalar
define coTop : mix Geom.Top Geom.Bot (0 - 1 / (2 * stripes))
define coBot : mix Geom.Top Geom.Bot (1 + 1 / (2 * stripes))
define coLeft : mix Geom.Left Geom.Right (0 - 1 / (2 * stripes))
define coRight : mix Geom.Left Geom.Right (1 + 1 / (2 * stripes))

create-glyph [MangleName "stripedTriangleLeft"] [MangleUnicode 0x1CC80] : glyph-proc
set-width MosaicWidth
include : intersection
refer-glyph : MangleName "blackTriangleLeft"
VShade stripes top bottom coLeft coRight

create-glyph [MangleName "stripedTriangleUp"] [MangleUnicode 0x1CC81] : glyph-proc
set-width MosaicWidth
include : intersection
refer-glyph : MangleName "blackTriangleUp"
HShade stripes coTop coBot left right

create-glyph [MangleName "stripedTriangleRight"] [MangleUnicode 0x1CC82] : glyph-proc
set-width MosaicWidth
include : intersection
refer-glyph : MangleName "blackTriangleRight"
VShade stripes top bottom coLeft coRight

create-glyph [MangleName "stripedTriangleDown"] [MangleUnicode 0x1CC83] : glyph-proc
set-width MosaicWidth
include : intersection
refer-glyph : MangleName "blackTriangleDown"
HShade stripes coTop coBot left right


do "Moon Lander"
define scaffold : object
set scaffold.tipSize 0.2
Expand Down
118 changes: 118 additions & 0 deletions packages/font-glyphs/src/symbol/pictograph/geometric.ptl
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
$$include '../../meta/macros.ptl'

import [mix linreg clamp fallback strokeOffset] from "@iosevka/util"
import [Box] from "@iosevka/geometry/box"
import [Transform] from "@iosevka/geometry/transform"

glyph-module

glyph-block Symbol-Pictograph-Geometric : for-width-kinds WideWidth4
glyph-block-import CommonShapes
glyph-block-import Common-Derivatives
glyph-block-import Symbol-Geometric-Shared : GeometricDim
glyph-block-import Symbol-Mosaic-Block : HShade VShade

define top fontMetrics.os2.sTypoAscender
define bottom fontMetrics.os2.sTypoDescender
define left 0
define right MosaicWidth

define midX : mix left right 0.5
define midY : mix top bottom 0.5

define Geom : GeometricDim MosaicUnitWidth MosaicWidth

do "Square Spiral"
define directions : list
* {.dx 1 .dy 0 .heading Rightward}
* {.dx 0 .dy 1 .heading Upward}
* {.dx (-1) .dy 0 .heading Leftward}
* {.dx 0 .dy (-1) .heading Downward}

define spiralSw : AdviceStroke 4 : Math.sqrt (MosaicWidthScalar / 2)
define oneStep : Geom.Size / 4.5
define stepsPerTurn { 9 9 9 7 7 5 5 3 3 }
define [SquareSpiral startx starty startidx] : glyph-proc
local x1 startx
local y1 starty
foreach [idx : range 0 stepsPerTurn.length] : begin
local {.dx dx .dy dy .heading dir} directions.((startidx + idx) % 4)
local x2 : x1 + dx * oneStep * stepsPerTurn.(idx)
local y2 : y1 + dy * oneStep * stepsPerTurn.(idx)
include : dispiro
widths.lhs spiralSw
disable-contrast
flat x1 y1 [heading dir]
curl x2 y2 [heading dir]
set x1 x2
set y1 y2

create-glyph [MangleName "squareSpiralFromTopLeft"] [MangleUnicode 0x1CC7C] : glyph-proc
set-width MosaicWidth
include : SquareSpiral Geom.Left Geom.Top 3
create-glyph [MangleName "squareSpiralFromTopRight"] [MangleUnicode 0x1CC7D] : glyph-proc
set-width MosaicWidth
include : SquareSpiral Geom.Right Geom.Top 2
create-glyph [MangleName "squareSpiralFromBottomRight"] [MangleUnicode 0x1CC7E] : glyph-proc
set-width MosaicWidth
include : SquareSpiral Geom.Right Geom.Bot 1
create-glyph [MangleName "squareSpiralFromBottomLeft"] [MangleUnicode 0x1CC7F] : glyph-proc
set-width MosaicWidth
include : SquareSpiral Geom.Left Geom.Bot 0

do "Ladder"
create-glyph [MangleName "vertLadder"] [MangleUnicode 0x1CC84] : glyph-proc
set-width MosaicWidth
include : HShade 8 top bottom Geom.Left Geom.Right
include : VBar.l Geom.Left bottom top GeometryStroke
include : VBar.r Geom.Right bottom top GeometryStroke

create-glyph [MangleName "horiLadder"] [MangleUnicode 0x1CC85] : glyph-proc
set-width MosaicWidth
include : VShade (4 * MosaicWidthScalar) Geom.Top Geom.Bot left right
include : HBar.b left right Geom.Bot GeometryStroke
include : HBar.t left right Geom.Top GeometryStroke


do "Striped Triangles"
define stripes : 2 + 2 * MosaicWidthScalar
define coTop : mix Geom.Top Geom.Bot (0 - 1 / (2 * stripes))
define coBot : mix Geom.Top Geom.Bot (1 + 1 / (2 * stripes))
define coLeft : mix Geom.Left Geom.Right (0 - 1 / (2 * stripes))
define coRight : mix Geom.Left Geom.Right (1 + 1 / (2 * stripes))

create-glyph [MangleName "stripedTriangleLeft"] [MangleUnicode 0x1CC80] : glyph-proc
set-width MosaicWidth
include : intersection
refer-glyph : MangleName "blackTriangleLeft"
VShade stripes top bottom coLeft coRight

create-glyph [MangleName "stripedTriangleUp"] [MangleUnicode 0x1CC81] : glyph-proc
set-width MosaicWidth
include : intersection
refer-glyph : MangleName "blackTriangleUp"
HShade stripes coTop coBot left right

create-glyph [MangleName "stripedTriangleRight"] [MangleUnicode 0x1CC82] : glyph-proc
set-width MosaicWidth
include : intersection
refer-glyph : MangleName "blackTriangleRight"
VShade stripes top bottom coLeft coRight

create-glyph [MangleName "stripedTriangleDown"] [MangleUnicode 0x1CC83] : glyph-proc
set-width MosaicWidth
include : intersection
refer-glyph : MangleName "blackTriangleDown"
HShade stripes coTop coBot left right

do "Horizontal Zigzag"
glyph-block-import Shared-Symbol-Shapes : HZigzag

create-glyph [MangleName 'horiZigzag'] [MangleUnicode 0x1CEB0] : glyph-proc
set-width Geom.Width
define left : SB * MosaicWidthScalar
define right : RightSB * MosaicWidthScalar
define amp : (OperTop - OperBot) / 8
define sgmts : 4 * MosaicWidthScalar + 1

include : HZigzag.fromSide Geom.MidY left right amp sgmts 1 GeometryStroke
Loading
Loading