Warn, not panic, on invalid fonts (#22491)
# Objective Fix panics due to invalid legacy fonts that we can't generate glyph images from. Fixes #22475 ## Solution * In `text_system` and `update_text2d_layout`, instead of panicking on `TextError::FailedToGetGlyphImage`, `warn_once` and clear the text layout. * Given an invalid font, Cosmic Text returns an invalid text layout with infinite text bounds. If Cosmic Text returns non-finite bounds, return a zero size from the `buffer_dimensions` function. * Added a `get_face_details` method to `CosmicFontSystem` to provide better info for the warning messages. `buffer_dimensions` probably should be reworked to return a `Result`, with the text systems emitting a warning on invalid layout bounds. Not so important though, left for a follow up. ## Testing The `system_fonts` example should no longer panic now. Instead the text with the invalid font is not rendered: <img width="869" height="166" alt="system-fonts-list-fixed" src="https://github.com/user-attachments/assets/a05cab45-68d2-453b-8fa6-16ec5b6bba76" /> One of the problematic fonts: https://github.com/justrajdeep/fonts/blob/master/NISC18030.ttf --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
I
ickshonpe committed
eb1aaba8958d8556e9cf421e0afe41e5c1fd86e4
Parent: 8a52867
Committed by GitHub <noreply@github.com>
on 1/13/2026, 7:35:45 PM