• entries
707
1173
• views
436775

# Bitmap Font System

165 views

I set out to code my bitmap font system last night...ran into a few snags. I'm not going to speak of the first problem I ran into; suffice it to say, I was a complete dunce (I blame exhaustion.)

The second snag came up when it came down to adding text alignment. When I started I said to myself "If I run into any problems, I'll pull out my old font system and see how I did it there."

I got a few lines in and was like "WTF, I don't remember having to do this* in my old code. Lets see how I did it before." So, I whipped out my old code and scanned through it. Then I scanned through it again. And once more, for good measure. For some reason, I think I like to regularly act like a dunce because, I had all of the code for me to tell my font system to render aligned text, but I didn't have ANY of the code that actually aligned text.

* The 'this' that I'm referring to is splitting the input text into lines so that multiple lines will center correctly.

Anyway, the base system is done (meaning I can get aligned text onto the screen.) At the moment I'm just splitting the text into multiple strings and going from there, but I think that iterating the character and detecting strings from there will be faster. I'm not worried about speed at the moment though.

Anyway, without further ado, another screenshot:

[Chronicles of a Hero Font, White, Center alignment]

Next on the list is rectangle binding (currently only supports resolution binding), color formatting, and word-break formatting. All done [grin].

Rectangle bound done (lol, not even 5 minutes. I guess it helps when you've done this as many times as I have.)

[Chronicles of a Hero Font, OrangeRed, Center alignment, @{100, 75 x 200, 100}]
And the black background is drawn by me, not the font system.

I'm going to do word-break formatting next because it's easy and I've got some things to decide on when it comes to color formatting.

[edit2]
Word-break formatting is done. Nothing fancy really, just showing the same text constrained to 2 smaller rectangles (so no screenshot.)

Also yes, I am going to be posting every screenshot I take. If I think it's screenshot worthy, then it's upload & post worthy :P.

[edit3]
Ok, color-formatting is done. Kind of deserves a post of it's own, but I'll just append it here. First off, screenshot:

Ok, my old system allowed both a color table (via the ^[0-9] formatting) and custom colors (via rgb(r, g, b) or argb(a, r, g, b) formatting) which was awesome, but pointless. Color formatting on a per-character basis is retarded.

So, my new system is setup using only a color table (via the $[0-9] format at the moment, but I might change the$ character.) There is a default color table, or you can supply your own (this will be helpful when I implement my GUI skin system.)

Also, the system now does color formatting on a per-word basis (however you could still do per-character coloring via '$0t$1h$2i$3s') and automatically returns to the default color (if you supply a color table, it's the first color in the table. If you don't it defaults to the color you supplied) when it reaches a control character (newline, tab, etc) or a space.

I didn't say so before, but my font system uses AngelCode's bitmap font generator because it fucking rocks my socks.

Not quite sure were I'll go from here. Probably move onto the user interface.

[edit4]
Ok, I thought I'd point out that this is NOT XNA (showed off a screenshot in an IRC chat and Krisc thought it was XNA because of the CornflowerBlue background), I just have a lot of the same colors as XNA.

There are no comments to display.

## Create an account

Register a new account