ladybird icon indicating copy to clipboard operation
ladybird copied to clipboard

LibWebView: add fallback mechanism for monospace font

Open arcbjorn opened this issue 9 months ago • 3 comments

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:

  1. First tries to use the font returned by fontconfig
  2. If that fails, tries a list of common monospace fonts
  3. If that still fails, attempts to find any monospace font in the database
  4. Only triggers the VERIFY assertion if all fallback attempts fail

Testing

ctest --test-dir Build/release -R TestFontPlugin
// or
./Meta/ladybird.sh test LibWebView

Related Issues

Fixes #3832

arcbjorn avatar Mar 06 '25 08:03 arcbjorn

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.

ladybird-bot avatar Mar 06 '25 08:03 ladybird-bot

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?

AtkinsSJ avatar Mar 06 '25 10:03 AtkinsSJ

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!

github-actions[bot] avatar Mar 28 '25 02:03 github-actions[bot]

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!

github-actions[bot] avatar Apr 04 '25 02:04 github-actions[bot]

Hey guys! The issue is long resolved. Apologies for late response!

arcbjorn avatar Aug 14 '25 01:08 arcbjorn