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

fix(web): fix handling of fonts with single quotes in filename 🍒 🏠 #13041

Merged
merged 4 commits into from
Jan 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions web/src/engine/dom-utils/src/stylesheets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,27 +133,31 @@ export class StylesheetManager {
}

// Build the font-face definition according to the browser being used
var s='@font-face {\nfont-family:'
+ fd.family + ';\nfont-style:normal;\nfont-weight:normal;\n';
// The OSK will similarly remove double-quotes from font-family names and double-quote
// the name itself. (#13018, #13022)
var s='@font-face {\nfont-family:"'
+ fd.family.replace(/\u0022/g, '') + '";\nfont-style:normal;\nfont-weight:normal;\n';

// Build the font source string according to the browser,
// but return without adding the style sheet if the required font type is unavailable

// Modern browsers: use WOFF, TTF and fallback finally to SVG. Don't provide EOT

// Note: encodeURI("'") == "'", but encodeURI('"') == "%22" (#13018, #13022)
if(os == DeviceSpec.OperatingSystem.iOS) {
if(ttf != '') {
if(this.doCacheBusting) {
ttf = this.cacheBust(ttf);
}
source = "url('"+encodeURI(ttf)+"') format('truetype')";
source = "url(\""+encodeURI(ttf)+"\") format('truetype')";
}
} else {
if(woff != '') {
source = "url('"+encodeURI(woff)+"') format('woff')";
source = "url(\""+encodeURI(woff)+"\"') format('woff')";
}

if(ttf != '') {
source = "url('"+encodeURI(ttf)+"') format('truetype')";
source = "url(\""+encodeURI(ttf)+"\") format('truetype')";
}
}

Expand Down
Loading