Jump to content

Problem with Polish diacritical characters in VSImGui


Go to solution Solved by Brady_The,

Recommended Posts

Posted

Hello,

I'm working on a Vintage Story mod that uses VSImGui for displaying the interface. I'm encountering an issue with displaying Polish diacritical characters (ą, ę, ć, etc.) in the ImGui interface.

I tried loading a custom font with Polish character support in the following way:

private ImFontPtr? customFont = null;

// In the constructor:
private void LoadCustomFont()
{
    try
    {
        string fontPath = Path.Combine(..., "Arial.ttf");
        
        if (File.Exists(fontPath))
        {
            var io = ImGui.GetIO();
            customFont = io.Fonts.AddFontFromFileTTF(fontPath, 16.0f);
            // Logs indicate the font was loaded successfully
        }
    }
    catch (Exception ex)
    {
        // Error handling
    }
}

// When rendering:
if (customFont.HasValue)
{
    ImGui.PushFont(customFont.Value);
}
// ... drawing interface ...
if (customFont.HasValue)
{
    ImGui.PopFont();
}

Unfortunately, after using ImGui.PushFont(customFont.Value), the game crashes without any error message.

Has anyone encountered a similar issue? Is there a recommended way to implement support for non-ASCII characters in VSImGui?

I also tried using Unicode codes directly (\u0105 for 'ą', etc.), but without success.

Thank you in advance for any suggestions!

  • Solution
Posted
41 minutes ago, Potusek said:

Is there a recommended way to implement support for non-ASCII characters in VSImGui?

Unfortunately it's doubtful that you will get a meaningful response here. There are a couple of modders around in the forum, but they are generally more content and not coding focused.

You will most likely receive better support in the dedicated ImGUI thread on the VS Discord server.

There's also the option to simply set the whole game font to a font that supports these special characters, either by editing the clientsettings file (defaultFontName) or using this mod: https://mods.vintagestory.at/fontsettings, which of course would require everyone who is using your mod to do the same, so this might not be the best option.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.