From b5b986e3de56663d8c9e03618b1584a8611cd476 Mon Sep 17 00:00:00 2001 From: Muffin Date: Tue, 15 Aug 2023 18:34:12 -0500 Subject: [PATCH] Wrap family in quotes Fixes fonts like "xyz 2" --- src/engine/tw-font-manager.js | 2 +- test/integration/tw_font_manager.js | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/engine/tw-font-manager.js b/src/engine/tw-font-manager.js index 11a3e81a8a1..8bf433a3690 100644 --- a/src/engine/tw-font-manager.js +++ b/src/engine/tw-font-manager.js @@ -110,7 +110,7 @@ class FontManager extends EventEmitter { return this.fonts.map(font => ({ system: font.system, name: font.family, - family: `${font.family}, ${font.fallback}`, + family: `"${font.family}", ${font.fallback}`, data: font.asset ? font.asset.data : null })); } diff --git a/test/integration/tw_font_manager.js b/test/integration/tw_font_manager.js index cdf2205d60a..39d0e777e1e 100644 --- a/test/integration/tw_font_manager.js +++ b/test/integration/tw_font_manager.js @@ -62,7 +62,7 @@ test('system font', t => { { system: true, name: 'Noto Sans Mono', - family: 'Noto Sans Mono, monospace', + family: '"Noto Sans Mono", monospace', data: null } ]); @@ -83,13 +83,13 @@ test('system font', t => { { system: true, name: 'Noto Sans Mono', - family: 'Noto Sans Mono, monospace', + family: '"Noto Sans Mono", monospace', data: null }, { system: true, name: 'Lobster', - family: 'Lobster, fantasy, sans-serif', + family: '"Lobster", fantasy, sans-serif', data: null } ]); @@ -180,7 +180,7 @@ test('custom fonts', t => { { system: false, name: 'Arial', - family: 'Arial, sans-serif', + family: '"Arial", sans-serif', data: new Uint8Array([1, 2, 3]) } ]); @@ -219,13 +219,13 @@ test('custom fonts', t => { { system: false, name: 'Arial', - family: 'Arial, sans-serif', + family: '"Arial", sans-serif', data: new Uint8Array([1, 2, 3]) }, { system: false, name: 'Comic Sans MS', - family: 'Comic Sans MS, serif', + family: '"Comic Sans MS", serif', data: new Uint8Array([4, 5, 6]) } ]); @@ -306,7 +306,7 @@ test('deleteFont', t => { { system: true, name: 'Liberation Mono', - family: 'Liberation Mono, monospace', + family: '"Liberation Mono", monospace', data: null } ], 'updated getFonts() after deleting'); @@ -414,13 +414,13 @@ test('serialization and deserialization roundtrip - project', t => { { system: true, name: 'Ubuntu Mono', - family: 'Ubuntu Mono, monospace', + family: '"Ubuntu Mono", monospace', data: null }, { system: false, name: 'Inter', - family: 'Inter, sans-serif', + family: '"Inter", sans-serif', data: new Uint8Array([20, 21, 22, 23, 24]) } ], 'preserved in getFonts()'); @@ -502,19 +502,19 @@ test('serialization and deserialization roundtrip - target', t => { { system: true, name: 'Liberation Sans', - family: 'Liberation Sans, sans-serif', + family: '"Liberation Sans", sans-serif', data: null }, { system: true, name: 'FreeSans', - family: 'FreeSans, monospace', + family: '"FreeSans", monospace', data: null }, { system: false, name: 'Noto Sans Traditional Chinese', - family: 'Noto Sans Traditional Chinese, sans-serif', + family: '"Noto Sans Traditional Chinese", sans-serif', data: new Uint8Array([97, 98, 99]) } ], 'imported fonts from sprite');