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

Continue filling in the list of FontFeatures #23730

Merged
merged 1 commit into from
Jan 27, 2021

Conversation

Hixie
Copy link
Contributor

@Hixie Hixie commented Jan 16, 2021

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() (documentation)
  • FontFeature.ordinalForms()
  • FontFeature.proportionalFigures() (documentation)
  • 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() (documentation)

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.

@Hixie
Copy link
Contributor Author

Hixie commented Jan 24, 2021

cc @GaryQian this is the PR that uses those FontFeature diagrams

@Hixie Hixie requested a review from GaryQian January 24, 2021 21:19
this.feature,
[ this.value = 1 ]
) : assert(feature != null), // ignore: unnecessary_null_comparison
assert(feature.length == 4, 'Feature tag must be exactly four characters long.'),
Copy link
Contributor

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.

Copy link
Contributor Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

Just messages

Copy link
Contributor

@dnfield dnfield left a 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...
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// could be demonstrated...
// could be demonstrated.

Copy link
Contributor

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)

Copy link
Contributor Author

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>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// * <https://docs.microsoft.com/en-us/typography/opentype/spec/features_ae#calt>
/// * <https://docs.microsoft.com/en-us/typography/opentype/spec/features_pt#swsh>

Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

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).
Copy link
Contributor

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.

Copy link
Contributor Author

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)';
Copy link
Contributor

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.

Copy link
Contributor Author

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.

@@ -115,7 +127,7 @@ class FontFeature {
int get hashCode => hashValues(feature, value);

@override
String toString() => 'FontFeature($feature, $value)';
String toString() => 'FontFeature(\'$feature\', $value)';
Copy link
Contributor

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.
@Hixie
Copy link
Contributor Author

Hixie commented Jan 26, 2021

Thanks for the review; applied all suggested changes. Will land on green.

@dnfield dnfield added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Jan 27, 2021
@fluttergithubbot
Copy link
Contributor

This pull request is not suitable for automatic merging in its current state.

  • The status or check suite Mac Host Engine has failed. Please fix the issues identified (or deflake) before re-applying this label.
  • The status or check suite Mac Web Engine has failed. Please fix the issues identified (or deflake) before re-applying this label.

@fluttergithubbot fluttergithubbot removed the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Jan 27, 2021
@Hixie Hixie added the waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land. label Jan 27, 2021
@fluttergithubbot fluttergithubbot merged commit 0540bc8 into flutter:master Jan 27, 2021
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jan 27, 2021
hjfreyer pushed a commit to hjfreyer/engine that referenced this pull request Mar 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes waiting for tree to go green This PR is approved and tested, but waiting for the tree to be green to land.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants