From 4987c30580ae516a408910b5495221014c77c4a5 Mon Sep 17 00:00:00 2001 From: Jakub Arnold Date: Sun, 28 Apr 2024 21:12:14 +0200 Subject: [PATCH] Improved text atlas usage logging --- Makefile | 4 ++-- comfy-wgpu/src/text.rs | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index b51a4eb..a14d966 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ # EXAMPLE=egui # EXAMPLE=exr-hdr-image # EXAMPLE=full_game_loop -EXAMPLE=fullscreen +# EXAMPLE=fullscreen # EXAMPLE=framerate_vsync # EXAMPLE=fragment-shader # EXAMPLE=music @@ -31,7 +31,7 @@ EXAMPLE=fullscreen # EXAMPLE=sprite # EXAMPLE=shapes # EXAMPLE=sound -# EXAMPLE=text +EXAMPLE=text # EXAMPLE=timed_draw # EXAMPLE=version # EXAMPLE=y_sort diff --git a/comfy-wgpu/src/text.rs b/comfy-wgpu/src/text.rs index 662fabd..fbd5821 100644 --- a/comfy-wgpu/src/text.rs +++ b/comfy-wgpu/src/text.rs @@ -172,7 +172,16 @@ impl TextRasterizer { )) .unwrap_or_else(|| panic!("FAILED TO FIT GLYPH {}", c)); - info!("still have {} free space", self.atlas.free_space()); + if self.atlas.free_space() < self.atlas.allocated_space() { + let used = self.atlas.free_space(); + let total = self.atlas.size().area(); + info!( + "font atlas has {}/{} space ({:.2}%) used", + used, + total, + (1.0 - used as f32 / total as f32) * 100.0 + ); + } let rect = allocation.rectangle.to_rect(); let inset_rect = IRect::new(