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

Fix: Support font assets with space in URL #8911

Merged
merged 1 commit into from Nov 30, 2022
Merged

Conversation

SuperSodaSea
Copy link
Member

Description of change

Use encodeURI to escape URL for the constructor of FontFace.

Fixes #8910.

url with space.ttf

The url with space.ttf used in the test is an nearly empty font file generated by the following code:

import fs from 'fs';
import svg2ttf from 'svg2ttf';

const svg = `
<?xml version="1.0" standalone="no"?>
<svg xmlns="http://www.w3.org/2000/svg">
    <metadata>Test</metadata>
    <defs>
        <font id="Test">
            <font-face font-family="Test" units-per-em="1024" ascent="960" descent="-64"/>
            <missing-glyph horiz-adv-x="512" d="M 0 0 L 512 0 L 512 1024 L 0 1024"/>
            <glyph unicode="&#x20;" horiz-adv-x="512" d=""/>
        </font>
    </defs>
</svg>
`;

const ttf = svg2ttf(svg, {
    description: '-',
    url: '-',
});
fs.writeFileSync('output.ttf', ttf.buffer);
Pre-Merge Checklist
  • Tests and/or benchmarks are included
  • Lint process passed (npm run lint)
  • Tests passed (npm run test)

@SuperSodaSea SuperSodaSea added this to the v7.1.0 milestone Nov 30, 2022
Copy link
Member

@GoodBoyDigital GoodBoyDigital left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@bigtimebuddy bigtimebuddy added the ✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t label Nov 30, 2022
@bigtimebuddy bigtimebuddy merged commit 06a9562 into dev Nov 30, 2022
@bigtimebuddy bigtimebuddy deleted the fix/font-url-escape branch November 30, 2022 18:48
@bigtimebuddy
Copy link
Member

Awesome work again, thank you @SuperSodaSea 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✅ Ready To Merge Helpful when issues are in the queue waiting to get merged. This means the PR is completed and has t
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A ttf font with a space in the basename results in an error when loading it with Assets.load()
3 participants