Skip to content

Commit 501b67b

Browse files
Merge pull request #63 from StreakInTheSky/update-openscriptjs
Fix setting "post" table
2 parents d2f6207 + 44e0fe8 commit 501b67b

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

src/js/download_wizard.js

+22-15
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,16 @@ function catchError(button, error) {
111111
}
112112

113113
function makeCustomFont(settings) {
114-
// console.log("makeCustomFont")
115-
116114
const fontBaseURL = "/src/fonts/fontlab/"
117115
const fontName = "CommitMono" + versionOfCommitMono
118116
const fontWeight = settings.weight
119117
const fontItalic = settings.italic ? "Italic" : "Regular"
120118
const fontFilePath = `${fontBaseURL}${fontName}-${fontWeight}${fontItalic}.otf`
121119
// "/src/fonts/fontlab/CommitMonoV132-400Italic.otf"
122120

123-
return opentype
124-
.load(fontFilePath)
121+
return fetch(fontFilePath)
122+
.then(file=>file.arrayBuffer())
123+
.then(font=>opentype.parse(font))
125124
.then((font) => {
126125
// ######################
127126
// #1 change alternates by switching their paths
@@ -265,18 +264,28 @@ function makeCustomFont(settings) {
265264
// ######################
266265
// #3 change the names
267266
// give custom names to each member of the style group
268-
font.names.fontFamily.en = `${websiteData.fontName}`
269-
font.names.fontSubfamily.en = settings.style
270-
font.names.fullName.en = `${websiteData.fontName} ${settings.style}`
271-
font.names.postScriptName.en = `${websiteData.fontName}-${settings.style.split(" ").join("")}`
272-
delete font.names.preferredFamily
273-
delete font.names.preferredSubfamily
274-
font.names.uniqueID.en = `${font.names.version.en};;${websiteData.fontName}-${settings.style
267+
268+
const fontFamily = websiteData.fontName
269+
const fullName = `${websiteData.fontName} ${settings.style}`
270+
const postScriptName = `${websiteData.fontName}-${settings.style.split(" ").join("")}`
271+
272+
font.names.macintosh.fontFamily.en = fontFamily
273+
font.names.macintosh.fontSubfamily.en = settings.style
274+
font.names.macintosh.fullName.en = fullName
275+
font.names.macintosh.postScriptName.en = postScriptName
276+
font.names.macintosh.preferredSubfamily = font.names.windows.preferredSubfamily
277+
278+
font.names.windows.fontFamily.en = fontFamily
279+
font.names.windows.fontSubfamily.en = settings.style
280+
font.names.windows.fullName.en = fullName
281+
font.names.windows.postScriptName.en = postScriptName
282+
font.names.windows.uniqueID.en = `${font.names.windows.version.en};;${websiteData.fontName}-${settings.style
275283
.split(" ")
276284
.join("")};2023;FL820`
285+
delete font.names.windows.preferredFamily
277286

278-
font.tables.cff.topDict.familyName = font.names.fontFamily.en
279-
font.tables.cff.topDict.fullName = font.names.fullName.en
287+
font.tables.cff.topDict.familyName = fontFamily
288+
font.tables.cff.topDict.fullName = fullName
280289
font.tables.cff.topDict.weight = settings.weight == 700 ? "Bold" : "Regular"
281290

282291
// set correct mac style
@@ -292,8 +301,6 @@ function makeCustomFont(settings) {
292301
// set the correct weight
293302
font.tables.os2.usWeightClass = settings.weight
294303

295-
// console.log(font)
296-
297304
const fontAB = font.toArrayBuffer()
298305
const fontBlob = new Blob([fontAB], { type: "font/otf" })
299306

src/js/opentype.min.js

+4-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)