Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken OTF icons in fullscreen #4698

Closed
ambitslix opened this issue Nov 6, 2021 · 4 comments
Closed

Broken OTF icons in fullscreen #4698

ambitslix opened this issue Nov 6, 2021 · 4 comments

Comments

@ambitslix
Copy link

ambitslix commented Nov 6, 2021

Dear ImGui 1.85 WIP (18420)
--------------------------------
sizeof(size_t): 8, sizeof(ImDrawIdx): 2, sizeof(ImDrawVert): 20
define: __cplusplus=201103
define: __linux__
define: __GNUC__=9
--------------------------------
io.BackendPlatformName: imgui_impl_sdl
io.BackendRendererName: imgui_impl_sdlrenderer
io.ConfigFlags: 0x00000000
io.ConfigInputTextCursorBlink
io.ConfigWindowsResizeFromEdges
io.ConfigMemoryCompactTimer = 60.0
io.BackendFlags: 0x00000006
 HasMouseCursors
 HasSetMousePos
--------------------------------
io.Fonts: 2 fonts, Flags: 0x00000000, TexSize: 4096,16384
io.DisplaySize: 2560.00,1440.00
io.DisplayFramebufferScale: 1.00,1.00
--------------------------------
style.WindowPadding: 8.00,8.00
style.WindowBorderSize: 1.00
style.FramePadding: 4.00,3.00
style.FrameRounding: 6.00
style.FrameBorderSize: 0.00
style.ItemSpacing: 8.00,4.00
style.ItemInnerSpacing: 4.00,4.00

Branch: master

Back-ends: imgui_impl_sdl.cpp imgui_impl_sdlrenderer.cpp
SDL: 2.0.17
Compiler: gcc
Operating System: Ubuntu/Linux

I'm loading extra fonts like this from MaterialIconsOutlined-Regular.otf:

  size_t       dataSize = 0;
  char*        data     = System::loadData("MaterialIconsOutlined-Regular.otf", dataSize);
  ImFontConfig config;
  ImFont*      font = nullptr;

  static const ImWchar ranges[] = {
    ICON_MIN_MD, ICON_MAX_MD, 0
  };
  // config.SizePixels = 24.0f;
  config.FontDataOwnedByAtlas = true;
  config.MergeMode            = false;
  // Use if you want to make the icon monospaced
    config.GlyphMaxAdvanceX = config.GlyphMinAdvanceX = size;

    font = m_io.Fonts->AddFontFromMemoryTTF(data, dataSize, size, &config, ranges);

It works fine when I'm setting the resolution to anything other then fullscreen desktop resolution. But when I'm setting fullscreen and the same as desktop it will display filled rectangles for all the glyphs. See screenshot.

Screenshot from 2021-11-06 09-32-04

At the same time I'm seeing the following console error:

INFO: error creating texture

This issue only manifest under Ubuntu/Linux. It works fine on Fedora/Windows/Android/OSX I'm guessing it's an SDL issue.

More GFX info here from my app:

Compiled/Linked SDL v2.0.17 / v2.0.17
Current display mode: 3840 x 2160px @ 30HZ
Display #0/0 mode: 3840 x 2160px @ 30HZ
Display #0/1 mode: 3840 x 2160px @ 25HZ
Display #0/2 mode: 3840 x 2160px @ 24HZ
Display #0/3 mode: 2560 x 1440px @ 60HZ
Display #0/4 mode: 1920 x 1200px @ 60HZ
Display #0/5 mode: 1920 x 1080px @ 60HZ
Display #0/6 mode: 1920 x 1080px @ 50HZ
Display #0/7 mode: 1680 x 1050px @ 60HZ
Display #0/8 mode: 1600 x 1200px @ 60HZ
Display #0/9 mode: 1440 x 900px @ 60HZ
Display #0/10 mode: 1440 x 576px @ 50HZ
Display #0/11 mode: 1440 x 480px @ 60HZ
Display #0/12 mode: 1280 x 1024px @ 75HZ
Display #0/13 mode: 1280 x 1024px @ 60HZ
Display #0/14 mode: 1280 x 960px @ 60HZ
Display #0/15 mode: 1280 x 720px @ 60HZ
Display #0/16 mode: 1280 x 720px @ 50HZ
Display #0/17 mode: 1152 x 864px @ 75HZ
Display #0/18 mode: 1024 x 768px @ 75HZ
Display #0/19 mode: 1024 x 768px @ 70HZ
Display #0/20 mode: 1024 x 768px @ 60HZ
Display #0/21 mode: 800 x 600px @ 75HZ
Display #0/22 mode: 800 x 600px @ 72HZ
Display #0/23 mode: 800 x 600px @ 60HZ
Display #0/24 mode: 800 x 600px @ 56HZ
Display #0/25 mode: 720 x 576px @ 50HZ
Display #0/26 mode: 720 x 480px @ 60HZ
Display #0/27 mode: 640 x 480px @ 75HZ
Display #0/28 mode: 640 x 480px @ 73HZ
Display #0/29 mode: 640 x 480px @ 60HZ
SDL detecting drivers...
SDL_GetRenderDriverInfo: #0 opengl
SDL_GetRenderDriverInfo: #1 opengles2
SDL_GetRenderDriverInfo: #2 opengles
SDL_GetRenderDriverInfo: #3 software
SDL_SetHintWithPriority opengl OK
Double-buffer: YES
SDL_CreateWindow (Fullscreen) 3840 x 2160 ...
Vsync ON
SDL_GetWindowSize 3840 x 2160
OpenGL version:         v4.6.0 NVIDIA 460.91.03
GLSL version:           v4.60 NVIDIA
GLVendor:               NVIDIA Corporation
GLRenderer:             Quadro K620/PCIe/SSE2
@ambitslix ambitslix changed the title Broken TTF fonts icons only fullscreen Broken OTF icons in fullscreen Nov 6, 2021
@ocornut
Copy link
Owner

ocornut commented Nov 6, 2021

I'm guessing it's an SDL issue.

Yes probably, and it perhaps has nothing do with fonts, it's just that it's failing to create the atlas texture.
Try to remove fonts from the equation first.
If it works without it could be a texture size issue.

For icon fonts you can probably set the font_cfg.OversampleH and font_cfg.OversampleV values to 1, you'll instantly divide texture size by a factor of three.

@ambitslix
Copy link
Author

ambitslix commented Nov 6, 2021

If I load only the regular font and not the icons there is no problem, so it happens when loading the extra fonts (second set)...so perhaps it's not a SDL issue after all?

@ocornut
Copy link
Owner

ocornut commented Nov 6, 2021

So I guess it is a texture size issue, setting oversample to 1 will help for now. (or reducing the range)

See "Font atlas too large?" section of https://github.com/ocornut/imgui/blob/master/docs/FONTS.md#font-loading-instructions

@ambitslix
Copy link
Author

Thanks. It works fine now with OversampleH/V =1. I don't set fullscreen often obviously for development and by the time I noticed this I completely forgot about reducing the icon range and the section about seeing empty rectangles as a result.

Thanks for the lightning fast help :) and for the excellent ImGui.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants