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

PixelFont class for displaying text with image based fonts #334

Open
quinton-ashley opened this issue Oct 16, 2024 · 1 comment
Open

PixelFont class for displaying text with image based fonts #334

quinton-ashley opened this issue Oct 16, 2024 · 1 comment

Comments

@quinton-ashley
Copy link
Owner

quinton-ashley commented Oct 16, 2024

The idea is to give users an easier way to load and write text with pixel (image based aka bitmap) fonts like this one:

Actual size:
Alphanumeric

Scaled up:
Screenshot 2024-10-16 at 08 12 05

I'd like a PixelFont class that extends the SpriteAnimations class.

Users would need to define the characters (charSet) in the order they appear in the image. Internally each character would be loaded as a single frame animation, with the character as the animation name. Spaces would be ignored by this setter so that users could skip parts of the image they don't want to load.

//                               (image, charWidth, charHeight, padX, padY)
let pix = new PixelFont("1bit-font.png", 8, 8, 1, 1);
pix.charSet = `ABCDEFGHIJKLM.!?NOPQRSTUVWXYZ,:;abcdefghijklm"''nopqrstuvwxyz"/\\01234#$€~ …       56789&@%^-      +-*÷=<>()_`;

The main task would be implementing a pixelFont.text function that enables users to write messages on screen using the pixel font.

pix.text("Hello world!", 50, 50);
@quinton-ashley
Copy link
Owner Author

quinton-ashley commented Nov 12, 2024

In the future I'd also like the PixelFont class to support loading .fnt bitmap font files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

No branches or pull requests

1 participant