Skip to content

Commit

Permalink
Fix internal seams of variants of outlined letters U+1CCE6 and U+1CCEF (
Browse files Browse the repository at this point in the history
#2509). (#2512)

Closes #2509
  • Loading branch information
be5invis authored Sep 22, 2024
1 parent 9020684 commit ad42410
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 44 deletions.
1 change: 1 addition & 0 deletions changes/31.7.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* Fix internal seams of variants of outlined letters U+1CCE6 and U+1CCEF (#2509).
12 changes: 4 additions & 8 deletions packages/font-glyphs/src/letter/latin/upper-q.ptl
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ glyph-block Letter-Latin-Upper-Q : begin
define [QHorizontalTailedBody df top sw] : begin
define fine : mix ShoulderFine sw 0.125
return : dispiro
flat (df.middle - sw * TanSlope + O) (sw - fine) [widths.lhs fine]
curl [arch.adjust-x.bot df.middle fine] (sw - fine)
g4.right.mid [arch.adjust-x.bot df.middle fine] (sw - fine) [widths.lhs fine]
archv
flat df.rightSB ArchDepthA [widths.lhs sw]
curl df.rightSB (top - ArchDepthB)
arch.lhs top
flat df.leftSB (top - ArchDepthA)
curl df.leftSB ArchDepthB
arcvh
straight.right.end [arch.adjust-x.bot df.middle] 0
flat [arch.adjust-x.bot df.middle] 0
curl df.rightSB 0

define [QOpenSwashyBody df top] : glyph-proc
define fine : AdviceStroke 3.5
Expand Down Expand Up @@ -125,10 +125,6 @@ glyph-block Letter-Latin-Upper-Q : begin
VBar.m df.middle [mix Descender HalfStroke 1.75] 0 sw
VBar.m df.middle 0 TailDepth

define [QHorizontalTail df tio sw] : dispiro
flat [arch.adjust-x.bot df.middle] 0 [widths.lhs : AdviceStroke 3]
curl [mix df.rightSB df.width 0.5] 0

define detachedTailGap : Math.max (-0.25 * Descender) [AdviceStroke 12]
define yObliqueTailStart : 0 - detachedTailGap - Stroke * 0.875
define yObliqueTailEnd : [mix 0 Descender 0.75] - Stroke * 0.5
Expand Down Expand Up @@ -159,7 +155,7 @@ glyph-block Letter-Latin-Upper-Q : begin
crossing { QStdBody [AdviceStroke 4] QCrossing 'capital' 'e' }
crossingBaseline { QStdBody [AdviceStroke 4] QCrossingBaseline 'capital' 'e' }
verticalCrossing { QStdBody QInnerVertSw QVerticalCrossing 'capDesc' 'p' }
horizontalTailed { QHorizontalTailedBody [AdviceStroke 3] QHorizontalTail 'capital' 'e' }
horizontalTailed { QHorizontalTailedBody [AdviceStroke 3] no-shape 'capital' 'e' }
detachedTailed { QStdBody Stroke QDetachedTail 'capDesc' 'p' }
detachedBendTailed { QStdBody Stroke QDetachedBendTail 'capDesc' 'p' }
openSwash { QOpenSwashyBody Stroke QSwashyTail 'capDesc' 'p' }
Expand Down
46 changes: 24 additions & 22 deletions packages/font-glyphs/src/letter/latin/x.ptl
Original file line number Diff line number Diff line change
Expand Up @@ -13,41 +13,43 @@ glyph-block Letter-Latin-X : begin
glyph-block-import Letter-Shared-Shapes : CyrDescender PalatalHook

glyph-block-export HalfXStrand
define [HalfXStrand stb fSlab _leftx lefty rightx righty turn pStraight tension _sw] : glyph-proc
define [HalfXStrand stb fSlab _xOuter yOuter xCenter yCenter turn pStraight tension _sw _pConn] : glyph-proc
local sw : fallback _sw Stroke
local sbCor : if stb ([StrokeWidthBlend 1 6] * OX * ([Math.abs (lefty - righty)] / CAP)) 0
local leftx : _leftx + ([HSwToV : 0.5 * sw] + [Math.max (-SideJut) sbCor]) * [if (rightx > _leftx) 1 (-1)]
local sbCor : if stb ([StrokeWidthBlend 1 6] * OX * ([Math.abs (yOuter - yCenter)] / CAP)) 0
local xOuter : _xOuter + ([HSwToV : 0.5 * sw] + [Math.max (-SideJut) sbCor]) * [if (xCenter > _xOuter) 1 (-1)]

if stb : begin
local hst : (0.5 * sw) * [DiagCor (righty - lefty) (rightx - leftx) 0 0]
local hst : (0.5 * sw) * [DiagCor (yCenter - yOuter) (xCenter - xOuter) 0 0]
local hse : (0.5 * sw) * [Math.min 0.97 ([AdviceStroke 3] / Stroke)]
local leftx2 : _leftx + ([HSwToV hst] + [Math.max (-SideJut) sbCor]) * [if (rightx > _leftx) 1 (-1)]
local xOuterAdjusted : _xOuter + ([HSwToV hst] + [Math.max (-SideJut) sbCor]) * [if (xCenter > _xOuter) 1 (-1)]
include : dispiro
corner leftx2 lefty [widths.heading hst hst [if (lefty < righty) Upward Downward]]
corner rightx righty [widths.center : 2 * hse]
corner xOuterAdjusted yOuter [widths.heading hst hst [if (yOuter < yCenter) Upward Downward]]
corner xCenter yCenter [widths.center : 2 * hse]

: else : begin
local height : Math.abs (lefty - righty)
local height : Math.abs (yOuter - yCenter)
local slabClearance : if fSlab ((sw / Stroke) * [AdviceStroke2 2 3 height]) 0
local turnyleft : mix lefty righty [if fSlab [Math.max turn (slabClearance / height)] turn]
local cyleft : mix turnyleft righty tension
local straightxleft : mix leftx rightx pStraight
local straightyleft : mix cyleft righty pStraight
local turnyOuter : mix yOuter yCenter [if fSlab [Math.max turn (slabClearance / height)] turn]
local cyOuter : mix turnyOuter yCenter tension
local straightXOuter : mix xOuter xCenter pStraight
local straightYOuter : mix cyOuter yCenter pStraight
local xCenterAdj : mix xCenter xOuter [fallback _pConn 0]
local yCenterAdj : mix yCenter cyOuter [fallback _pConn 0]
include : dispiro
widths.center sw
flat leftx lefty [heading [if (lefty < righty) Upward Downward]]
curl leftx turnyleft [heading [if (lefty < righty) Upward Downward]]
quadControls 0 ((cyleft - turnyleft) / (straightyleft - turnyleft)) 24
flat straightxleft straightyleft
curl rightx righty
flat xOuter yOuter [heading [if (yOuter < yCenter) Upward Downward]]
curl xOuter turnyOuter [heading [if (yOuter < yCenter) Upward Downward]]
quadControls 0 ((cyOuter - turnyOuter) / (straightYOuter - turnyOuter)) 24
flat straightXOuter straightYOuter
curl xCenterAdj yCenterAdj

glyph-block-export XStrand
define [XStrand stb slab _leftx lefty _rightx righty turn pStraight tension _sw] : glyph-proc
local middlex : mix _leftx _rightx 0.5
local middley : mix lefty righty 0.5
define [XStrand stb slab xLeft yLeft xRight yRight turn pStraight tension _sw] : glyph-proc
local xMid : mix xLeft xRight 0.5
local yMid : mix yLeft yRight 0.5

include : HalfXStrand stb slab _leftx lefty middlex middley turn pStraight tension _sw
include : HalfXStrand stb slab _rightx righty middlex middley turn pStraight tension _sw
include : HalfXStrand stb slab xLeft yLeft xMid yMid turn pStraight tension _sw (-0.001)
include : HalfXStrand stb slab xRight yRight xMid yMid turn pStraight tension _sw (-0.001)

define [XChanceryStrand sign leftX leftY rightX rightY fHalf _sw] : begin
local sw : fallback _sw Stroke
Expand Down
15 changes: 2 additions & 13 deletions packages/font/src/cleanup/glyphs.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,8 @@ function regulateGlyphStore(cache, para, skew, glyphStore) {

function flattenSimpleGlyph(cache, para, skew, g) {
try {
let gSimplified;
const needsTransform = g.gizmo ? !Transform.isTranslate(g.gizmo) : skew != 0;
if (needsTransform) {
const tfBack = g.gizmo ? g.gizmo.inverse() : new Transform(1, -skew, 0, 1, 0, 0);
const tfForward = g.gizmo ? g.gizmo : new Transform(1, +skew, 0, 1, 0, 0);
gSimplified = Geom.TransformedGeometry.create(
tfForward,
new Geom.SimplifyGeometry(Geom.TransformedGeometry.create(tfBack, g.geometry)),
);
} else {
gSimplified = new Geom.SimplifyGeometry(g.geometry);
}

if (!g.gizmo) throw new TypeError("No gizmo");
const gSimplified = Geom.SimplifyGeometry.wrapWithGizmo(g.geometry, g.gizmo);
const cs = gSimplified.toContours({ cache });
g.clearGeometry();
g.includeContours(cs);
Expand Down
2 changes: 1 addition & 1 deletion packages/geometry-cache/src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import zlib from "zlib";
import * as CurveUtil from "@iosevka/geometry/curve-util";
import { encode, decode } from "@msgpack/msgpack";

const Edition = 45;
const Edition = 46;
const MAX_AGE = 16;
class GfEntry {
constructor(age, value) {
Expand Down
12 changes: 12 additions & 0 deletions packages/geometry/src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,18 @@ export class SimplifyGeometry extends CachedGeometry {
h.embed(this.m_geom);
h.endStruct();
}

static wrapWithGizmo(g, gizmo) {
const needsTransform = !Transform.isTranslate(gizmo);
if (needsTransform) {
return new TransformedGeometry(
gizmo,
new SimplifyGeometry(new TransformedGeometry(gizmo.inverse(), g)),
);
} else {
return new SimplifyGeometry(g);
}
}
}

// Utility functions
Expand Down

0 comments on commit ad42410

Please sign in to comment.