Skip to content
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

console.lua: improve the hovered item calculation with background-box #15711

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

guidocella
Copy link
Contributor

console.lua: improve the hovered item calculation with background-box

Follow up to c438732 which improved the calculation with the default outline-and-shadow. We can make the calculation accurate for background-box too without making semitransparent rectangle backgrounds overlap by adding margin between items.

We could calculate the height of each item to make them perfectly adjacent by rendering each one with compute_bounds, but that takes 15ms per render, so 20 lines would take 300ms, which is too slow.

Instead add a fixed 0.1 * opts.font_size to each item's height. This ensures the backgrounds don't overlap with tall CJK text or track circles and --osd-shadow-offset=0. Add this to outline-and-shadow too since it looks better with some margin between the items. Then add the rectangle offset to the height depending on the border style.

This should not divide by scale_factor() because osd_w is already scaled
pixels.

Also add a TODO to fix --osd-margin-x's scaling.
Follow up to c438732 which improved the calculation with the default
outline-and-shadow. We can make the calculation accurate for
background-box too without making semitransparent rectangle backgrounds
overlap by adding margin between items.

We could calculate the height of each item to make them perfectly
adjacent by rendering each one with compute_bounds, but that takes 15ms
per render, so 20 lines would take 300ms, which is too slow.

Instead add a fixed 0.1 * opts.font_size to each item's height. This
ensures the backgrounds don't overlap with tall CJK text or track
circles and --osd-shadow-offset=0. Add this to outline-and-shadow too
since it looks better with some margin between the items. Then add the
rectangle offset to the height depending on the border style.
Copy link

Download the artifacts for this pull request:

Windows
macOS

@na-na-hi
Copy link
Contributor

Instead add a fixed 0.1 * opts.font_size to each item's height. This ensures the backgrounds don't overlap with tall CJK text or track circles and --osd-shadow-offset=0.

How do you ensure that the "tall characters" are at most 10% larger than normal characters, but not more?

@guidocella
Copy link
Contributor Author

You don't, it's a heuristic. It works with the fonts I tried and can be increased if it doesn't work with some others.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants