K
K
Ksenia2019-12-09 15:26:08
Fonts
Ksenia, 2019-12-09 15:26:08

How to generate TMP_FontAsset if there is a font texture and a description of which coordinates to take the “picture” for glyph from?

Hello!
I can't fully understand the workflow for the next task.
To generate a font, I have the following information:
1) a texture that contains all the necessary characters;
2) a description of each character, from which I can populate the data for each glyph in the GlyphTable and CharacterTable (which correspond to the rendered texture). This includes the location of the character on the texture, height/width, etc.
I need to generate TMP_FontAsset from this data.
To begin with, I take some existing TMP_FontAsset, do ClearFontAssetData(), and then add the necessary Characters to the CharacterTable according to my data.
Next, I don't understand what I need to do to set up the display of part of the texture in the "window" in which the preview of the symbol is shown. I just have a void.
I'm applying my texture to the atlasTextures (element 0), atlas fields in the Debug inspector's view, but I can't get my texture into the most important field, AtlasTexture.
In general, there is a mess in my head, and I still don’t understand what exactly needs to be corrected in my case.
Those. I would at least understand how to do what I want in the inspector: for example, add a texture from which characters for the font will be taken; adjust the position of the first character with the knobs. Does not work.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Ksenia, 2019-12-10
@Ksushqa

The main important points turned out to be this:
- apply your texture as a font atlas and apply your material;
- pass the desired texture with symbols to _MainTexture of the font material;
- fill in glyph table data;
- fill in character table data.
Note that the AtlasWidth and AtlasHeight fields must match the texture size.
After generation, it may be that the font is not immediately updated, so you need to check it first.
In my case, in the preview inspector, the characters were "empty", despite the fact that they looked correct in the text. Therefore, it is better to check the characters of the font on some text in the scene.
Don't forget to clear the glyph table and character table of the font before each generation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question