@@ -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,28 @@ 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
+
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
275
283
. split ( " " )
276
284
. join ( "" ) } ;2023;FL820`
285
+ delete font . names . windows . preferredFamily
277
286
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
280
289
font . tables . cff . topDict . weight = settings . weight == 700 ? "Bold" : "Regular"
281
290
282
291
// set correct mac style
@@ -292,8 +301,6 @@ function makeCustomFont(settings) {
292
301
// set the correct weight
293
302
font . tables . os2 . usWeightClass = settings . weight
294
303
295
- // console.log(font)
296
-
297
304
const fontAB = font . toArrayBuffer ( )
298
305
const fontBlob = new Blob ( [ fontAB ] , { type : "font/otf" } )
299
306
0 commit comments