Refactor to use Apple system fonts (#137275)

Addresses #63507, and is a follow up to the engine PR https://github.com/flutter/engine/pull/46857

Changes the font family string when attempting to use Apple system fonts to the new proxies added by the engine. For the "Text" font this will be more secure in the future against possible changes to Apple's API. For the "Display" font, this will now work correctly when it didn't before.

I checked the letter spacing values against a native app for all font sizes between 17-28. I made a few adjustments to better match native, but especially for the "Text" font we were either really close, or close enough to not make a large breaking change to default fonts worth it.

| Before  | After |
| ------------- | ------------- |
| <img width="466" alt="Screenshot 2023-11-02 at 11 45 12 AM" src="https://github.com/flutter/flutter/assets/58190796/627ed8ac-d848-4f71-aa62-a467b8aac62d"> | <img width="383" alt="Screenshot 2023-11-02 at 11 46 25 AM" src="https://github.com/flutter/flutter/assets/58190796/9a502021-7d2b-4e14-98f1-86971b3830a5"> |

The smaller text in both the before and after should be the same. The large system font that Flutter used before was incorrect, which caused it to look more spread out. Now we use the correct font.
This commit is contained in:
Mitchell Goodwin
2023-11-29 13:03:32 -08:00
committed by GitHub
parent 4f8a99147a
commit e84f1296ac
13 changed files with 99 additions and 82 deletions

View File

@@ -153,7 +153,7 @@ class _CupertinoTextFieldDemoState extends State<CupertinoTextFieldDemo> {
Widget build(BuildContext context) {
return DefaultTextStyle(
style: const TextStyle(
fontFamily: '.SF UI Text',
fontFamily: 'CupertinoSystemText',
inherit: false,
fontSize: 17.0,
color: CupertinoColors.black,