How to use a font drawn in eps format?

Anything libgdx related goes here!

How to use a font drawn in eps format?

Postby PillowMan » Mon Aug 26, 2019 6:26 pm

Hello. I would like to use own font, which I found on shutterstock in my game. Image is available in eps format. For example:

Image

What is the best way so that I can easily type any text in the game?

I thought it might be better to use the BitFont library, but for this I need to convert a vector image to ttf. Right? I tried to do this using FontLab and Adobe Illustrator. But when exporting the font, only the outline remained. Apparently I did something wrong:

Image

 Please tell me how developers use their font when creating games? Thank you.
PillowMan
 
Posts: 29
Joined: Fri Mar 16, 2018 12:14 pm

Re: How to use a font drawn in eps format?

Postby PillowMan » Wed Aug 28, 2019 9:43 pm

Solved, I think ;). First, I cut out all the symbols and set a name "symbols_24" to each image, where the number is the ASCII code. For example, the image 'A' uses the name symbol_65. Then I made a texture atlas from all the symbols . In the class where I create the textures, I wrote a simple method:

Code: Select all
void loadFont () {
        Array <TextureAtlas.AtlasRegion> regions = mFontAtlas.findRegions ("symbol");
        for (TextureAtlas.AtlasRegion region: regions) {
            [b]symbols[/b].put (region.index, getSprite (region)); [b]*[/b]
        }
    }
[i]* HashMap <Integer, Sprite> symbols;[/i]

 

That's all. To use the necessary sprite with a symbol, you just need to write the following code:

Code: Select all
Sprite sprite = symbols.get((int) c);
PillowMan
 
Posts: 29
Joined: Fri Mar 16, 2018 12:14 pm


Return to Libgdx

Who is online

Users browsing this forum: Google [Bot] and 1 guest