mirror of
https://github.com/multipleof4/stain.otf.git
synced 2026-01-14 00:27:55 +00:00
Feat: Add basic author metadata to font
This commit is contained in:
@@ -29,103 +29,106 @@ import { glyphX, glyphx } from "../src/glyphs/X.js";
|
|||||||
import { glyphY, glypthy as glyphy } from "../src/glyphs/Y.js";
|
import { glyphY, glypthy as glyphy } from "../src/glyphs/Y.js";
|
||||||
import { glyphZ, glyphz } from "../src/glyphs/Z.js";
|
import { glyphZ, glyphz } from "../src/glyphs/Z.js";
|
||||||
|
|
||||||
const __filename = fileURLToPath(import.meta.url);
|
const __filename=fileURLToPath(import.meta.url);
|
||||||
const __dirname = path.dirname(__filename);
|
const __dirname=path.dirname(__filename);
|
||||||
|
|
||||||
const outDir = path.join(__dirname, "..", "dist");
|
const outDir=path.join(__dirname,"..","dist");
|
||||||
if (!fs.existsSync(outDir)) fs.mkdirSync(outDir, { recursive: true });
|
if(!fs.existsSync(outDir))fs.mkdirSync(outDir,{recursive:true});
|
||||||
|
|
||||||
const familyName = "Stain";
|
const familyName="Stain";
|
||||||
const unitsPerEm = 1000;
|
const styleName="Regular";
|
||||||
const ascender = 800;
|
const unitsPerEm=1000;
|
||||||
const descender = -200;
|
const ascender=800;
|
||||||
const defaultAdv = 600;
|
const descender=-200;
|
||||||
|
const defaultAdv=600;
|
||||||
|
|
||||||
const mkGlyph = (name, unicode, adv, pathFn) =>
|
const mkGlyph=(name,unicode,adv,pathFn)=>
|
||||||
new opentype.Glyph({
|
new opentype.Glyph({
|
||||||
name,
|
name,
|
||||||
unicode,
|
unicode,
|
||||||
advanceWidth: adv,
|
advanceWidth:adv,
|
||||||
path: pathFn(new opentype.Path())
|
path:pathFn(new opentype.Path())
|
||||||
});
|
});
|
||||||
|
|
||||||
const glyphSpace = mkGlyph("space", " ".codePointAt(0), 260, (p) => p);
|
const glyphSpace=mkGlyph("space"," ".codePointAt(0),260,p=>p);
|
||||||
const glyphPeriod = mkGlyph("period", ".".codePointAt(0), 260, (p) => {
|
const glyphPeriod=mkGlyph("period","."
|
||||||
p.moveTo(80, 0);
|
.codePointAt(0),260,p=>{
|
||||||
p.lineTo(80, 120);
|
p.moveTo(80,0);
|
||||||
p.lineTo(180, 120);
|
p.lineTo(80,120);
|
||||||
p.lineTo(180, 0);
|
p.lineTo(180,120);
|
||||||
|
p.lineTo(180,0);
|
||||||
p.close();
|
p.close();
|
||||||
return p;
|
return p;
|
||||||
});
|
});
|
||||||
|
|
||||||
const glyphList = [
|
const glyphList=[
|
||||||
glyphSpace,
|
glyphSpace,
|
||||||
glyphPeriod,
|
glyphPeriod,
|
||||||
glyphA(opentype, defaultAdv),
|
glyphA(opentype,defaultAdv),
|
||||||
glypha(opentype, defaultAdv),
|
glypha(opentype,defaultAdv),
|
||||||
glyphB(opentype, defaultAdv),
|
glyphB(opentype,defaultAdv),
|
||||||
glyphb(opentype, defaultAdv),
|
glyphb(opentype,defaultAdv),
|
||||||
glyphC(opentype, defaultAdv),
|
glyphC(opentype,defaultAdv),
|
||||||
glyphc(opentype, defaultAdv),
|
glyphc(opentype,defaultAdv),
|
||||||
glyphD(opentype, defaultAdv),
|
glyphD(opentype,defaultAdv),
|
||||||
glyphd(opentype, defaultAdv),
|
glyphd(opentype,defaultAdv),
|
||||||
glyphE(opentype, defaultAdv),
|
glyphE(opentype,defaultAdv),
|
||||||
glyphe(opentype, defaultAdv),
|
glyphe(opentype,defaultAdv),
|
||||||
glyphF(opentype, defaultAdv),
|
glyphF(opentype,defaultAdv),
|
||||||
glyphf(opentype, defaultAdv),
|
glyphf(opentype,defaultAdv),
|
||||||
glyphG(opentype, defaultAdv),
|
glyphG(opentype,defaultAdv),
|
||||||
glyphg(opentype, defaultAdv),
|
glyphg(opentype,defaultAdv),
|
||||||
glyphH(opentype, defaultAdv),
|
glyphH(opentype,defaultAdv),
|
||||||
glyphh(opentype, defaultAdv),
|
glyphh(opentype,defaultAdv),
|
||||||
glyphI(opentype, defaultAdv),
|
glyphI(opentype,defaultAdv),
|
||||||
glyphi(opentype, defaultAdv),
|
glyphi(opentype,defaultAdv),
|
||||||
glyphJ(opentype, defaultAdv),
|
glyphJ(opentype,defaultAdv),
|
||||||
glyphj(opentype, defaultAdv),
|
glyphj(opentype,defaultAdv),
|
||||||
glyphK(opentype, defaultAdv),
|
glyphK(opentype,defaultAdv),
|
||||||
glyphk(opentype, defaultAdv),
|
glyphk(opentype,defaultAdv),
|
||||||
glyphL(opentype, defaultAdv),
|
glyphL(opentype,defaultAdv),
|
||||||
glyphl(opentype, defaultAdv),
|
glyphl(opentype,defaultAdv),
|
||||||
glyphM(opentype, 740),
|
glyphM(opentype,740),
|
||||||
glyphm(opentype, 740),
|
glyphm(opentype,740),
|
||||||
glyphN(opentype, defaultAdv),
|
glyphN(opentype,defaultAdv),
|
||||||
glyphn(opentype, defaultAdv),
|
glyphn(opentype,defaultAdv),
|
||||||
glyphO(opentype, defaultAdv),
|
glyphO(opentype,defaultAdv),
|
||||||
glypho(opentype, defaultAdv),
|
glypho(opentype,defaultAdv),
|
||||||
glyphP(opentype, defaultAdv),
|
glyphP(opentype,defaultAdv),
|
||||||
glyphp(opentype, defaultAdv),
|
glyphp(opentype,defaultAdv),
|
||||||
glyphQ(opentype, defaultAdv),
|
glyphQ(opentype,defaultAdv),
|
||||||
glyphq(opentype, defaultAdv),
|
glyphq(opentype,defaultAdv),
|
||||||
glyphR(opentype, defaultAdv),
|
glyphR(opentype,defaultAdv),
|
||||||
glyphr(opentype, defaultAdv),
|
glyphr(opentype,defaultAdv),
|
||||||
glyphS(opentype, defaultAdv),
|
glyphS(opentype,defaultAdv),
|
||||||
glyphsLowerS(opentype, defaultAdv),
|
glyphsLowerS(opentype,defaultAdv),
|
||||||
glyphT(opentype, defaultAdv),
|
glyphT(opentype,defaultAdv),
|
||||||
glypht(opentype, defaultAdv),
|
glypht(opentype,defaultAdv),
|
||||||
glyphU(opentype, defaultAdv),
|
glyphU(opentype,defaultAdv),
|
||||||
glyphu(opentype, defaultAdv),
|
glyphu(opentype,defaultAdv),
|
||||||
glyphV(opentype, defaultAdv),
|
glyphV(opentype,defaultAdv),
|
||||||
glyphv(opentype, defaultAdv),
|
glyphv(opentype,defaultAdv),
|
||||||
glyphW(opentype, 760),
|
glyphW(opentype,760),
|
||||||
glyphw(opentype, 660),
|
glyphw(opentype,660),
|
||||||
glyphX(opentype, defaultAdv),
|
glyphX(opentype,defaultAdv),
|
||||||
glyphx(opentype, defaultAdv),
|
glyphx(opentype,defaultAdv),
|
||||||
glyphY(opentype, defaultAdv),
|
glyphY(opentype,defaultAdv),
|
||||||
glyphy(opentype, defaultAdv),
|
glyphy(opentype,defaultAdv),
|
||||||
glyphZ(opentype, defaultAdv),
|
glyphZ(opentype,defaultAdv),
|
||||||
glyphz(opentype, defaultAdv)
|
glyphz(opentype,defaultAdv)
|
||||||
];
|
];
|
||||||
|
|
||||||
const font = new opentype.Font({
|
const font=new opentype.Font({
|
||||||
familyName,
|
familyName,
|
||||||
styleName: "Regular",
|
styleName,
|
||||||
unitsPerEm,
|
unitsPerEm,
|
||||||
ascender,
|
ascender,
|
||||||
descender,
|
descender,
|
||||||
glyphs: glyphList
|
glyphs:glyphList,
|
||||||
|
copyright:"Author: Anon"
|
||||||
});
|
});
|
||||||
|
|
||||||
const buf = Buffer.from(font.toArrayBuffer());
|
const buf=Buffer.from(font.toArrayBuffer());
|
||||||
const outPath = path.join(outDir, "Stain.otf");
|
const outPath=path.join(outDir,"Stain.otf");
|
||||||
fs.writeFileSync(outPath, buf);
|
fs.writeFileSync(outPath,buf);
|
||||||
console.log(`Built ${outPath}`);
|
console.log(`Built ${outPath}`);
|
||||||
|
|||||||
Reference in New Issue
Block a user