ladybird
ladybird copied to clipboard
LibWebView: add fallback mechanism for monospace font
FontPlugin: add fallback mechanism for monospace font
Problem
Ladybird crashes when trying to resolve the UiMonospace font on systems where the default monospace font is JetBrainsMono Nerd Font. The WebContent process fails with:
VERIFICATION FAILED: m_default_font at /build/source/Libraries/LibWebView/Plugins/FontPlugin.cpp:47
The crash occurs because generic_font_name(Web::Platform::GenericFont::UiMonospace) returns a font name that cannot be successfully loaded by the FontDatabase, and the subsequent VERIFY assertion fails.
Solution
This PR adds a fallback mechanism to the FontPlugin constructor that attempts to find a suitable monospace font when the primary font resolution fails. Instead of immediately failing with a VERIFY assertion, the code now:
- First tries to use the font returned by
fontconfig - If that fails, tries a list of common
monospacefonts - If that still fails, attempts to find any
monospacefont in the database - Only triggers the
VERIFYassertion if all fallback attempts fail
Testing
ctest --test-dir Build/release -R TestFontPlugin
// or
./Meta/ladybird.sh test LibWebView
Related Issues
Fixes #3832
Hello!
One or more of the commit messages in this PR do not match the Ladybird code submission policy, please check the lint_commits CI job for more details on which commits were flagged and why.
Please do not close this PR and open another, instead modify your commit message(s) with git commit --amend and force push those changes to update this PR.
Hi, the verification failure you're seeing is based on a 4-month-old version of the code. I assume you're building from the nixpkgs version. Can you confirm that you see this crash on the master branch without your changes?
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions!
This pull request has been closed because it has not had recent activity. Feel free to open a new pull request if you wish to still contribute these changes. Thank you for your contributions!
Hey guys! The issue is long resolved. Apologies for late response!