where to put fonts #720
Replies: 8 comments
-
This post has been migrated automatically from the old LITIENGINE forum (2018 - 2022). sourceSets {
main.java.srcDir "src"
main.java.srcDir "sprites"
main.java.srcDir "sounds"
main.java.srcDir "fonts"
main.java.srcDir "maps"
main.java.srcDir "localization"
main.resources.includes = ["game.litidata"]
} I recommend not retrieving the font on every render call. Apart from that , you should ditch the "./" in front of the font name. It makes sense to load all Font Resources in one place, e.g. in a class with static Constants, something like the following: public class FancyFonts {
public static final Font NUMBER_FONT = Resources.fonts().get("04b_11_.ttf").deriveFont(16f);
public static final Font JOURNAL_TITLE_FONT = Resources.fonts().get("superscr.ttf").deriveFont(32f);
public static final Font JOURNAL_TEXT_FONT = Resources.fonts().get("pixel-love.ttf").deriveFont(32f);
public static final Font UNI_FONT = Resources.fonts().get("unifont.ttf").deriveFont(32f);
public static final Font GUI_FONT = Resources.fonts().get("fsex300.ttf").deriveFont(32f);
public static final Font GUI_FONT_MID = GUI_FONT.deriveFont(24f);
public static final Font GUI_FONT_SMALL = GUI_FONT.deriveFont(16f);
public static final Font SPEECH_BUBBLE_FONT = GUI_FONT.deriveFont(4f);
public static final Font FLOATING_COMBAT_NUMBERS_FONT = GUI_FONT.deriveFont(4f);
public static final Font ICON_FONT = Resources.fonts().get("iconfont.ttf").deriveFont(48f);
private FancyFonts() {
}
public static final FontIcon ICON_FEMALE = new FontIcon(ICON_FONT, "\uE800");
public static final FontIcon ICON_MALE = new FontIcon(ICON_FONT, "\uE801");
} |
Beta Was this translation helpful? Give feedback.
-
This post has been migrated automatically from the old LITIENGINE forum (2018 - 2022). |
Beta Was this translation helpful? Give feedback.
-
This post has been migrated automatically from the old LITIENGINE forum (2018 - 2022). |
Beta Was this translation helpful? Give feedback.
-
This post has been migrated automatically from the old LITIENGINE forum (2018 - 2022). |
Beta Was this translation helpful? Give feedback.
-
This post has been migrated automatically from the old LITIENGINE forum (2018 - 2022). |
Beta Was this translation helpful? Give feedback.
-
This post has been migrated automatically from the old LITIENGINE forum (2018 - 2022). |
Beta Was this translation helpful? Give feedback.
-
This post has been migrated automatically from the old LITIENGINE forum (2018 - 2022). |
Beta Was this translation helpful? Give feedback.
-
This post has been migrated automatically from the old LITIENGINE forum (2018 - 2022). |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
This post has been migrated automatically from the old LITIENGINE forum (2018 - 2022).
Posted: 2020-04-05 19:24:00
User: smcbot [] (age: 947 days 🙌; posts: 12)
So, lately I have been working on a project and when I run it, I get the error that it can't find the font. I am using:
g.setFont(Resources.fonts().get("./joystix_monospace.ttf",16f*Main.scale)); in the render method of my screen.
The error message makes it seem like it's looking for the font in the directory I am running the application from.
Where should I put the font and/or what do I need to add to the build.gradle file to make this work?
Beta Was this translation helpful? Give feedback.
All reactions