@@ -111,17 +111,16 @@ function catchError(button, error) {
111
111
}
112
112
113
113
function makeCustomFont ( settings ) {
114
- // console.log("makeCustomFont")
115
-
116
114
const fontBaseURL = "/src/fonts/fontlab/"
117
115
const fontName = "CommitMono" + versionOfCommitMono
118
116
const fontWeight = settings . weight
119
117
const fontItalic = settings . italic ? "Italic" : "Regular"
120
118
const fontFilePath = `${ fontBaseURL } ${ fontName } -${ fontWeight } ${ fontItalic } .otf`
121
119
// "/src/fonts/fontlab/CommitMonoV132-400Italic.otf"
122
120
123
- return opentype
124
- . load ( fontFilePath )
121
+ return fetch ( fontFilePath )
122
+ . then ( file => file . arrayBuffer ( ) )
123
+ . then ( font => opentype . parse ( font ) )
125
124
. then ( ( font ) => {
126
125
// ######################
127
126
// #1 change alternates by switching their paths
@@ -265,18 +264,22 @@ function makeCustomFont(settings) {
265
264
// ######################
266
265
// #3 change the names
267
266
// 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
+ font . names . macintosh . fontFamily . en = `${ websiteData . fontName } `
268
+ font . names . macintosh . fontSubfamily . en = settings . style
269
+ font . names . macintosh . fullName . en = `${ websiteData . fontName } ${ settings . style } `
270
+ font . names . macintosh . postScriptName . en = `${ websiteData . fontName } -${ settings . style . split ( " " ) . join ( "" ) } `
271
+
272
+ font . names . windows . fontFamily . en = `${ websiteData . fontName } `
273
+ font . names . windows . fontSubfamily . en = settings . style
274
+ font . names . windows . fullName . en = `${ websiteData . fontName } ${ settings . style } `
275
+ font . names . windows . postScriptName . en = `${ websiteData . fontName } -${ settings . style . split ( " " ) . join ( "" ) } `
276
+ font . names . windows . uniqueID . en = `${ font . names . windows . version . en } ;;${ websiteData . fontName } -${ settings . style
275
277
. split ( " " )
276
278
. join ( "" ) } ;2023;FL820`
279
+ delete font . names . windows . preferredSubfamily
277
280
278
- font . tables . cff . topDict . familyName = font . names . fontFamily . en
279
- font . tables . cff . topDict . fullName = font . names . fullName . en
281
+ font . tables . cff . topDict . familyName = ` ${ websiteData . fontName } ` ;
282
+ font . tables . cff . topDict . fullName = ` ${ websiteData . fontName } ${ settings . style } `
280
283
font . tables . cff . topDict . weight = settings . weight == 700 ? "Bold" : "Regular"
281
284
282
285
// set correct mac style
@@ -292,8 +295,6 @@ function makeCustomFont(settings) {
292
295
// set the correct weight
293
296
font . tables . os2 . usWeightClass = settings . weight
294
297
295
- // console.log(font)
296
-
297
298
const fontAB = font . toArrayBuffer ( )
298
299
const fontBlob = new Blob ( [ fontAB ] , { type : "font/otf" } )
299
300
0 commit comments