• entries
    707
  • comments
    1173
  • views
    434138

GameFontLib

Sign in to follow this  

80 views

I finally got script-fonts working right. The problem was that I'm a moron lol. I can't even really seem to say it without sound dumb lol. Pretty much, I was in the mindset that I was calculating the width of the string when what I really wanted to do was calculate the right boundary (the right side of the very last character in the string.) After working a total of around 6 hours on this problem, I switched mindsets and had it working in less than 5 minutes. All I really had to add was four lines of code (well, two lines in two different places.) When I've reached the end of the line or the end of the string, I had to add what was left over of the last character (I iterate the string, adding the x-advance values and then when I reach a new line or the end of the string, I add the width of the last character minus it's x-advance to the total width.)

Kerning doesn't seem to be working right either. When I leave kerning out, my output looks almost exactly as the font does in MS office, but when I add kerning, the pairs with kerning overlap or are too far apart. I sent Andreas an email, so I'm leaving it out until then.

So, at the moment I've got alignment completely finished, script-style fonts supported, multiple pages working, batching half-finished (still need to get an index-buffer in there), and viewport-based rendering.

Formatting to break words isn't in yet (other than newlines), but I'll get that done tomorrow or Monday. I'm trying to decide how I want to do the color system. At the moment I've got a table system in place (the system has a table with 10 nodes in it which can be changed at anytime.) To change the color in the string you'd just use $[0-9] and it'd change the color of the next word to the color in the corresponding table index.
The problem with that is that very limited (only 10 colors.) I had thoughts of reimplementing my old system (where you could specify RGB values), but that puts more strain on scripters (you'd have to make sure your colors stay consistent for key-word highlighting.)

nerd_boy recommended changing it to ${#} and that would allow pretty much an unlimited number of colors. I could also allow strings then, so instead of making sure that every character is colored using $(51) and that nothing changes that color, you could use $(CharNameColor). The problem there is that it's very ugly. For example:

Welcome back to my shop, $(CharNameColor)Malykai!


And there's also the problem with phrases. For example, you might have a character mention Donny's House. To do that with the current system would require:

The artifact can be found at $(PlaceNameColor)Donny's $(PlaceNameColor)House.

As a small aside, I just realised that my current system would recognize the apostraphe as punctuation and revert back to the default color; so the 's' wouldn't be highlighted.

Not very...efficient or wanted. I've had thoughts of implementing an HTML like tag system. That would fix the above problem (I'd just have and ), but is more bloated and just as ugly. The reason I'm using the system I am is that is simple and doesn't stick out like a sore thumb:

The artifact can be found at $1Donny's $1House.


I don't know though; I'll think about it. I'm off to bed though, I was going to head there two hours ago. My to-do list grew by one, but I'm down to three items:
* Get kerning, formatting, & alignment in.
* Decide on a coloring system.
* Get scaling in.
* Get clipping in.
* Decide whether or not I want shadow support. Answer is: nope.
* Get an index-buffer involved in the batching.
* Add functions so that I can react to lost devices and device resets.
* Add viewport support
* Add methods to retrieve character set information and glyphs.

One of things I have on my maybe list is a loader plugin system. That way it could be used to load any font (not just the ones generated from my tool that uses the files generated by AngelCode's bitmap font generator.) Technically, one could write a loader plugin that does all of the generating on-load and doesn't even need an external tool. But, as I said, that's on the maybe list and if I decided to do it, it'd be later down the road. Once the above items are done, I'm moving on to the prototypes.

[edit]
Another idea, I could expand the current system. Keep it like the old, but adding support for A-Z. So, you can use $[0-9,A-Z] to specify the color and you could use certain characters for things. For example, $C could be used to color names and $P could be used to color places.

I could then add support for $< and $> for phrase. For example:

The $IGoblet can be found at $!

'Goblet' would be colored with whatever color is stored in C(ending at the space) and then "Donny's House" would be colored with whatever color is stored in P.

Still not "pretty" (especially with characters right next to eachother), but adds more flexibility and fixes the phrases problem.

Any comments/suggestions?
Sign in to follow this  


0 Comments


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now