Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 - add missing properties #19859
CanvasRenderingContext2D - add missing properties #19859
Changes from all commits
31e72bb
873b007
abc0104
9f41882
3baddde
f01e1ca
c52b086
7f77636
02a1a7e
e0dbbf0
5025cf8
1bfadb2
e4509dd
cd28549
12fafea
6b1cc30
37595a5
ebaaa4b
6139bf6
0036577
f7a0e42
909fb7a
b702497
adc0928
cf97f92
293655d
9b31909
d1af047
a3ba79d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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";
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @Elchi3
Yes, clearly the default font is not a variable font, so this can't work. So yes we need to add a font. Unfortunately I am completely stumped as to how to do this in a live example (and I think it is worth doing in a live example).
I tried having the font in the same folder as the docs but I get 404 errors (it isn't served). I tried using links from the interactive examples, but they fail with CORS errors.
The "best" way to do this would be to use a CDN served font with appropriate allow headers. I tried this with fonts.gstatic.com but I can't find a woff file that contains variable fonts. For example, this doesn't vary:
What I'd like to do, because I think it would be generally useful, is use the google font API with the font loading API. However passing in the URLs suggested for CSS just gives you link parsing errors.
Any ideas?
PS Our CSS Font loading API docs are "very thin". Not enough examples, and some may be incorrect - for example https://developer.mozilla.org/en-US/docs/Web/API/FontFace/load looks to me to not be adding the font to the document, and I think that is a precondition.
In general it isn't clear what you need to do - I THINK you load() the font, wait for it to complete, then add it to the document and wait for it to be ready, but none of that is demonstrated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Elchi3 So I think we're good except for fontstretch, on which I am stumped for the above reasons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bsmth See these messages above^
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, tracking this improvement in #20208
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re: using fancy fonts in live samples, please see mdn/yari#5727.