Iosevka/font-src/glyphs/letter/latin/upper-r.ptl

275 lines
16 KiB
Text

$$include '../../../meta/macros.ptl'
import [mix linreg clamp fallback] from '../../../support/utils'
import [Dotless CvDecompose MathSansSerif] from "../../../support/gr"
glyph-module
glyph-block Letter-Latin-Upper-R : begin
glyph-block-import CommonShapes
glyph-block-import Common-Derivatives
glyph-block-import Letter-Latin-Upper-P : PShape RevPShape PBarPosY PRotundaShape BBPShape PShapeOutline
glyph-block-import Letter-Blackboard : BBS BBD
glyph-block-import Letter-Shared-Shapes : SerifFrame RightwardTailedBar
define LEG-SHAPE-CURLY 0
define LEG-SHAPE-STRAIGHT 1
define LEG-SHAPE-STANDING 2
define [RLegTerminalX legShape right sw] : right - [if legShape (OX * 2) 0] - sw / 2 * HVContrast
define [RSlabExtraShift slab sw] : if slab (-Jut / 2 + 0.25 * sw * HVContrast) 0
define [RLegDiagCor top bottom left right extraShift sw] : DiagCor (top - bottom) (right - left - extraShift) 0 sw
define [RStandingLegFine sw] : sw * CThinB
define [RStandingLegBend left right top bottom sw] : Math.min ((right - left) * 0.99) : Math.max (sw * 1.5) ((right - left) * 0.875)
define [RStandingBottomOverflow slab] : if slab 0 (2 * OX)
define [RLegShape-Straight] : params [top bottom left right charTop slab sw extraShift] : glyph-proc
local xRightBottom : RLegTerminalX LEG-SHAPE-STRAIGHT right sw
local shift : RSlabExtraShift slab sw
include : dispiro
widths.center (sw * [RLegDiagCor top bottom left right extraShift sw])
corner (left + extraShift + shift / 2) top [heading Downward]
corner (xRightBottom + shift) bottom [heading Downward]
if slab : begin
include : RightwardBottomSerif (xRightBottom + shift + 0.25 * sw * HVContrast) bottom (SideJut + Jut / 8)
define [RLegShape-Curly] : params [top bottom left right charTop slab sw extraShift] : glyph-proc
local xRightBottom : RLegTerminalX LEG-SHAPE-CURLY right sw
include : intersection
Rect top bottom (-Width) (2 * Width)
dispiro
widths.center sw
g4.up.start xRightBottom bottom [heading Upward]
quadControls 0 0.4 8
g4 left top
if slab : begin
include : RightwardBottomSerif right bottom (SideJut + Jut / 8)
define [RLegShape-Standing] : params [top bottom left right charTop slab sw extraShift] : glyph-proc
local fine : RStandingLegFine sw
local bend : RStandingLegBend left right top bottom sw
local ytopRef : begin top
local yTopStroke : top - sw / 2 + fine
local yOffset : mix bottom top 0.2
local xOverflow : RStandingBottomOverflow slab
include : dispiro
widths.rhs fine
flat left yTopStroke [heading Rightward]
curl (right - bend) yTopStroke [heading Rightward]
archv
flat (right + O) [Math.max (yOffset + 1) (ytopRef - bend * charTop / CAP)] [widths.rhs.heading sw Downward]
curl (right + O) yOffset [heading Downward]
curl (right + O - xOverflow) bottom [heading Downward]
if slab : include : RightwardBottomSerif right bottom SideJut
define RLegShapes { RLegShape-Curly RLegShape-Straight RLegShape-Standing }
define [RevRLegTerminalX legShape left sw] : left + [if legShape (OX * 2) 0] + sw / 2 * HVContrast
define [RevRLegShape-Straight] : params [top bottom left right charTop slab sw extraShift] : glyph-proc
local xLeftBottom : RevRLegTerminalX LEG-SHAPE-STRAIGHT left sw
local shift : RSlabExtraShift slab sw
include : dispiro
widths.center (sw * [RLegDiagCor top bottom left right extraShift sw])
corner (right - extraShift - shift / 2) top [heading Downward]
corner (xLeftBottom - shift) bottom [heading Downward]
if slab : begin
include : LeftwardBottomSerif (xLeftBottom - shift - 0.25 * sw * HVContrast) bottom (SideJut + Jut / 8)
define [RevRLegShape-Curly] : params [top bottom left right charTop slab sw extraShift] : glyph-proc
local xLeftBottom : RevRLegTerminalX LEG-SHAPE-CURLY left sw
include : intersection
Rect top 0 (-Width) (2 * Width)
dispiro
widths.center sw
g4.up.start xLeftBottom bottom [heading Upward]
quadControls 0 0.4 8
g4 right top
if slab : begin
include : LeftwardBottomSerif left bottom (SideJut + Jut / 8)
define [RevRLegShape-Standing] : params [top bottom left right charTop slab sw extraShift] : glyph-proc
local fine : RStandingLegFine sw
local bend : RStandingLegBend left right top bottom sw
local ytopRef : begin top
local yTopStroke : top - sw / 2 + fine
local yOffset : mix bottom top 0.2
local xOverflow : RStandingBottomOverflow slab
include : dispiro
widths.lhs fine
flat right yTopStroke [heading Leftward]
curl (left + bend) yTopStroke [heading Leftward]
archv
flat (left - O) [Math.max (yOffset + 1) (ytopRef - bend * charTop / CAP)] [widths.lhs.heading sw Downward]
curl (left - O) yOffset [heading Downward]
curl (left - O + xOverflow) bottom [heading Downward]
if slab : include : LeftwardBottomSerif left bottom SideJut
define RevRLegShapes { RevRLegShape-Curly RevRLegShape-Straight RevRLegShape-Standing }
define [RBarPos charTop slab] : begin PShape.BarPos
define [RLegTop charTop sw bp] : (sw / 2) + [PBarPosY charTop sw bp]
define [RShape] : params [legShape top bp [mul 1] [slab null]] : glyph-proc
include : PShape top (mul -- mul) (overshoot -- O) (slab -- slab) (bp -- bp)
local right : RightSB - O - [if SLAB (Jut / 8) 0]
include : RLegShapes.(legShape) [RLegTop top Stroke bp] 0 Middle right top (slab === PShape.SlabSymmetric) Stroke 0
define [RRotundaShape] : params [legShape top [mul 1] [pmRotunda 0] [endX Middle] [hook Hook] [pBar 1] [slab null]] : glyph-proc
local bp : pBar * [RBarPos top false]
local legTop : RLegTop top Stroke bp
local right (RightSB - O - [if SLAB (Jut / 8) 0])
local cor : RLegDiagCor legTop 0 endX right 0 Stroke
local endX1 : endX - [if legShape (HalfStroke * cor * HVContrast) HalfStroke] + [if legShape [RSlabExtraShift SLAB Stroke] 0]
include : PRotundaShape top (mul -- mul) (bp -- bp) (overshoot -- O) (slab -- false) (endX -- endX1) (hook -- hook)
include : RLegShapes.(legShape) legTop 0 endX right top (slab === PShape.SlabSymmetric) Stroke 0
define [RevRShape] : params [legShape top bp [slab null] [mul 1] [tailedShape false]] : glyph-proc
include : RevPShape top (mul -- mul) (overshoot -- O) (slab -- slab) (bp -- bp)
local left : SB + O + [if SLAB (Jut / 8) 0]
include : RevRLegShapes.(legShape) [RLegTop top Stroke bp] 0 left Middle top SLAB Stroke 0
if tailedShape : begin
eject-contour 'strokeR'
include : tagged 'strokeR' : RightwardTailedBar (Width - SB * mul) 0 top
define [ROverlayAnchor] : glyph-proc
set-base-anchor 'overlay'
SB + Stroke * HVContrast
PBarPosY CAP Stroke : RBarPos CAP SLAB
define RConfig : object
standing { LEG-SHAPE-STANDING [if SLAB PShape.SlabSymmetric] [if SLAB RevPShape.SlabSymmetric] false false }
straight { LEG-SHAPE-STRAIGHT [if SLAB PShape.SlabSymmetric] [if SLAB RevPShape.SlabSymmetric] false false }
curly { LEG-SHAPE-CURLY [if SLAB PShape.SlabSymmetric] [if SLAB RevPShape.SlabSymmetric] false false }
standingOpen { LEG-SHAPE-STANDING [if SLAB PShape.SlabSymmetric] [if SLAB RevPShape.SlabSymmetric] true false }
straightOpen { LEG-SHAPE-STRAIGHT [if SLAB PShape.SlabSymmetric] [if SLAB RevPShape.SlabSymmetric] true false }
curlyOpen { LEG-SHAPE-CURLY [if SLAB PShape.SlabSymmetric] [if SLAB RevPShape.SlabSymmetric] true false }
standingMotionSerifed { LEG-SHAPE-STANDING PShape.SlabMotion RevPShape.SlabMotion false false }
straightMotionSerifed { LEG-SHAPE-STRAIGHT PShape.SlabMotion RevPShape.SlabMotion false false }
curlyMotionSerifed { LEG-SHAPE-CURLY PShape.SlabMotion RevPShape.SlabMotion false false }
standingOpenMotionSerifed { LEG-SHAPE-STANDING PShape.SlabMotion RevPShape.SlabMotion true false }
straightOpenMotionSerifed { LEG-SHAPE-STRAIGHT PShape.SlabMotion RevPShape.SlabMotion true false }
curlyOpenMotionSerifed { LEG-SHAPE-CURLY PShape.SlabMotion RevPShape.SlabMotion true false }
standingSerifless { LEG-SHAPE-STANDING null null false false }
straightSerifless { LEG-SHAPE-STRAIGHT null null false false }
curlySerifless { LEG-SHAPE-CURLY null null false false }
standingOpenSerifless { LEG-SHAPE-STANDING null null true false }
straightOpenSerifless { LEG-SHAPE-STRAIGHT null null true false }
curlyOpenSerifless { LEG-SHAPE-CURLY null null true false }
standingSmallCyrl { LEG-SHAPE-STANDING PShape.SlabMotion [if SLAB : if para.isItalic RevPShape.SlabCyrlItalic RevPShape.SlabSymmetric] false false }
straightSmallCyrl { LEG-SHAPE-STRAIGHT PShape.SlabMotion [if SLAB : if para.isItalic RevPShape.SlabCyrlItalic RevPShape.SlabSymmetric] false false }
curlySmallCyrl { LEG-SHAPE-CURLY PShape.SlabMotion [if SLAB : if para.isItalic RevPShape.SlabCyrlItalic RevPShape.SlabSymmetric] false false }
standingOpenSmallCyrl { LEG-SHAPE-STANDING PShape.SlabMotion [if SLAB : if para.isItalic RevPShape.SlabCyrlItalic RevPShape.SlabSymmetric] true false }
straightOpenSmallCyrl { LEG-SHAPE-STRAIGHT PShape.SlabMotion [if SLAB : if para.isItalic RevPShape.SlabCyrlItalic RevPShape.SlabSymmetric] true false }
curlyOpenSmallCyrl { LEG-SHAPE-CURLY PShape.SlabMotion [if SLAB : if para.isItalic RevPShape.SlabCyrlItalic RevPShape.SlabSymmetric] true false }
standingTailed { LEG-SHAPE-STANDING PShape.SlabMotion [if (SLAB && !para.isItalic) RevPShape.SlabMotion] false true }
straightTailed { LEG-SHAPE-STRAIGHT PShape.SlabMotion [if (SLAB && !para.isItalic) RevPShape.SlabMotion] false true }
curlyTailed { LEG-SHAPE-CURLY PShape.SlabMotion [if (SLAB && !para.isItalic) RevPShape.SlabMotion] false true }
standingOpenTailed { LEG-SHAPE-STANDING PShape.SlabMotion [if (SLAB && !para.isItalic) RevPShape.SlabMotion] true true }
straightOpenTailed { LEG-SHAPE-STRAIGHT PShape.SlabMotion [if (SLAB && !para.isItalic) RevPShape.SlabMotion] true true }
curlyOpenTailed { LEG-SHAPE-CURLY PShape.SlabMotion [if (SLAB && !para.isItalic) RevPShape.SlabMotion] true true }
foreach { suffix { legShape slabs revSlabs fOpen fTailed } } [Object.entries RConfig] : begin
local fMotion : slabs === PShape.SlabMotion
local bpCap : RBarPos CAP (slabs === PShape.SlabSymmetric)
local bpXH : RBarPos XH (slabs === PShape.SlabSymmetric)
create-glyph "R.\(suffix)" : glyph-proc
include : MarkSet.capital
include : ROverlayAnchor
include : difference
RShape legShape CAP (slab -- slabs) (bp -- bpCap)
if fOpen [PShape.OpenGap CAP (mul -- 1) (bp -- bpCap)] [glyph-proc]
create-glyph "smcpR.\(suffix)" : glyph-proc
include : MarkSet.capital
include : ROverlayAnchor
include : difference
RShape legShape XH (slab -- slabs) (bp -- bpXH)
if fOpen [PShape.OpenGap XH (mul -- 1) (bp -- bpXH)] [glyph-proc]
if (!fMotion && !fOpen) : create-glyph "Rrotunda.\(suffix)" : glyph-proc
include : MarkSet.capital
include : RRotundaShape legShape CAP (hook -- Hook) (pBar -- 0.9) (slab -- slabs)
if (!fMotion && !fOpen) : create-glyph "rrotunda.\(suffix)" : glyph-proc
include : MarkSet.capital
include : RRotundaShape legShape XH (hook -- AHook) (pBar -- 0.9) (slab -- slabs)
create-glyph "cyrl/Ya.\(suffix)" : glyph-proc
include : MarkSet.capital
include : ROverlayAnchor
include : difference
RevRShape legShape CAP (slab -- revSlabs) (bp -- bpCap)
if fOpen [RevPShape.OpenGap CAP (mul -- 1) (bp -- bpCap)] [glyph-proc]
create-glyph "cyrl/ya.\(suffix)" : glyph-proc
include : MarkSet.e
include : ROverlayAnchor
include : difference
RevRShape legShape XH (slab -- revSlabs) (bp -- bpXH) (tailedShape -- fTailed)
if fOpen [RevPShape.OpenGap XH (mul -- 1) (bp -- bpXH)] [glyph-proc]
create-glyph "Yr.\(suffix)" : glyph-proc
include : MarkSet.if
local top : CAP * 0.85
local bp 0.45
local legTop : RLegTop top Stroke bp
local right (RightSB - O - [if SLAB (Jut / 8) 0])
include : VBarLeft SB (top - 1) CAP
include : difference
union
PShape top (mul -- 1) (bp -- bp) (slab -- slabs)
RLegShape-Straight legTop Descender Middle right (top - Descender) (slabs === PShape.SlabSymmetric) Stroke 0
if fOpen [PShape.OpenGap top (mul -- 1) (bp -- bp)] [glyph-proc]
create-glyph "currency/indianRupeeSign.\(suffix)" : glyph-proc
define bp : RBarPos CAP 0
include : intersection
Rect CAP 0 SB Width
WithTransform [Translate (-Width / 8) 0]
PShape CAP (bp -- bp) (withBar -- false)
local right : RightSB - O - [if legShape 0 (Width / 16)]
include : RLegShapes.(legShape) [RLegTop CAP Stroke bp] 0 (Width * 0.375) right CAP (slabs === PShape.SlabSymmetric) Stroke 0
define sw : AdviceStroke2 2 4 CAP
include : HBarTop SB RightSB CAP sw
include : HBar SB RightSB [mix CAP [PBarPosY CAP Stroke bp] 0.5] sw
select-variant 'R' 'R'
link-reduced-variant 'R/sansSerif' 'R' MathSansSerif
select-variant 'smcpR' 0x280 (follow -- 'R')
turned 'turnSmapR' 0x1D1A 'smcpR' Middle (XH / 2)
select-variant 'Rrotunda' 0xA75A
select-variant 'rrotunda' 0xA75B (follow -- 'Rrotunda')
select-variant 'cyrl/Ya' 0x42F
select-variant 'cyrl/ya' 0x44F
select-variant 'revSmcpR' 0x1D19 (shapeFrom -- 'cyrl/ya') (follow -- 'R')
turned 'invSmcpR' 0x281 'revSmcpR' Middle (XH / 2)
select-variant 'Yr' 0x1A6 (follow -- 'R')
select-variant 'currency/indianRupeeSign' 0x20B9 (follow -- 'Rrotunda')
derive-glyphs 'Rbar' 0x24C 'R' : lambda [src sel] : glyph-proc
include [refer-glyph src] AS_BASE ALSO_METRICS
include : HBar [mix 0 SB 0.3] (SB - O) ((CAP - Stroke) * [RBarPos CAP SLAB] + Stroke * 0.25)
create-glyph 'mathbb/R' 0x211D : glyph-proc
define [SingleLeg] : RLegShape-Straight ((CAP - BBS) * HBarPos) 0 Middle (RightSB - O) CAP false BBS (BBD / 2)
define terminalX : RLegTerminalX LEG-SHAPE-STRAIGHT (RightSB - O) BBS
include : MarkSet.capital
include : BBPShape (mul -- 1) (overshoot -- O)
include : difference
union
SingleLeg
new-glyph : glyph-proc
include : SingleLeg
include : Translate (0 - BBD) 0
HBarBottom (terminalX - BBD) (terminalX - BBS / 2) 0 BBS
PShapeOutline CAP (sw -- BBS) (mul -- 1) (overshoot -- O) (offset -- 1)