Refactor: Redraw lowercase d glyph

This commit is contained in:
2025-11-09 12:36:45 -08:00
parent 2c09fd51e2
commit d168e1a236

View File

@@ -1,61 +1,61 @@
const makeGlyph = (opentype, name, unicode, cmds, adv) => const makeGlyph=(opentype,name,unicode,cmds,adv)=>
new opentype.Glyph({ new opentype.Glyph({
name, name,
unicode, unicode,
advanceWidth: adv, advanceWidth:adv,
path: cmds(new opentype.Path()) path:cmds(new opentype.Path())
}); });
export const glyphD = (opentype, adv) => export const glyphD=(opentype,adv)=>
makeGlyph( makeGlyph(
opentype, opentype,
"D", "D",
"D".codePointAt(0), "D".codePointAt(0),
(p) => { p=>{
p.moveTo(100, 0); p.moveTo(100,0);
p.lineTo(100, 700); p.lineTo(100,700);
p.lineTo(320, 700); p.lineTo(320,700);
p.curveTo(480, 700, 580, 590, 580, 420); p.curveTo(480,700,580,590,580,420);
p.lineTo(580, 280); p.lineTo(580,280);
p.curveTo(580, 110, 480, 0, 320, 0); p.curveTo(580,110,480,0,320,0);
p.close(); p.close();
p.moveTo(160, 60); p.moveTo(160,60);
p.lineTo(320, 60); p.lineTo(320,60);
p.curveTo(450, 60, 520, 140, 520, 280); p.curveTo(450,60,520,140,520,280);
p.lineTo(520, 420); p.lineTo(520,420);
p.curveTo(520, 560, 450, 640, 320, 640); p.curveTo(520,560,450,640,320,640);
p.lineTo(160, 640); p.lineTo(160,640);
p.close(); p.close();
return p; return p;
}, },
adv adv
); );
export const glyphd = (opentype, adv) => export const glyphd=(opentype,adv)=>
makeGlyph( makeGlyph(
opentype, opentype,
"d", "d",
"d".codePointAt(0), "d".codePointAt(0),
(p) => { p=>{
p.moveTo(310, -10); const stemX=460;
p.curveTo(250, -10, 200, 10, 160, 40); const asc=720;
p.lineTo(160, 0); p.moveTo(300,-10);
p.lineTo(100, 0); p.curveTo(180,-10,90,80,90,240);
p.lineTo(100, 720); p.curveTo(90,400,180,490,300,490);
p.lineTo(160, 720); p.curveTo(380,490,440,460,480,410);
p.lineTo(160, 440); p.lineTo(480,asc);
p.curveTo(200, 470, 250, 490, 310, 490); p.lineTo(420,asc);
p.curveTo(430, 490, 520, 400, 520, 240); p.lineTo(420,450);
p.curveTo(520, 80, 430, -10, 310, -10); p.curveTo(390,480,350,490,300,490);
p.close(); p.curveTo(180,490,90,400,90,240);
p.moveTo(310, 50); p.curveTo(90,80,180,-10,300,-10);
p.curveTo(400, 50, 460, 110, 460, 240); p.curveTo(360,-10,410,10,450,40);
p.curveTo(460, 370, 400, 430, 310, 430); p.lineTo(450,0);
p.curveTo(220, 430, 160, 370, 160, 240); p.lineTo(510,0);
p.curveTo(160, 110, 220, 50, 310, 50); p.lineTo(510,410);
p.curveTo(510,260,430,50,300,50);
p.close(); p.close();
return p; return p;
}, },
adv adv
); );