-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
Make font atlas padding between packed glyphs configurable #1282
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
Conversation
Thanks James. The patch looks good. Interestingly it could also be useful for very low-spec system to use this with a value of 0 and bilinear filtering filtered (will give it a try). We currently have mouse cursor bitmap (see |
For our particular use case we only modify the font glyphs and leave the cursors alone, so the manual packing there isn't a problem. Given how the cursors are currently implemented, I imagine adjusting those to use a configurable padding amount would probably be a bit more awkward! |
By the way could you clarify the your use with 2+ spacing? Is it related to mip-mapping, or are you altering the rasterized data, e.g. adding an outline to it? |
Yeah, we're altering the rasterized data to add an outline*. It's admittedly a little bit of a hack, but it does mean we don't have to maintain our own font rasterizer as mentioned earlier. If text outlining were available in ImGui that would be neat, though from #745 it's understandable why it isn't. :) *We want an outline because we want our window backgrounds to be fairly translucent, to avoid obscuring the scene underneath (i.e. using some windows as overlays to display data, with only a few interactive widgets). Depending on what's in the scene, this can make text of a single colour hard to read, so an outline is desirable. |
Merged. |
@jadwallis: Your approach will actually break once I add more data into the texture atlas (e.g. rounded shapes), as you won't be able to distinguish easily font vs other graphic data. So you may need to consider another approach. If that happen pretty soon I'd probably remove |
Thanks for the heads up. Hopefully the current approach will tide us over for the moment at least, and I can consider alternative, less hacky implementations later when I have a bit more time. Cheers for your help. :) |
Adds a
TexGlyphPadding
member toImFontAtlas
, which allows the user to configure the size of the padding between pixels when the font atlas texture is built (similar to howTexDesiredWidth
allows a desired width of this texture to be specified).We've found ImGui really useful in our project, but had a need to make some tweaks to the generated font atlas texture in our code after ImGui builds it. Writing a custom font rasterizer for this (like #618) seems like it would be a bit overkill, since we otherwise closely mirror what ImGui does. The texture change we make needs the glyphs in the texture to be spaced out a bit more than the hard-coded default of 1 pixel, which isn't something that the user is currently able to configure. Admittedly it's a bit of a weird and niche use case, but being able to configure this would be quite handy.
Thanks for taking a look!