Missing LabelStyle font.
Closed this issue · 4 comments
Link label sample :https://github.com/rednblackgames/HyperLap2D/wiki/libgdx---Getting-Started
LabelVO labelVO = new LabelVO();
labelVO.itemIdentifier = "labeltutorial";
labelVO.text = "This is a runtime label";
labelVO.style = "Bodoni MT";
labelVO.size = 26;
labelVO.layerName = "Default";
labelVO.x = 10;
labelVO.y = 10;
labelVO.width = 100;
labelVO.height = 100;
I has add font to asset/freetypefonts/Bodoni MT.tff and assets/Bodoni MT.tff. But has miss labe style.
Can anyone help me to solve this error, I really don't know where I am missing.
Hi! Can you add more details about?
If you have copied the font manually into asset folder then hyperlap can't recognize it until you explicit tells to load into ResourceManager
Hi @fgnm
The first thing I did was: copy the font to my project(asset/freetypefonts/Bodoni MT.tff and assets/Bodoni MT.tf) according to the above link and copy the code lable and call. but it is showing error.
Sorry, because I'm a new developer :(
You've two ways to load font in hyperlap:
- Place a Label object in the editor (save and reload project before export). In that case during scene loading
ResourceManager
will load required font-size pair automatically. - If you want to generate lables at runtime without insert any label object in the editor previously, your
ResourceManager
needs to be informed that has to load a new font-size pair, in order to do that, you first need to place the font intoassets/freetypefonts/
folder of your game/libGDX project (not hyperlap project) and then tellsResourceManager
to load it with:resourceManager.loadFont(new FontSizePair("Bodoni MT", 26));
.
Note that if you need the same font but with different size you've to call loadFont
multiple times.
hi @fgnm, thank you..
String fontTest="Bodoni MT";
mAsyncResourceManager.loadFont(new FontSizePair(fontTest, 26));
LabelVO labelVO = new LabelVO();
labelVO.itemIdentifier = "labeltutorial";
labelVO.text = "This is a runtime label";
labelVO.style = fontTest;
labelVO.size = 26;
labelVO.layerName = "Default";
labelVO.x = 10;
labelVO.y = 10;
labelVO.width = 100;
labelVO.height = 100;
Entity label = mSceneLoader.getEntityFactory().createEntity(mSceneLoader.getRoot(), labelVO);
mSceneLoader.getEngine().addEntity(label);