-
Notifications
You must be signed in to change notification settings - Fork 68
fix: handle semicolon font fallback separators #1991
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -190,7 +190,15 @@ export function mapWordFamilyFallback(wordFamily) { | |
| */ | ||
| export function toCssFontFamily(fontName, options = {}) { | ||
| if (!fontName || typeof fontName !== 'string') return fontName; | ||
| const trimmed = fontName.trim(); | ||
| let trimmed = fontName.trim(); | ||
| // replace semicolon font fallback separators | ||
| if (trimmed.includes(';')) { | ||
| trimmed = trimmed | ||
| .split(';') | ||
| .map((part) => part.trim()) | ||
|
Comment on lines
+195
to
+198
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The new semicolon normalization splits on every Useful? React with 👍 / 👎.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mattConnHarbour check and add a response if applicable/or not |
||
| .filter(Boolean) | ||
| .join(', '); | ||
| } | ||
| if (!trimmed || trimmed.includes(',')) return trimmed; | ||
|
|
||
| const { fallback, wordFamily } = options; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
once semicolons become commas, the comma check on line 202 returns early -- no sans-serif fallback gets added.
works today because the import path already adds one, but if this function gets called with raw "Liberation Sans;Arial" it'll be missing a generic fallback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also.. needs tests for semicolon inputs -- the early return on line 202 skipping fallbacks is easy to miss without one.
toCssFontFamily("Liberation Sans;Arial")andtoCssFontFamily("Foo;Bar", { wordFamily: 'swiss' })would cover it.