-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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
Fonts #5301
Comments
Could you describe what you mean by "vague"? |
@rokups I think he is talking about the slight blurriness of the characters, for this I would probably assume DPI scaling or AA. |
Our font rendering is not as good as OS ones for two mains reasons (but not only that):
- stb_truetype doesn’t handle font hinting. For <4k resolutions and “small sizes” this is rather noticeable. Using imgui_freetype can noticeably improve rendering and you can do this today.
- We don’t support sub-pixel rendering (there is an experimental pull request for that) which is a technique taking advantage of particular LCD/screen layout where typically a pixel is often composed of 3 R/G/B subpixels which are treated separately, effectively tripling horizontal resolution. This is what most OS rendering are using and this is why when you look closely at text you may notice r/g/b fringe bleeding.
For a small you can look at imgui_freetype to improve rendering quality.
|
Sorry.I mean the text is not distinct. |
Issue with MacOS is that it pretends screen has 2x less pixels than it actually does. This simplifies application development in most cases, but in our case we happen to render fonts at 1x scale while screen renders at 2x scale. You can cheat a little: CGFloat scale = NSScreen.mainScreen.backingScaleFactor;
ImFontConfig cfg;
cfg.SizePixels = 13.0f * scale;
io.Fonts->AddFontDefault(&cfg);
io.FontGlobalScale = 1.0f / scale;
This rasterizes default font at 2x
And this renders fonts at half a scale. Here we worked around scaling issues by rasterizing fonts at twice size, but also reduce rendered fonts by half so they visually look same, except crisper (font atlas pixel matches physical pixel on the screen). |
OK.I will have a try. |
Thanks.I will have a try. |
It seems to work.Thanks. |
I'm trying this workaround to get crisper fonts, and it kind of works. However, if I scale the fonts by more than 1.8 or so, the font textures seem to become all black. Any ideas why that would happen? |
Hmm, it seems to be related to max texture size. If I reduce the size of the biggest font I'm loading then scale factors above 2 works too. |
Is the loading of all glyphs to a single texture a thing that lives in imgui, or is it due to using stb_truetype.h? Maybe freetype would work better for me if so? |
It's an issue in dear imgui. Freetype does has the advantage that hinted rendering makes oversampling much less necessary and therefore save spaces. In my experience OversampleH=3 by default is largely overkill, =2 is enough. |
Reducing OversampleH to 2 allowed me to load fonts at 2x, so now my app has crisp fonts on macs. :) |
@rokups This works great for me if I use That being said, I am not sure how you get access to Shouldn't using |
Not quite sure what you mean.
You can create a function in obj-C and expose it to c++. |
@rokups Thank you. BTW it seems that the code you pointed to |
cf ocornut/imgui#5301 Issue with MacOS is that it pretends screen has 2x less pixels than it actually does. This simplifies application development in most cases, but in our case we happen to render fonts at 1x scale while screen renders at 2x scale.
Due to Dear ImGui issue ocornut/imgui#5301, the font scaling on HiDPI setup (only on macOS) is not correct and results in blurry text. This PR is a workaround for that. * simple scale technique worked. * check DisplayFramebufferScale * start making a shim * automatic detection of scale factor on macos * make nix build succeed. * remove stale code * compile shim.mm only on macOS
Platform: Mac OS
Backend: Metal
Why is the Chinese displayed so vague?
The text was updated successfully, but these errors were encountered: