fix: bake UI font atlas at physical DPI size so text isn't skinny on standard-DPI
The font atlas was rasterized once at a fixed 16px and point-filtered, then scaled to a logical size at draw time. On HiDPI it got upscaled (acceptable); on standard-DPI it got downscaled, and point filtering dropped rows/columns of the anti-aliased glyphs, thinning stems into a faint "hyper-skinny" look. Bake the atlas at the real physical size text is drawn at (16 * GetUIScale() * GetWindowScaleDPI().y), quantized to 4px steps, and rebuild it via EnsureUIFont() once per frame when that density changes (resize, or moving between monitors of different DPI). Use mipmaps + trilinear filtering so downsampling stays smooth. Call sites are unchanged: DrawTextEx still scales the atlas glyph to the same logical size, only the backing resolution differs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,15 @@ float GetUIScale(void);
|
||||
void DrawTextScaled(const char* text, float x, float y, float baseSize, Color color);
|
||||
float MeasureTextScaled(const char* text, float baseSize);
|
||||
|
||||
// --- DPI-aware UI font ---
|
||||
// InitUIFont remembers the TTF path and bakes the first atlas; EnsureUIFont
|
||||
// rebuilds it (cheap no-op when unchanged) whenever the effective pixel density
|
||||
// (window UI scale * monitor DPI scale) shifts, keeping text crisp on any
|
||||
// display instead of thinning out on standard-DPI screens. Call EnsureUIFont
|
||||
// once per frame before drawing text.
|
||||
void InitUIFont(const char* path);
|
||||
void EnsureUIFont(void);
|
||||
|
||||
// --- Colormaps ---
|
||||
void GenerateColormapTexture(void);
|
||||
const char* ColormapName(ColormapType type);
|
||||
|
||||
Reference in New Issue
Block a user