Font lists#24378
Conversation
…to the font assets. When FontSource resolution failed because an asset wasn't yet loaded, `update_editable_text_styles` didn't resolve the FontSource again the next frame.
|
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
|
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
2 similar comments
|
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
|
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
…he loaded collection, instead of the asset path. Store the changed family ids and asset paths, and set the any TextFonts that refer to them as changed.
|
Your PR caused a change in the graphical output of an example or rendering test. This might be intentional, but it could also mean that something broke! If it's expected, please add the M-Deliberate-Rendering-Change label. If this change seems unrelated to your PR, you can consider updating your PR to target the latest main branch, either by rebasing or merging main into it. |
…s`. Respected helpers also renamed.
Objective
Add
FontSourcevariants to support ordered lists of fonts.Solution
The changes are mostly just boilerplate implementing the API. The lists are just handed off to Parley to resolve.
FontSourcevariantsStringandList.bevy_textuses the first available font in the list.FontSource::Namestakes a string in CSS font family format.FontSource::Listtakes a vector of family names and generic font families.FontSource::Familyhas been renamed toFontSource::Named, to better imply it takes a string and to match the correspondingNamesvariant.FontSource::Generic(GenericFontFamily)enum replaces the individual variants for each generic family. Included short form constructors such asFontSource::serif()to be used instead ofFontSource::Generic(GenericFontFamily::Serif).update_editable_text_content_size.FontItemandGenericFontFamilyenums, these just exist to be Bevy friendly types that are mapped internally to Parley'sFontFamilyNameandGenericFamilytypes.testbed_uiscene for testing:FontLists.Limitations
Ideally text layouts would only be regenerated when the selected font changes. That is, suppose you have a list of "Times New Roman, Fira Sans" and only "Fira Sans" is present, so "Fira Sans" is selected. If you then change the list to "Times New Roman, Fira Sans, Gabriola", "Fira Sans" still takes precedence so the text shouldn't need an update, but with this PR it updates on any changes to the list and the entire text is regenerated.
The
update_editable_text_content_sizefunction is a bit unpleasant now but I'm not sure if there's a nicer alternative to what it does. Maybe needs more support from Parley.FontSource::Listdoesn't allow assets handles as items in the font list. This is possible to add, but IMO we should move away from referring to fonts using asset handles.Testing
testbed_ui's newFontListsscene can be used for testing.The first available font from the list (going downwards) is used to display each list. The Gabriola font isn't included with Bevy, so it's skipped.
With the "system_font_discovery" feature enabled, the Gabriola font (if present on your system) is used: