-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Choose your own font and size #1154
Conversation
What happens if fonts don't fit in a texture within max Tex size? |
Each font only allocates the glyph it actually uses (*), so a font texture of e.g. 4096x4096 can fit a lot of glyphs. If it gets full, the atlas is cleared and filled in again. The atlas can still get full if you use a lot of glyphs of different types and font sizes at the same time. For that to realistically happen though, you are filling your screen with all kinds of different text (or have a lot of varying text of varying sizes in a scroll area). Anyway, if this happens: an error is printed to stderr (I will likely start using the I believe this could happen if you load a big font (which supports tens of thousands of glyphs) and open the Font Book in the demo (which will paint all glyphs in the font), but otherwise I hope this will be extremely rare. For now I think this is a reasonable limitation, as a more robust solution would require multiple font textures which will complicate text painting (needing to switch textures mid-mesh), or require a completely different way of rendering text. (*) All of ASCII is currently pre-cached for each font, but this might change |
In #1154 the default was set to 16k x 512, which is way excessive, as most of it will be blank. This PR changes it to 8k x 64, which will make egui use less RAM and VRAM, and load quicker again. This also decreases the max size from 16k² to 8k². That should be enough.
In #1154 the default was set to 16k x 512, which is way excessive, as most of it will be blank. This PR changes it to 8k x 64, which will make egui use less RAM and VRAM, and load quicker again. This also decreases the max size from 16k² to 8k². That should be enough.
This PR rewrites a lot of the font and
TextStyle
related code so that you can now no longer limited to what's inTextStyle
. Now you can use any font size and any font family in all widgets and painting.TextStyle
still exists, but has been moved fromepaint
toegui
, with a look-up-table inegui::Style
. It has also been extended withTextStyle::Name
so you can create your own named text styles.FontFamily
also has aFontFamily::Name
variant so you can name any of your custom font families (ifFontFamily::Proportional
andFontFamily::Monospace
are not enough for you).FontId
is a newstruct
that contains aFontFamily
and a size.TODO: