From 3aeed07ed4d09a7086ece5d45519b363d077cab6 Mon Sep 17 00:00:00 2001 From: Matt Jennings Date: Sun, 17 Mar 2024 20:18:30 -0500 Subject: [PATCH] fix: incomplete types for options in ex.FontSource.toFont() (#2973) - Fixed incomplete types for font options in `ex.FontSource().toFont(options)` --- CHANGELOG.md | 1 + src/engine/Resources/Font.ts | 2 +- src/spec/FontSourceSpec.ts | 8 ++++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e81be4aec..e8b7dcc5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). ### Fixed +- Fixed incomplete types for font options in `ex.FontSource().toFont(options)` - Fixed issue with `ex.Loader` start button position when using CSS transforms - Fixed issue where adding scenes with the same name did not work when it was previously removed - Fixed issue when WebGL context lost occurs where there was no friendly output to the user diff --git a/src/engine/Resources/Font.ts b/src/engine/Resources/Font.ts index 546149dd2..88ef41c46 100644 --- a/src/engine/Resources/Font.ts +++ b/src/engine/Resources/Font.ts @@ -70,7 +70,7 @@ export class FontSource implements Loadable { * Build a font from this FontSource. * @param options {FontOptions} Override the font options */ - toFont(options?: FontOptions): Font { + toFont(options?: FontOptions & GraphicOptions & RasterOptions): Font { return new Font({ family: this.family, ...this._options, ...options }); } } diff --git a/src/spec/FontSourceSpec.ts b/src/spec/FontSourceSpec.ts index f7ff4cebf..694e31927 100644 --- a/src/spec/FontSourceSpec.ts +++ b/src/spec/FontSourceSpec.ts @@ -37,13 +37,15 @@ describe('A FontSource', () => { it('will use options from FontSource', async () => { const fontSource = new ex.FontSource('src/spec/fonts/Gorgeous Pixel.ttf', 'Gorgeous Pixel', { - size: 50 + size: 50, + color: ex.Color.Red }); await fontSource.load(); const font = fontSource.toFont(); expect(font.size).toBe(50); + expect(font.color.toString()).toBe(ex.Color.Red.toString()); }); it('will override options when converting to a Font', async () => { @@ -54,11 +56,13 @@ describe('A FontSource', () => { await fontSource.load(); const font = fontSource.toFont({ - size: 100 + size: 100, + color: ex.Color.Red }); expect(font.size).toBe(100); expect(font.opacity).toBe(0.5); + expect(font.color.toString()).toBe(ex.Color.Red.toString()); }); it('will resolve the font if already loaded', async () => {