Page 2 of 2

Re: Font Module for games

Posted: Sun Dec 03, 2023 12:16 pm
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.

Re: Font Module for games

Posted: Sun Dec 03, 2023 2:35 pm
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.

Re: Font Module for games

Posted: Sun Dec 03, 2023 11:36 pm
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)