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

CanvasRenderingContext2D needs improved fontStretch property example #20208

Closed
bsmth opened this issue Sep 1, 2022 · 2 comments · Fixed by #20794
Closed

CanvasRenderingContext2D needs improved fontStretch property example #20208

bsmth opened this issue Sep 1, 2022 · 2 comments · Fixed by #20794
Assignees
Labels
Content:WebAPI Web API docs help wanted If you know something about this topic, we would love your help!

Comments

@bsmth
Copy link
Member

bsmth commented Sep 1, 2022

https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fontStretch

This example doesn't show different text renderings to me (in Chrome).
Like in CSS, should a new FontFace be added to the document first?

let ff = new FontFace('myfont', url);
ff.stretch = "condensed";
document.fonts.add(ff);

document.fonts.ready.then(() => {
    ctx.font = '25px myfont';
    ctx.fontStretch = "condensed";
}

Originally posted by @Elchi3 in #19859 (comment)

@bsmth bsmth self-assigned this Sep 1, 2022
@github-actions github-actions bot added Content:CSS Cascading Style Sheets docs needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. and removed Content:CSS Cascading Style Sheets docs labels Sep 1, 2022
@hamishwillee
Copy link
Collaborator

I was still investigating this when the previous issue merged.

The problem is that you can only stretch a variable font that supports stretching. So yes, we do need to add a font that does this.

The ideal would be to load it from the same folder but that isn't supported yet - see mdn/yari#5727 (ideal because then we could steal the font used in the CSS version of this interactive example). Can't load it from github as that results in a cross-side fetch error.

What I have been trying in the meantime is loading from google fonts. However defining a URL that actually provides the required stretchable font hasn't worked. Still trying.

@bsmth
Copy link
Member Author

bsmth commented Sep 2, 2022

OK, I'll leave this one in your court while you try to get it working. Let me know if you'd like to hand it over, happy to pick it up.

@sideshowbarker sideshowbarker added Content:WebAPI Web API docs help wanted If you know something about this topic, we would love your help! and removed needs triage Triage needed by staff and/or partners. Automatically applied when an issue is opened. labels Sep 3, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Content:WebAPI Web API docs help wanted If you know something about this topic, we would love your help!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants