-
Notifications
You must be signed in to change notification settings - Fork 309
Experiment with a non-centenary font weight #65
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
Comments
Other notes:
|
Hmm, really? It sounds to me like a non-variable font wouldn't respond to turning a "wght" dial: AIUI, "wght" is an axis that a variable font can optionally declare. Are you thinking Flutter gives us some special "adapter" logic to interpret "wght" for a font that hasn't declared that axis? In a test just now on iOS, I requested the system font "Menlo" and the text didn't visibly change when I changed "wght", including through the specific values 400 and 600. In contrast, I tried bundling the variable font |
The docs did sound that way:
but I'd hoped that was just a matter of emphasizing the use case. Ah well.
Sounds like the experiment is a success, though, so we can close this issue. Thanks for trying it out! |
I think there might be more worth investigating in this area, but then again it could be a small thing. When we request a variable font that supports …Although I don't yet see that result when the Does this seem like a useful area to investigate? |
Sure. I guess the question there is just: if you set
Should be a quick add-on to the experiment you already have handy. |
Hmm. In that experiment, as far as my eye can tell, the glyphs I get are the same as I get if I only set I see that same "threshold" effect when I set I see that same "threshold" effect when I set I see that same "threshold" effect when I set I also see that new "threshold" effect when I set When I set I also see that new "threshold" effect when I set When I set I also see that new "threshold" effect when I set When I set |
IOW the good, hoped-for answer, right? And then it sounds like It seems a bit odd that So it seems like everything looks good for that. Does that sound right to you? |
Yes, that's right. Since I don't understand what's causing the effect, I'm not sure if we'll be safe with a different font that I haven't tested yet 🤷 or if the effect is likely to vary in future Flutter versions, or between Impeller and Skia, iOS and Android, etc. But at least we have this thread that we can follow up on if something seems wrong in the future. By the way I think we don't want to set a |
Cool. There's always the possibility of new problems, but we can deal with those as they arise. I think we've now done the experiment we wanted to do, so there's no longer something for this issue to track.
I agree. That property is supposed to correspond to the weight of what's actually in the font file, so there's no one value that would make sense for it to be set to in the case of a variable font. |
Linking flutter/flutter#33709 just because it has context on support for variable fonts in Flutter. |
For background on our interest in variable fonts, see zulip#65.
For background on our interest in variable fonts with a "wght" axis, see zulip#65. One thing I noticed when adding such a font ('Source Code Pro', in a commit coming soon) is that by default, the text was drawn really lightly; in fact, Flutter seemed to be using the font's lightest weight by default. I guess I'd assumed Flutter would pick a "normal" weight by default, as it does for non-variable fonts. Possibly that's just because Flutter hasn't fully caught up with this recent development in fonts. But also, I'm not sure if these new fonts all *have* mappings from "normal", "bold", etc., to values on their "wght" axes...whether such mappings are standard/predictable, or at least declared by the font in structured metadata. Anyway, in my design here, it means that if you want to use one of these fonts, you still need an incantation (weightVariableTextStyle) to render text where a normal weight makes sense. Hopefully that's not too burdensome, but it comes with a benefit: as long as that's the norm, I think we're unlikely to misuse `fontWeight` to control glyphs that want to be controlled by "wght". Much of the complexity in this commit comes from handling glyphs that need to be rendered in a fallback font that doesn't have a "wght" axis; see clampVariableFontWeight and how we use that. It means those glyphs will have approximately the weight of the other glyphs...not essential, but nice to have. Some complexity comes from extending Flutter's support for the "bold-text" accessibility setting, so that it applies to these new fonts that use "wght". Ideally we wouldn't regress on our support for that platform setting, but in this design, it means callers have to have a BuildContext on hand; hmm.
For background on our interest in variable fonts with a "wght" axis, see zulip#65. One thing I noticed when adding such a font ('Source Code Pro', in a commit coming soon) is that by default, the text was drawn really lightly; in fact, Flutter seemed to be using the font's lightest weight by default. I guess I'd assumed Flutter would pick a "normal" weight by default, as it does for non-variable fonts. Possibly that's just because Flutter hasn't fully caught up with this recent development in fonts. But also, I'm not sure if these new fonts all *have* mappings from "normal", "bold", etc., to values on their "wght" axes...whether such mappings are standard/predictable, or at least declared by the font in structured metadata. Anyway, in my design here, it means that if you want to use one of these fonts, you still need an incantation (weightVariableTextStyle) to render text where a normal weight makes sense. Hopefully that's not too burdensome, but it comes with a benefit: as long as that's the norm, I think we're unlikely to misuse `fontWeight` to control glyphs that want to be controlled by "wght". Much of the complexity in this commit comes from handling glyphs that need to be rendered in a fallback font that doesn't have a "wght" axis; see clampVariableFontWeight and how we use that. It means those glyphs will have approximately the weight of the other glyphs...not essential, but nice to have. Some complexity comes from extending Flutter's support for the "bold-text" accessibility setting, so that it applies to these new fonts that use "wght". Ideally we wouldn't regress on our support for that platform setting, but in this design, it means callers have to have a BuildContext on hand; hmm.
For background on our interest in variable fonts with a "wght" axis, see zulip#65. One thing I noticed when adding such a font ('Source Code Pro', in a commit coming soon) is that by default, the text was drawn really lightly; in fact, Flutter seemed to be using the font's lightest weight by default. I guess I'd assumed Flutter would pick a "normal" weight by default, as it does for non-variable fonts. Possibly that's just because Flutter hasn't fully caught up with this recent development in fonts. But also, I'm not sure if these new fonts all *have* mappings from "normal", "bold", etc., to values on their "wght" axes...whether such mappings are standard/predictable, or at least declared by the font in structured metadata. Anyway, in my design here, it means that if you want to use one of these fonts, you still need an incantation (weightVariableTextStyle) to render text where a normal weight makes sense. Hopefully that's not too burdensome, but it comes with a benefit: as long as that's the norm, I think we're unlikely to misuse `fontWeight` to control glyphs that want to be controlled by "wght". Much of the complexity in this commit comes from handling glyphs that need to be rendered in a fallback font that doesn't have a "wght" axis; see clampVariableFontWeight and how we use that. It means those glyphs will have approximately the weight of the other glyphs...not essential, but nice to have. Some complexity comes from extending Flutter's support for the "bold-text" accessibility setting, so that it applies to these new fonts that use "wght". Ideally we wouldn't regress on our support for that platform setting, but in this design, it means callers have to have a BuildContext on hand; hmm.
For background on our interest in variable fonts with a "wght" axis, see zulip#65. One thing I noticed when adding such a font ('Source Code Pro', in a commit coming soon) is that by default, the text was drawn really lightly; in fact, Flutter seemed to be using the font's lightest weight by default. I guess I'd assumed Flutter would pick a "normal" weight by default, as it does for non-variable fonts. Possibly that's just because Flutter hasn't fully caught up with this recent development in fonts. But also, I'm not sure if these new fonts all *have* mappings from "normal", "bold", etc., to values on their "wght" axes...whether such mappings are standard/predictable, or at least declared by the font in structured metadata. Anyway, in my design here, it means that if you want to use one of these fonts, you still need an incantation (weightVariableTextStyle) to render text where a normal weight makes sense. Hopefully that's not too burdensome, but it comes with a benefit: as long as that's the norm, I think we're unlikely to misuse `fontWeight` to control glyphs that want to be controlled by "wght". Much of the complexity in this commit comes from handling glyphs that need to be rendered in a fallback font that doesn't have a "wght" axis; see clampVariableFontWeight and how we use that. It means those glyphs will have approximately the weight of the other glyphs...not essential, but nice to have. Some complexity comes from extending Flutter's support for the "bold-text" accessibility setting, so that it applies to these new fonts that use "wght". Ideally we wouldn't regress on our support for that platform setting, but in this design, it means callers have to have a BuildContext on hand; hmm.
For background on our interest in variable fonts with a "wght" axis, see zulip#65. One thing I noticed when adding such a font ('Source Code Pro', in a commit coming soon) is that by default, the text was drawn really lightly; in fact, Flutter seemed to be using the font's lightest weight by default. I guess I'd assumed Flutter would pick a "normal" weight by default, as it does for non-variable fonts. Possibly that's just because Flutter hasn't fully caught up with this recent development in fonts. But also, I'm not sure if these new fonts all *have* mappings from "normal", "bold", etc., to values on their "wght" axes...whether such mappings are standard/predictable, or at least declared by the font in structured metadata. Anyway, in my design here, it means that if you want to use one of these fonts, you still need an incantation (weightVariableTextStyle) to render text where a normal weight makes sense. Hopefully that's not too burdensome, but it comes with a benefit: as long as that's the norm, I think we're unlikely to misuse `fontWeight` to control glyphs that want to be controlled by "wght". Much of the complexity in this commit comes from handling glyphs that need to be rendered in a fallback font that doesn't have a "wght" axis; see clampVariableFontWeight and how we use that. It means those glyphs will have approximately the weight of the other glyphs...not essential, but nice to have. Some complexity comes from extending Flutter's support for the "bold-text" accessibility setting, so that it applies to these new fonts that use "wght". Ideally we wouldn't regress on our support for that platform setting, but in this design, it means callers have to have a BuildContext on hand; hmm.
For background on our interest in variable fonts with a "wght" axis, see zulip#65. One thing I noticed when adding such a font ('Source Code Pro', in a commit coming soon) is that by default, the text was drawn really lightly; in fact, Flutter seemed to be using the font's lightest weight by default. I guess I'd assumed Flutter would pick a "normal" weight by default, as it does for non-variable fonts. Possibly that's just because Flutter hasn't fully caught up with this recent development in fonts. But also, I'm not sure if these new fonts all *have* mappings from "normal", "bold", etc., to values on their "wght" axes...whether such mappings are standard/predictable, or at least declared by the font in structured metadata. Anyway, in my design here, it means that if you want to use one of these fonts, you still need an incantation (weightVariableTextStyle) to render text where a normal weight makes sense. Hopefully that's not too burdensome, but it comes with a benefit: as long as that's the norm, I think we're unlikely to misuse `fontWeight` to control glyphs that want to be controlled by "wght". Much of the complexity in this commit comes from handling glyphs that need to be rendered in a fallback font that doesn't have a "wght" axis; see clampVariableFontWeight and how we use that. It means those glyphs will have approximately the weight of the other glyphs...not essential, but nice to have. Some complexity comes from extending Flutter's support for the "bold-text" accessibility setting, so that it applies to these new fonts that use "wght". Ideally we wouldn't regress on our support for that platform setting, but in this design, it means callers have to have a BuildContext on hand; hmm.
Flutter supports specifying what font weight to use for text.
The main API for this,
FontWeight
, provides the weights 100, 200, etc., up to 900. (For exampleFontWeight.normal
is an alias for weight 400, andFontWeight.bold
is 700.)That's plenty for many purposes, but one sometimes wants finer control with a weight like 450 or 550. In particular @terpimost would like to have the design flexibility to use such weights. Some discussion in chat.
It looks like we should be able to accomplish that using
TextStyle.fontVariations
. That allows specifying an arbitrary weight, as a number, by using design axiswght
.So it would be good to try that out and demonstrate that it does indeed work.
In order to successfully carry out the experiment, we'll need a font that has such a weight in the first place. This probably means we'll need:
and specifically to bundle a variable font, like Source Sans 3 VF as seen in the web PR zulip/zulip#24833.
The text was updated successfully, but these errors were encountered: