Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

データのurl変更に対応するために、gen-fontsのスクリプトを修正 #4158

Merged
merged 7 commits into from
Dec 2, 2023

Conversation

mehm8128
Copy link
Member

@mehm8128 mehm8128 commented Nov 18, 2023

npm run gen-fontsが失敗するようになっていたため、対応

確認事項としては、npm run gen-fonts実行時にpublic/fonts内にフォントが生成されていることと、プレビュー環境でフォントがちゃんと反映されていることが確認できれば多分大丈夫です

@mehm8128 mehm8128 self-assigned this Nov 18, 2023
Copy link

Copy link

codecov bot commented Nov 18, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (dcb6688) 86.35% compared to head (10e6a03) 86.35%.
Report is 5 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4158   +/-   ##
=======================================
  Coverage   86.35%   86.35%           
=======================================
  Files          66       66           
  Lines        4719     4719           
  Branches      564      564           
=======================================
  Hits         4075     4075           
  Misses        638      638           
  Partials        6        6           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@zer0-star zer0-star left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

フォントが生成されていること、新しいURLのフォントが適用されていることを確認しました
上のレビューで指摘されていること以外は良さそうです!

Copy link
Member

@ras0q ras0q left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

まだ動作確認はしてないですが https://fonts.googleapis.com/css2?family=M+PLUS+1p:wght@400;700&display=swap の中だけ見ました

  src: url(https://fonts.gstatic.com/s/mplus1p/v28/e3tmeuShHdiFyPFzBRrQRBEgfivGoOYmg_dUa_BuiDU9F33s7CtHVU4.119.woff2) format('woff2');

  src: url(https://fonts.gstatic.com/s/mplus1p/v28/e3tmeuShHdiFyPFzBRrQRBEQcUnXkvc.woff2) format('woff2');

の両方に対応したくてユニークであればいいなら/\/v\d+\/(.+)\.woff2$とか${family}.${weight}.${url.path}で十分じゃないかなって思いました
できるだけフォント名短くしたいとかなら沿わないけど

pathだと/が入ってだめか

@mehm8128
Copy link
Member Author

↑確かにそれで十分そうなので前者の方針でやってみました

@mehm8128
Copy link
Member Author

生成されたの見るとファイル名長くてちょっと無駄な気もするけど、ロジック簡単になる方がよさそうなのでこれでよさそうですね

Copy link
Member

@ras0q ras0q left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

結果として正規表現直すだけになったのでdiffがやや冗長だけど動作自体は問題ないのでdiff減らすのめんどくさかったらマージしちゃってください:+1:

@mehm8128
Copy link
Member Author

mehm8128 commented Dec 1, 2023

これ(.+)のところ/除外した方がいいですかね?

@mehm8128 mehm8128 requested a review from ras0q December 2, 2023 03:09
Copy link
Member

@ras0q ras0q left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

コメントしましたが意図してたらそのままマージしちゃってください

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/)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/v28/hoge/e3tmeuShHdiFyPFzBRrQRBEQcUnXkvc.woff2みたいなパスにはマッチさせないのは想定してますか?
末尾だけマッチさせるならこうかな

Suggested change
const fontSrcWithId = getUrlFromSrc(font.src).match(/\/v\d+\/([^/]+)\.woff2/)
const fontSrcWithId = getUrlFromSrc(font.src).match(/\/v\d+\/(?:[^/]*/)*([^/]+)\.woff2/)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

そうですね、今のところそれは考えなくていいかなと思っています
またエラー吐くようになったら変えるくらいでいいと思います

@mehm8128 mehm8128 merged commit 4c3688d into master Dec 2, 2023
11 checks passed
@mehm8128 mehm8128 deleted the fix/gen-mplus.js branch December 2, 2023 04:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants