|
| 1 | +$$include '../meta/macros.ptl' |
| 2 | + |
| 3 | +import [mix linreg clamp fallback boole boolePn] from "@iosevka/util" |
| 4 | +import [Transform] from "@iosevka/geometry/transform" |
| 5 | +import [Point] from "@iosevka/geometry/point" |
| 6 | +import [FunctionInterpolator AfCombine] from "@iosevka/geometry/spiro-control" |
| 7 | +import [RadicalGeometry StrokeGeometry RemoveHolesGeometry] from "@iosevka/geometry" |
| 8 | + |
| 9 | +glyph-module |
| 10 | + |
| 11 | +glyph-block Common-OShape-Variants : begin |
| 12 | + glyph-block-import CommonShapes |
| 13 | + glyph-block-import Common-Derivatives |
| 14 | + |
| 15 | + glyph-block-export OvalShapeT DiamondShapeT RoundRectShapeT |
| 16 | + define [OvalShapeT sink t b l r _sw _refAda _refAdb] : begin |
| 17 | + local m : mix l r 0.5 |
| 18 | + local sw : fallback _sw Stroke |
| 19 | + local refAda : fallback _refAda SmallArchDepthA |
| 20 | + local refAdb : fallback _refAdb SmallArchDepthB |
| 21 | + |
| 22 | + return : sink |
| 23 | + widths.rhs sw |
| 24 | + arch.rhs.centerAt.ltr.t m t (sw -- sw) |
| 25 | + archv |
| 26 | + g4 (r - OX) [YSmoothMidR t b refAda refAdb] |
| 27 | + arcvh |
| 28 | + arch.rhs.centerAt.rtl.b m b (sw -- sw) |
| 29 | + archv |
| 30 | + g4 (l + OX) [YSmoothMidL t b refAda refAdb] |
| 31 | + arcvh |
| 32 | + close |
| 33 | + |
| 34 | + define diamondFineRatio : [AdviceStroke 3] / [AdviceStroke 2] |
| 35 | + define [DiamondShapeT sink t b l r sw] : begin |
| 36 | + local body : fallback sw : AdviceStroke 2 |
| 37 | + local fine : diamondFineRatio * body |
| 38 | + local sw1 fine |
| 39 | + local sw2 : mix body fine 0.375 |
| 40 | + |
| 41 | + local mxb : arch.adjust-x.bot [mix (l - OX) (r + OX) 0.5] (sw -- fine) |
| 42 | + local mxt : arch.adjust-x.top [mix (l - OX) (r + OX) 0.5] (sw -- fine) |
| 43 | + local myl : YSmoothMidL t b |
| 44 | + local myr : YSmoothMidR t b |
| 45 | + |
| 46 | + local p1 : 0.45 + 0.8 * (fine / (r - l)) |
| 47 | + local p2 : 0.15 + 0.5 * (fine / (t - b)) |
| 48 | + local p3 : 0.35 + 0.8 * (body / (t - b)) |
| 49 | + local p4 : 0.15 + 0.0 * (body / (r - l)) |
| 50 | + |
| 51 | + local pcx 0.5 |
| 52 | + local pcy 0.1 |
| 53 | + |
| 54 | + return : sink |
| 55 | + g2.right.mid mxb (b + O) [widths.lhs fine] |
| 56 | + alsoThru.g2 pcx pcy |
| 57 | + flat [mix mxb r p1] [mix b myr p2] [widths.lhs sw1] |
| 58 | + curl [mix mxb r (1 - p4)] [mix b myr (1 - p3)] [widths.lhs sw2] |
| 59 | + g2.up.mid (r - OX) myr [widths.lhs body] |
| 60 | + flat [mix r mxt p4] [mix myr t p3] [widths.lhs sw2] |
| 61 | + curl [mix r mxt (1 - p1)] [mix myr t (1 - p2)] [widths.lhs sw1] |
| 62 | + alsoThru.g2 (1 - pcx) (1 - pcy) |
| 63 | + g2.left.mid mxt (t - O) [widths.lhs fine] |
| 64 | + alsoThru.g2 pcx pcy |
| 65 | + flat [mix mxt l p1] [mix t myl p2] [widths.lhs sw1] |
| 66 | + curl [mix mxt l (1 - p4)] [mix t myl (1 - p3)] [widths.lhs sw2] |
| 67 | + g2.down.mid (l + OX) myl [widths.lhs body] |
| 68 | + flat [mix l mxb p4] [mix myl b p3] [widths.lhs sw2] |
| 69 | + curl [mix l mxb (1 - p1)] [mix myl b (1 - p2)] [widths.lhs sw1] |
| 70 | + alsoThru.g2 (1 - pcx) (1 - pcy) |
| 71 | + close |
| 72 | + |
| 73 | + define [RoundRectShapeT sink u d l r _sw _cr] : begin |
| 74 | + local sw : fallback _sw Stroke |
| 75 | + local cr : fallback _cr : clamp ((r - l) / 5) ((r - l) / 2.5) : HSwToV sw |
| 76 | + local lMid : l + cr |
| 77 | + local rMid : r - cr |
| 78 | + local ada : ArchDepthAOf cr (r - l) |
| 79 | + local adb : ArchDepthBOf cr (r - l) |
| 80 | + |
| 81 | + return : sink |
| 82 | + widths.lhs sw |
| 83 | + arch.lhs.centerAt.rtl.t lMid u (sw -- sw) (knot-ty -- curl) |
| 84 | + archv |
| 85 | + flatside.ld l d u ada adb |
| 86 | + arcvh |
| 87 | + arch.lhs.centerAt.ltr.b lMid d (sw -- sw) (knot-ty -- flat) |
| 88 | + arch.lhs.centerAt.ltr.b rMid d (sw -- sw) (knot-ty -- curl) |
| 89 | + archv |
| 90 | + flatside.ru r d u ada adb |
| 91 | + arcvh |
| 92 | + arch.lhs.centerAt.rtl.t rMid u (sw -- sw) (knot-ty -- flat) |
| 93 | + close |
0 commit comments