Skip to content

Commit

Permalink
Wrap family in quotes
Browse files Browse the repository at this point in the history
Fixes fonts like "xyz 2"
  • Loading branch information
GarboMuffin committed Aug 15, 2023
1 parent 7c86a36 commit b5b986e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/engine/tw-font-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}));
}
Expand Down
24 changes: 12 additions & 12 deletions test/integration/tw_font_manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
]);
Expand All @@ -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
}
]);
Expand Down Expand Up @@ -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])
}
]);
Expand Down Expand Up @@ -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])
}
]);
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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()');
Expand Down Expand Up @@ -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');
Expand Down

0 comments on commit b5b986e

Please sign in to comment.