-
Notifications
You must be signed in to change notification settings - Fork 10.3k
raylib: better HTML renderer to handle inline styles #36294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Refactors the HTML renderer for openpilot's UI system to support inline styling (bold and italics) and improves performance through caching and proper HTML parsing.
- Replaces regex-based parsing with a proper HTMLParser class for better HTML processing
- Adds support for italic fonts alongside existing bold support
- Implements caching for text wrapping and height calculations to improve rendering performance
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 4 comments.
File | Description |
---|---|
system/ui/widgets/html_render.py | Complete refactor of HTML parsing logic and rendering with inline styling support |
system/ui/lib/application.py | Extended font loading system to support italic variants |
selfdrive/assets/fonts/*.ttf | Updated Inter font files to version 4.1 and added italic variants |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
How do I fix the LFS errors :( |
I reverted the italic fonts since it seems I can't upload them due to LFS permissions. It will fallback to regular font until they are added. |
this seems very large. can we start by just supporting inline fyi I tried cursor + gpt5 to do this but it was terrible, I suspect you need to do it yourself to get anything mergable |
styles all seem broken for lists now |
I'll take a proper look today. |
I can try to split it out into a separate PR. To make italics work you need the font and I couldn't add it due to lfs permission issues. Btw, it also supports bold + italics. The idea was that adding other inline styling is not that hard with this new way.
This was like the third attempt, but the trick was to prompt it more to start from scratch instead of refactoring the old code. I wanted to get rid of the regex parsing too, which I think was a bottleneck for adding the inline styles. Previous attempts worked for bold, but I wanted a system that could scale to things like italics or underlines, and this approach looked promising. I saw your attempt, which seemed more complex that my previous ones and it inspired me to try again 😅 I did some more prompts to fix some bugs and stuff, but I did have to do a lot of manual cleanup in the end. |
@sshane The issue was that the whitespace between tags was being rendered. Also fixed rendering new lines to support just plain text with new lines. I don't know how to fix the macOS build; I don't think I did anything to break that. Removing italics won't make it that much smaller, but I can still do that if you want. |
388fb21
to
3d4ecc0
Compare
Refactors the HTML Renderer for the following improvements:
The macOS test is failing but I don't understand why 🤔
Example:

Show HTML