carlfoxmarten: (chair)
I thought it might be interesting for people to see how I'm going to specify fonts.

In the previous font engine (which was essentially sprite-based), each font was a long, thin image with characters running horizontally in alphabetical order from the exclamation point ('!') to the 127th ASCII character ('}', as it turns out), with the top line of pixels indicating where each character stopped and started.

The font engine would run through this top line, looking for the spaces between the dots or dashes and extract each character, putting each into its own sprite.

This worked very well up until I needed to put a line of characters in front of a row of Tetris blocks, as the sprites were positioned based on screen pixels, and the Tetris rows were based on 3D space coordinates.
(granted, I did figure out how to do a rough conversion, but that wasn't a very good method, and it wouldn't let me do any rotations or scaling, which would be rather handy for extra effects)

However, the line of pixels indicating the extents of each character was something I could readily add, and I really liked how everything that specified a font was in one file.
(unlike some font engines I found...)

So, my next font engine will again use that row of pixels to specify character extents, but as I will use only one image texture for all the characters at the same time (no more texture splitting for now), I'll need to do "character wrapping", which also means that the line of character extents indicating pixels will also need to wrap.
(for some reason, graphics cards happen to like square images instead of long, thin ones)

I've started some work on the new font engine, which also means I've broken all the current font code, which then means the project won't even compile now.
Good incentive to get the new engine done quickly, eh? =^.^=

The one thing I'm not quite sure about, however, is generating the new fonts.
So far I've used The Gimp to create a 256x256 pixel image and paste in all the appropriate characters, tweaking the font sizes and stuff until almost all the space in the image is taken up without having anything overlap anything else, then laboriously putting in all the alignment pixels.

I'm thinking I should write a font generator in Java...

Edit: Just so people have an idea of what I mean, here is a possible font descriptor image for the new font engine:

Note that the strip of pixels indicates how wide each character is by indicating where the spaces are.
carlfoxmarten: (Default)
So, as I'm bored today (at least until I start making dinner, then going over to Grandpa's to watch the hockey game), I've decided to rewrite my font engine.

The current font engine I have for Tetris-Power is strictly based on bitmaps which are used to directly affect the screen pixels, which means that if I need a different font size, I have to create, load and track another font file, which is not a recommended practice.

So, I need a polygon-based font engine that allows me to specify a size for each line of text without needing a new font for each point-size I need.

This will need to be almost a complete rewrite of the engine from the ground up, as my previous font engine used a vertically short and horizontally long image to represent the font, and graphics cards like square images to work with.

Another reason I need this rewrite is that when a row gets removed, the score you get floats up from the vanishing row, which means that I needed to figure out exactly where in pixels I had to start the score, when the rows exist in three dimensions. With the new engine, I'll be able to specify the location of the score text by simply taking the 3D position of the row and moving it closer to the viewer, so much simpler and with even less chance for mistakes.
(also, it makes graphical effects like spinning text SO much easier to do, and it even gives me anti-aliased text for nearly free, too!)

Profile

carlfoxmarten: (Default)
Carl Foxmarten

August 2023

S M T W T F S
  12 345
6789101112
13141516171819
20212223242526
2728293031  

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 15th, 2025 08:36 pm
Powered by Dreamwidth Studios