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

Bug: Error occurs when uninstalling a bitmap font with characters containing a space #10474

Open
azotov-box opened this issue Apr 25, 2024 · 0 comments
Assignees
Labels
🕷 Bug Verified that it’s actually a legit bug that exists in the current release.

Comments

@azotov-box
Copy link
Contributor

Current Behavior

When uninstalling a bitmap font with characters containing a space it throws an error:

BitmapFontManager › should uninstall and remove from Cache

        TypeError: Cannot read properties of undefined (reading 'destroy')

          192 |         for (const i in this.chars)
          193 |         {
        > 194 |             this.chars[i].texture.destroy();
              |                                   ^
          195 |         }
          196 |
          197 |         (this.chars as null) = null;

      at DynamicBitmapFont.destroy (src/scene/text-bitmap/AbstractBitmapFont.ts:194:35)
      at DynamicBitmapFont.destroy (src/scene/text-bitmap/DynamicBitmapFont.ts:406:15)
      at BitmapFontManagerClass.uninstall (src/scene/text-bitmap/BitmapFontManager.ts:257:18)

this.chars[i] doesn't have texture field:

" ": 
    id: 32
    kerning: {}
    xAdvance: 27.783203125
    xOffset: -4
    yOffset: -4

Expected Behavior

It uninstalls the font successfully

Steps to Reproduce

Install a font with chars containing a space.
Uninstall it

import { Cache } from '../../../src/assets/cache/Cache';
import { BitmapFontManager } from '../../../src/scene/text-bitmap/BitmapFontManager';
import type { BitmapFont } from '../../../src/scene/text-bitmap/BitmapFont';

describe('BitmapFontManager', () =>
{
    it('should uninstall and remove from Cache', () =>
    {   
        BitmapFontManager.install('foo', {}, { chars: ' ' });
        expect(Cache.get<BitmapFont>('foo-bitmap')).toBeDefined();

        BitmapFontManager.uninstall('foo');
        expect(Cache.get<BitmapFont>('foo-bitmap')).toBeUndefined();
    });
});

Environment

Possible Solution

No response

Additional Information

No response

@bigtimebuddy bigtimebuddy added the 🕷 Bug Verified that it’s actually a legit bug that exists in the current release. label Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🕷 Bug Verified that it’s actually a legit bug that exists in the current release.
Projects
None yet
Development

No branches or pull requests

3 participants