[BpkStylesheets] Add locale-specific font-family overrides for non-Latin languages#4343
Conversation
There was a problem hiding this comment.
Pull request overview
Adds locale-aware font-family stack overrides to bpk-stylesheets so script-specific Noto fonts are preferred only when the relevant lang is present, reducing unnecessary downloads triggered by non-Latin glyphs on otherwise Latin pages.
Changes:
- Added
[lang]/:lang()overrides for additional non-Latin locales to set--bpk-base-font-stack(Skyscanner Relative) and--bpk-larken-font-stack(Larken). - Included new locale coverage for
zh-HK,zh-CN,ko-KR,th-TH,hi-IN,ar, andhe(plus existingja-JP,zh-TW). - Updated the font examples to apply
langattributes to non-Latin samples and added azh-HKsample.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
packages/bpk-stylesheets/font.scss |
Adds locale-specific overrides for the base font stack via CSS variables and lang selectors. |
packages/bpk-stylesheets/larken.scss |
Adds matching locale-specific overrides for the Larken/editorial font stack via CSS variables and lang selectors. |
examples/bpk-stylesheets-fonts/examples.tsx |
Updates Storybook/example rendering to include lang attributes for non-Latin samples and adds a zh-HK sample. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Visit https://backpack.github.io/storybook-prs/4343 to see this build running in a browser. |
1 similar comment
|
Visit https://backpack.github.io/storybook-prs/4343 to see this build running in a browser. |
Non-Latin font handling in backpack-foundationsThe global This reverts backpack-foundations #485 which added all Noto Sans/Serif fonts to the global Two-part fix (CLOV-1508):
This approach ensures non-Latin fonts are only downloaded when actually needed, bringing CloudFront costs back down from ~$650/day to ~$250/day. |
| 'Helvetica Neue', sans-serif; | ||
| } | ||
|
|
||
| [lang='el-GR'], |
There was a problem hiding this comment.
seems all font setting of 'el-GR' ru-RU vi-VN are same, are they expected? if so, could we merged them?
| 'Noto Serif Devanagari', 'Noto Serif Thai', sans-serif; | ||
| } | ||
|
|
||
| [lang='el-GR'], |
There was a problem hiding this comment.
|
Visit https://backpack.github.io/storybook-prs/4343 to see this build running in a browser. |
0cbf8f1 to
799fd55
Compare
…tin languages Add CSS lang-attribute overrides so non-Latin Noto fonts are only loaded when the page locale matches (e.g. lang="ja-JP", lang="ar"), preventing unnecessary font downloads on Latin-language pages that previously caused a ~2.5x increase in CloudFront data transfer costs. New locale overrides added for: zh-HK, zh-CN, ko-KR, th-TH, hi-IN, ar, he. Updated Storybook examples to include lang attributes for all non-Latin language samples to enable proper visual verification. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Type LANGUAGE_SAMPLES and remove `as any` casts for type-safe lang access - Reword font.scss comment to accurately describe selector behavior - Merge duplicate zh-TW/zh-HK selectors in both font.scss and larken.scss Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add font-family overrides for el-GR (Greek), ru-RU/uk-UA/bg-BG (Cyrillic), and vi-VN (Vietnamese) to match the fallback fonts documentation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
These locales share the same Noto Sans / Noto Serif font stack, so combine them into a single rule in both font.scss and larken.scss. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
799fd55 to
06d30c8
Compare
|
Visit https://backpack.github.io/storybook-prs/4343 to see this build running in a browser. |
Include the latest foundations release which reverts the global font-family change, so consumers get both fixes in a single upgrade. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
06d30c8 to
7a58fad
Compare
|
Visit https://backpack.github.io/storybook-prs/4343 to see this build running in a browser. |
Description
Adds CSS
[lang]attribute overrides for non-Latin locales so that Noto fonts are only downloaded when the page locale matches (e.g.lang="ja-JP",lang="ar").Design doc
Fallback Fonts — Backpack Design System
Problem
backpack-foundations PR #485 added all Noto Sans fonts to the global
font-familystack. This caused every page (including English) to download large CJK/non-Latin fonts whenever any non-Latin character appeared (e.g. language switcher), leading to:Solution
font-familyCSS variable overrides using[lang]/:lang()selectors, so non-Latin Noto fonts are only loaded on pages with the matching localeNew locale overrides added
ja-JPfont.scss,larken.scsszh-TW,zh-HKfont.scss,larken.scsszh-CNfont.scss,larken.scssko-KRfont.scss,larken.scssth-THfont.scss,larken.scsshi-INfont.scss,larken.scssarfont.scss,larken.scsshefont.scss,larken.scssel-GRfont.scss,larken.scssru-RU,uk-UA,bg-BGfont.scss,larken.scssvi-VNfont.scss,larken.scssAlso updated Storybook font examples to include
langattributes for all non-Latin language samples.Screenshots
lang = ja-JP
lang = ko-KR
Checklist
langattributes for all non-Latin samples