Skip to content

Commit

Permalink
Fix phonetic ligatures' shape. Now they are connected more closely (#488
Browse files Browse the repository at this point in the history
).
  • Loading branch information
be5invis committed Apr 11, 2020
1 parent 05b51f3 commit 5223954
Show file tree
Hide file tree
Showing 3 changed files with 126 additions and 26 deletions.
1 change: 1 addition & 0 deletions changes/3.0.0-z.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Fixed phonetic ligatures' shape. Now they are connected more closely (#488).
64 changes: 54 additions & 10 deletions glyphs/autobuild-transformed.ptl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
###### Automatic builds
$$include '../meta/macros.ptl'

import [linreg clamp fallback] from '../support/utils'
import [linreg clamp mix fallback] from '../support/utils'

glyph-module

Expand Down Expand Up @@ -517,18 +517,9 @@ glyph-block Autobuild-Transformed : begin
list 0x1CA 'N' 'J'
list 0x1CB 'N' 'j'
list 0x1CC 'n' 'j'
list 0x2A3 'd' 'z'
list 0x1F1 'D' 'Z'
list 0x1F2 'D' 'z'
list 0x1F3 'd' 'z'
list 0x2A4 'd' 'ezh'
list 0x2A5 'd' 'zcurlytail'
list 0x2A6 't' 's'
list 0x2A7 't' 'esh'
list 0x2A8 't' 'ccurlytail'
list 0x2A9 'f' 'eng'
list 0x2AA 'l' 's'
list 0x2AB 'l' 'z'
list 0x478 'O' 'y' 'if'
list 0x479 'o' 'y' 'p'
list 0x20A7 'P' 's'
Expand All @@ -542,6 +533,59 @@ glyph-block Autobuild-Transformed : begin
list 0x2103 'degree' 'C'
list 0x2109 'degree' 'F'

define [createPhoneticLigatures _shrink1 _shrink2 wadj1 wadj2 records] : begin
local pendingGlyphs1 : records.map : [record] => record.1
local pendingGlyphs2 : records.map : [record] => record.2
local shrink1 : clamp 0 1 _shrink1
local shrink2 : clamp 0 1 _shrink2
local kern : SB * shrink1 + SB * shrink2 + 0.5 * STROKE * [mix shrink1 shrink2 0.5] - OX * 2
local antiScale : (WIDTH * shrink1 + WIDTH * shrink2 - kern) / WIDTH
foreach [cycle : range 0 4] : begin
set kern : SB * shrink1 + SB * shrink2 + 0.5 * STROKE * [mix shrink1 shrink2 0.5] - OX * 2
local tmp-shrink1 : (shrink1 * WIDTH + kern * shrink1 / (shrink1 + shrink2)) / (WIDTH * shrink1 + WIDTH * shrink2 - kern) * antiScale
local tmp-shrink2 : (shrink2 * WIDTH + kern * shrink2 / (shrink1 + shrink2)) / (WIDTH * shrink1 + WIDTH * shrink2 - kern) * antiScale
set shrink1 : clamp 0 1 tmp-shrink1
set shrink2 : clamp 0 1 tmp-shrink2

console.log cycle kern shrink1 shrink2

local df1 : Thinner pendingGlyphs1 shrink1
local df2 : Thinner pendingGlyphs2 shrink2

foreach [{unicode c1 c2 desiredWidth} : items-of records] : begin
local glyphName "\(c1)_\(c2)"
if [query-glyph glyphName] : begin
local j 2
while [query-glyph (glyphName + j)] : inc j
set glyphName (glyphName + j)

sketch
local sumChildrenWidth : df1.(c1).advanceWidth * wadj1 + df2.(c2).advanceWidth * wadj2
local refW : sumChildrenWidth - kern
include df2.(c2)
include : Translate (df1.(c1).advanceWidth * wadj1 - kern) 0
include : intersection
Rect (CAP * 2) (DESCENDER * 2) (-WIDTH) (df1.(c1).advanceWidth * wadj1 - kern + df2.(c2).advanceWidth * wadj2 / 2)
glyph-construction : include df1.(c1)
# include : Translate (-df1.(c1).advanceWidth * (1 - wadj1) / 2) 0
include : Upright
include : Translate (-refW / 2) 0
include : Scale [clamp 0 1 ((WIDTH - SB * 1.25) / (WIDTH - SB * 2) * WIDTH / refW)] 1
include : Translate (WIDTH / 2) 0
include : Italify
save glyphName unicode

if [not recursive] : createPhoneticLigatures stdShrink stdShrink 1 1 : list
list 0x2A3 'd' 'z'
list 0x2A4 'd' 'ezh'
list 0x2A5 'd' 'zcurlytail'
list 0x2A6 't.phoneticLeft' 's.phoneticRight'
list 0x2A7 't.phoneticLeft.extended' 'esh'
list 0x2A8 't.phoneticLeft' 'ccurlytail'
list 0x2A9 'f.straight' 'eng'
list 0x2AA 'l.phoneticLeft' 's.phoneticRight'
list 0x2AB 'l.phoneticLeft' 'z'


define [createAccentedEquals crowd scale records] : begin
local pendingGlyphs : records.map : [record] => record.2
Expand Down
87 changes: 71 additions & 16 deletions glyphs/letters-unified-basic.ptl
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,21 @@ glyph-block LetterUnified-Basic : begin
set-anchor 'topright' BASE (df.middle + RIGHTSB - MIDDLE) CAP
save 'l.italic'

sketch # l.phoneticLeft
local df : DivFrame 1
set-width df.width
include df.markSet.b
define middle : SB + STROKE * HVCONTRAST
include : dispiro
widths.center
flat middle CAP [heading DOWNWARD]
curl middle HOOK
arcvh
flat (middle + HOOK - HALFSTROKE) HALFSTROKE
curl [Math.max RIGHTSB (middle + [Math.max HOOKX (LONGJUT * 1.05 * df.div)])] HALFSTROKE [heading RIGHTWARD]
set-anchor 'topright' BASE (df.middle + RIGHTSB - MIDDLE) CAP
save 'l.phoneticLeft'

sketch # l.tailed
local df : DivFrame para.diversityI
set-width df.width
Expand Down Expand Up @@ -4194,27 +4209,46 @@ glyph-block LetterUnified-Basic : begin
include MarkSet.b
include : SmallTShape CAP 0
save 't.standard'

define [TFlatShape df m ext] : glyph-construction
local crossLeft : mix 0 SB m
local crossRight : mix df.width df.rightSB m
local barleft : [mix crossLeft crossRight 0.42] - STROKE * 0.375 * HVCONTRAST
local tTurn : Math.max (HOOK * 0.9) (STROKE * 1.375) : Math.min HOOK (STROKE * 1.75)
include : union
dispiro
widths.rhs
flat (crossRight + ext) 0
curl [Math.min (barleft + tTurn) (crossRight - 1)] 0
archv
flat barleft tTurn
curl barleft CAP [heading UPWARD]
dispiro
widths.rhs
flat (crossLeft - HALFSTROKE * TANSLANT) XH
curl (crossRight - HALFSTROKE * TANSLANT) XH
set-anchor 'topright' BASE crossRight CAP

sketch # t.narrow
local df : DivFrame para.diversityF
set-width df.width
include df.markSet.b
local crossLeft : mix 0 SB (1 / 2)
local crossRight : mix df.width df.rightSB (1 / 2)
local barleft : [mix crossLeft crossRight 0.42] - STROKE * 0.375 * HVCONTRAST
local tTurn : Math.max (HOOK * 0.9) (STROKE * 1.375) : Math.min HOOK (STROKE * 1.75)
include : dispiro
widths.rhs
flat crossRight 0
curl [Math.min (barleft + tTurn) (crossRight - 1)] 0
archv
flat barleft tTurn
curl barleft CAP [heading UPWARD]
include : dispiro
widths.rhs
flat (crossLeft - HALFSTROKE * TANSLANT) XH
curl (crossRight - HALFSTROKE * TANSLANT) XH
set-anchor 'topright' BASE crossRight CAP
include : TFlatShape df 0.5 0
save 't.narrow'
sketch # t.phoneticLeft
local df : DivFrame 1
set-width df.width
include df.markSet.b
include : TFlatShape df 1 0
save 't.phoneticLeft'
sketch # t.phoneticLeft.extended
local df : DivFrame 1
set-width df.width
include df.markSet.b
include : intersection
TFlatShape df 1 WIDTH
Rect CAP 0 SB (MIDDLE + WIDTH)
save 't.phoneticLeft.extended'
sketch # t.cross
set-width WIDTH
include MarkSet.b
Expand Down Expand Up @@ -4317,6 +4351,22 @@ glyph-block LetterUnified-Basic : begin
hookend O (sw -- stroke) (swItalicAdj -- STROKE)
g4 (SB - OX / 4) SHOOK

define [sStrokePhoneticRight] : begin
define stroke : adviceBlackness2 2.875 2 XH
define ess : mix stroke (ESS * stroke / STROKE) 0.5
define strokeCoeff : linreg 18 0 126 1 stroke
define smooth : adviceSSmooth XH (-1) stroke
return : dispiro
widths.lhs stroke
g4 (RIGHTSB + OX / 4) (XH - SHOOK)
hookstart XO (sw -- stroke) (swItalicAdj -- STROKE)
g4 (SB + OX / 8) (XH - smooth)
SNeck stroke (slantCoeff -- -0.01)
g4 (RIGHTSB - OX / 8) (smooth) [widths 0 stroke]
arcvh
flat (MIDDLE - CORRECTION_OMIDS) 0 [widths 0 STROKE]
curl SB 0

define [RevsStroke] : begin
define stroke : adviceBlackness2 2.875 2 XH
define ess : ESS * stroke / STROKE
Expand Down Expand Up @@ -4344,6 +4394,11 @@ glyph-block LetterUnified-Basic : begin
save 's' 's'
save 'cyrdze' 0x455

sketch # s
include MarkSet.e
include : sStrokePhoneticRight
save 's.phoneticRight'

sketch # revS
include MarkSet.capital
include : RevSStroke
Expand Down

0 comments on commit 5223954

Please sign in to comment.