serenity icon indicating copy to clipboard operation
serenity copied to clipboard

BackgroundPainting: Added a check to compute_text_clip_paths to ensure we are able to produce a path for a given font

Open 1JSIkora opened this issue 9 months ago • 1 comments

Context: Before this commit Ladybird would crash on websites attempting to utilize the clip-background: text property on a node rendered using a bitmap font

This was the case as compute_text_clip_paths assumed the glyph font was a derived instance of type ScaledFont. In reality BitmapFont was passed to the function under the above condition

This commit omits rendering text using the above property for bitmap fonts whilst maintaining it for vector based scaled fonts

This is done by coping the check / error message code from the Gfx library code used when attempting to path-ify bitmap fonts

The optimal solution would be to implement a way for us to calculate outline paths for bitmap fonts however I wanted to reach out and seek some advice of how useful this would be before perusing this.

Test Case:

<html>
    <style>
        .bitmap {
            background-clip: text;
            background-color: blanchedalmond;
        }
        .vector {
            background-clip: text;
            background-color: blueviolet;
            font-family: "Ubuntu";
        }
    </style>
    <body>
        <div class="bitmap"> this is a test of a bitmap font</div>
        <div class="vector"> this is a test of a vector font</div>
    </body>
</html>

image

1JSIkora avatar May 05 '24 00:05 1JSIkora

Hello!

One or more of the commit messages in this PR do not match the SerenityOS 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.

BuggieBot avatar May 05 '24 00:05 BuggieBot

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!

stale[bot] avatar Jun 02 '24 07:06 stale[bot]

This pull request has been closed because it has not had recent activity. Feel free to re-open if you wish to still contribute these changes. Thank you for your contributions!

stale[bot] avatar Jun 19 '24 02:06 stale[bot]