Skip to content

Add Local Font Access API demo #320

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

Merged
merged 6 commits into from
Jul 4, 2025

Conversation

chrisdavidmills
Copy link
Contributor

The MDN Local Font Access API documentation has several pages that link to this demo hosted on Glitch.

Because Glitch is going away, and the linked demo above doesn't work, I've decided to create my own simple version of it, which is added in this PR.

Note that the Local Font Access API requires HTTPS. It won't work if you test it on localhost. Ironically, I ended up testing it in Glitch, as it is still around for a few more days: https://cat-judicious-hose.glitch.me/ ;-)

@chrisdavidmills chrisdavidmills requested a review from a team as a code owner July 4, 2025 07:33
@chrisdavidmills chrisdavidmills requested review from dipikabh and bsmth and removed request for a team July 4, 2025 07:33
Copy link
Contributor

@dipikabh dipikabh left a comment

Choose a reason for hiding this comment

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

Thanks a lot! It's looking good, just a few nits and a suggestion

Comment on lines +23 to +26
selectElem.selectedIndex = 0;

selectElem.addEventListener("change", applyFont);
applyFont();
Copy link
Contributor

Choose a reason for hiding this comment

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

The first font from the list is getting automatically applied as soon as the local fonts are fetched.
Would it possible to add the first option as a placeholder, something like "--Choose a font--"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not a bad suggestion, but I don't think this is necessary.

@bsmth bsmth removed their request for review July 4, 2025 15:24
chrisdavidmills and others added 4 commits July 4, 2025 17:02
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
Co-authored-by: Dipika Bhattacharya <dipika@foss-community.org>
@chrisdavidmills chrisdavidmills merged commit a7006da into mdn:main Jul 4, 2025
1 check passed
@chrisdavidmills chrisdavidmills deleted the local-font-access-demo branch July 4, 2025 16:09
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