-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
Continue filling in the list of FontFeatures #23730
Conversation
8dbb697
to
c346cc5
Compare
cc @GaryQian this is the PR that uses those FontFeature diagrams |
this.feature, | ||
[ this.value = 1 ] | ||
) : assert(feature != null), // ignore: unnecessary_null_comparison | ||
assert(feature.length == 4, 'Feature tag must be exactly four characters long.'), |
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.
These are nice to add, but I'm pretty sure they just show up as <optimized out>
to users when thrown from dart:ui. I'm not sure why and whether that's on us or on Dart, or what the cost of fixing it would be.
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.
Is it the messages or the expressions that are optimized out? Any idea?
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.
Just messages
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.
I just learned so much about font features.
This LGTM - the only non-nit in here is the incorrect link for swsh
lib/ui/text.dart
Outdated
// Features listed below are those we deemed "interesting enough" to | ||
// have their own constructor, mostly on the basis of whether we | ||
// could find a font where the feature had a useful effect that | ||
// could be 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.
// could be demonstrated... | |
// could be 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.
(alternatively, ....
, but I don't see a good reason to trail off here)
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.
haha that was literally me trailing off when explaining my dubious criteria for inclusion :-)
fixed
lib/ui/text.dart
Outdated
/// | ||
/// See also: | ||
/// | ||
/// * <https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#pnum> | ||
const FontFeature.proportionalFigures() : feature = 'pnum', value = 1; | ||
/// * <https://docs.microsoft.com/en-us/typography/opentype/spec/features_ae#calt> |
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.
/// * <https://docs.microsoft.com/en-us/typography/opentype/spec/features_ae#calt> | |
/// * <https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#swsh> |
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.
good catch!
lib/ui/text.dart
Outdated
// swsh | ||
/// Enable swash glyphs. (`swsh`) | ||
/// | ||
/// Some fonts have beautiful flourishes on some characters. This |
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.
Can we be a little more descriptive on this line? Beautiful flourishes sounds nice but a bit vague. The image really helps me here (and elsewhere too, they're great!), but maybe we could describe this as something like This feature, when enabled, draws flourishes that continue the ending stroke of a letter.
? I'm not sure if it applies to beginning as well though.
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.
I've added more text explaining the concept, and a link to wikipedia.
lib/ui/text.dart
Outdated
final String feature; | ||
|
||
/// The value assigned to this feature. | ||
/// | ||
/// Must be a positive integer. Many features are Boolean values that accept | ||
/// Must be a positive integer. Many features are Boolean values that accept | ||
/// values of either 0 (feature is disabled) or 1 (feature is enabled). |
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.
nit: might want to mention here that other features use a bound range of acceptable values, and they're documented here for the ones we document or elsewhere for the ones we don't.
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.
added more color
lib/ui/text.dart
Outdated
@@ -312,7 +1431,7 @@ class FontFeature { | |||
int get hashCode => hashValues(feature, value); | |||
|
|||
@override | |||
String toString() => 'FontFeature($feature, $value)'; | |||
String toString() => 'FontFeature(\'$feature\', $value)'; |
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.
nit: consider either double quoting the outer or inner string rather than escaping.
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.
changed outer quotes to "
.
I'm pretty mixed on this. I kinda like the consistency of always using '
, and don't mind the \
so much. I find it confusing to have mixed quoting styles and it gets particularly annoying when dealing with copy/paste. But I also like avoiding escapes to some extent, it does look a bit cleaner. I dunno.
lib/web_ui/lib/src/ui/text.dart
Outdated
@@ -115,7 +127,7 @@ class FontFeature { | |||
int get hashCode => hashValues(feature, value); | |||
|
|||
@override | |||
String toString() => 'FontFeature($feature, $value)'; | |||
String toString() => 'FontFeature(\'$feature\', $value)'; |
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.
ditto (nit)
This adds support and documentation for: * FontFeature.alternative(n) * FontFeature.alternativeFractions() * FontFeature.contextualAlternates() * FontFeature.caseSensitiveForms() * FontFeature.characterVariant(v) * FontFeature.denominator() * FontFeature.fractions() * FontFeature.historicalForms() * FontFeature.historicalLigatures() * FontFeature.liningFigures() * FontFeature.localeAware(enable: false) * FontFeature.notationalForms(v) * FontFeature.numerators() * FontFeature.oldstyleFigures() * FontFeature.ordinalForms() * FontFeature.proportionalFigures() * FontFeature.randomize() (minor additions to documentation) * FontFeature.stylisticAlternates() * FontFeature.scientificInferiors() * FontFeature.stylisticSet(n) (documentation) * FontFeature.subscripts() * FontFeature.superscripts() * FontFeature.swash(v) * FontFeature.tabularFigures() (documentation) * FontFeature.slashedZero() There's hundreds more we could add but this is what I have so far. See flutter/assets-for-api-docs#131 for the diagrams.
Thanks for the review; applied all suggested changes. Will land on green. |
This pull request is not suitable for automatic merging in its current state.
|
This adds support and documentation for:
There's hundreds more we could add but this is what I have so far.
See flutter/assets-for-api-docs#131 for the diagrams.