Font Module for games

Advanced game related topics
coco2
Enthusiast
Enthusiast
Posts: 353
Joined: Mon Nov 25, 2013 5:38 am
Location: Australia

Re: Font Module for games

Post by coco2 »

I was just in the process of adding unicode support for all characters but I've come across a problem. Some characters are reported by PureBasic as zero width which means they are like a diacritic mark that goes over to top of the next character. I can't find any way of supporting these in a sprite system, since PureBasic doesn't render these individually into a sprite. I'm guessing these are displayed when there is a character after them which makes it impossible to create them as a sprite. Some example characters are in Arabic: 1541, 1558, 1559, 1560, 1561, 1562, 1564, 1652.

EDIT: I found a method to do it. If the character has zero width then flag it as diacritic and when creating the sprite add a space after it. Also give it the same width as the height. It doesn't matter if the sprite is too wide, it just has to be wide enough. Then I created a new procedure that draws strings and takes diacritics into account (it will be slightly slower). When drawing a sprite that is a diacritic then don't move to the new position, stay in the same place and then draw the next character.
User avatar
STARGÅTE
Addict
Addict
Posts: 2037
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Font Module for games

Post by STARGÅTE »

You can avoid this problem, when you use the vector drawing library to render your character sprites.
Here, VectorTextWidth() has the option to give not the text-flow width but the visible width.
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
coco2
Enthusiast
Enthusiast
Posts: 353
Joined: Mon Nov 25, 2013 5:38 am
Location: Australia

Re: Font Module for games

Post by coco2 »

I think that would be a good option when making a text editor application but for sprites I need to use font files (you can't use RegisterFontFile with the vector library)
Post Reply