ice1000 / jimgui

:sparkling_heart: Pure Java binding for dear-imgui
Apache License 2.0
185 stars 13 forks source link

Fonts don't seem to do ...anything. #79

Closed LowSpecCorgi closed 3 years ago

LowSpecCorgi commented 3 years ago

So, I have a directory structure like so:

src
 - main
  - java
    - ...
  - resources
    - fonts
      - Roboto-Bold.ttf
      - Roboto-Regular.ttf

Loading both fonts seem successful, by merit of no exception and such:

largeFont = imGui.getIO().getFonts().addFontFromFile(getClass().getClassLoader().getResource("fonts/Roboto-Bold.ttf").getPath(), 48);
smallFont = imGui.getIO().getFonts().addFontFromFile(getClass().getClassLoader().getResource("fonts/Roboto-Regular.ttf").getPath(), 24);

But, when pushing the font like so:

imGui.pushFont(largeFont);

imGui.text(
    WINDOW_TITLE
);

JImGuiGen.popFont();

Nothing happens. The text is rendered, but with the default ImGui font, I'm not particularly sure why this is happening.

Help would be appreciated :)

ice1000 commented 3 years ago

Try using absolute paths instead?

LowSpecCorgi commented 3 years ago

Try using absolute paths instead?

getClass().getClassLoader().getResource("fonts/Roboto-Regular.ttf").getPath()

Does return an absolute path to the resource

LowSpecCorgi commented 3 years ago

Oh wait you were right

I'm stupid

thanks for help

ice1000 commented 3 years ago

Try using absolute paths instead?

getClass().getClassLoader().getResource("fonts/Roboto-Regular.ttf").getPath()

Does return an absolute path to the resource

I think that's a Java specific format of path. You need to give imgui (yes, imgui, not jimgui) a path that is recognizable by the C++ file IO library.

ice1000 commented 3 years ago

You're not stupid, you're cute!