Skip to content

Commit

Permalink
Merge pull request #4158 from traPtitech/fix/gen-mplus.js
Browse files Browse the repository at this point in the history
データのurl変更に対応するために、gen-fontsのスクリプトを修正
  • Loading branch information
mehm8128 authored Dec 2, 2023
2 parents 972dd4c + 10e6a03 commit 4c3688d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions build/gen-mplus.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,14 @@ const getUrlFromSrc = src => {
}

const generateFilename = font => {
const i = getUrlFromSrc(font.src).match(/\/v\d+\/[^.]+\.(\d+)\.woff2/)
if (!i) throw new Error(`Unexpected: ${getUrlFromSrc(font.src)}`)
const family = font['font-family'].replace(/[' ]/g, '')
const weight = font['font-weight'].replace(/[' ]/g, '')
return `${family}.${weight}.${i[1]}.woff2`

const fontSrcWithId = getUrlFromSrc(font.src).match(/\/v\d+\/([^/]+)\.woff2/)
if (!fontSrcWithId) {
throw new Error(`Unexpected URL: ${getUrlFromSrc(font.src)}`)
}
return `${family}.${weight}.${fontSrcWithId[1]}.woff2`
}

const downloadAndtransform = async (url, filename) => {
Expand Down

0 comments on commit 4c3688d

Please sign in to comment.