Open yaroslav-kahaniak opened 2 weeks ago
Hey @MitchellGoodwin , Sorry for mentioning you without awaiting validation that the issue reproduces from any member of the Flutter team, but I think this issue is critical and I noticed that you worked on these fonts-related changes, so maybe you could help? https://github.com/flutter/engine/pull/46857 https://github.com/flutter/flutter/pull/137275
Hi @yaroslav-kahaniak, just curious, what version of flutter were you using before you upgraded to 3.19.6? Was this working as expected for you on that version? Is this also only on physical devices or are simulators experiencing this issue as well?
@danagbemava-nc Before the upgrade, the app was using Flutter version 3.3.10. I didn't upgrade the app from v3.3.10 to v3.19.6 in one fell swoop but instead did it piecemeal (3.3.10 -> 3.7.0 -> 3.10.0 -> 3.13.0 -> 3.16.0 -> 3.19.6). The fonts changed after upgrade from v3.7.0 to v3.10.0. Doing further updates to v3.13.0, v3.16.0, v3.19.0 didn't have any impact, so they stayed the same as in v3.10.0.
The app version that was running on Flutter v3.3.10 was using these font family names: SF Pro Display
and SF Pro Text
instead of CupertinoSystemText
and CupertinoSystemDisplay
. Disregarding what I am setting TextStyle.fontFamily
to (CupertinoSystemText/SF Pro Text) when using Flutter v3.10.0 and higher, the font doesn't look the same way it looked before the upgrade.
I always use real device, but have just checked and can confirm that issue reproduces on simulator on Flutter upgrade from v3.7.0 to v3.10.0
Hi @yaroslav-kahaniak, on my iPhone XS running iOS 17.4.1, this is what I see whether or not I set a fallback font family. I'm not particularly familiar with what it looked like earlier, can you share a screenshot of that? Also, what version of iOS are you running?
@danagbemava-nc What font family are you using as a fallback option? Is it font available out of out-of-the-box, or a one that was manually added (FYI: Graphik is not available out-of-the box)? If you are using a manually added font, make sure you added its file into the app assets and declared it in pubspec.yaml. iOS 16.2. You can find it in the first comment of this discussion.
My bad, I forgot to include the font. I tested with roboto and I do see the font change when the fallback font is present.
https://github.com/flutter/flutter/assets/88313112/30d5ba96-398c-4fa4-83f4-5e3dfefc3dab
also cc @jason-simmons, any idea why a hot reload would have any impact on font loading?
As of https://github.com/flutter/engine/commit/0bbb4d61ce82a9b58c9a9cd248d89bf8f7535479 CupertinoSystemText
is handled like any other nonexistent font family.
If the text subsystem can not find a font with that family name, then the font fallback mechanism will select the default system font. But if the text style provides a fontFamilyFallback
list, then font fallback will try to use those families instead.
If CupertinoSystemText
is intended to always map to a system font, then the engine should treat it as a special case similar to CupertinoSystemDisplay
.
From https://github.com/flutter/engine/pull/48937
The registering of "CupertinoSystemText" was removed, as the fallback will correctly show the right fonts, and this logic does not work for the smaller font due to Apple APIs removing the font weight.
cc @MitchellGoodwin
So the fallback we originally had wasn't fully working. I wonder if registering a font with an unspecified weight for small text would work.
Steps to reproduce
Important note: this issue doesn't reproduce for 'CupertinoSystemDisplay'
Expected results
Text style shouldn't change after doing step 2, since the lookup of the CupertinoSystemText should be successful, according to TextStyle documentation:
Actual results
Text style changes, so framework failed to find 'CupertinoSystemText' and picked font family from the fontFamilyFallback instead
Code sample
Code sample
```dart import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return const MaterialApp( title: 'iOS Font Text', home: HomeScreen(), ); } } class HomeScreen extends StatelessWidget { const HomeScreen({super.key}); @override Widget build(BuildContext context) { return const Scaffold( body: Center( child: Text( 'You have pushed the button this many times:', style: TextStyle( fontFamilyFallback: ['Graphik'], fontFamily: 'CupertinoSystemText', ), ), ), ); } } ```Screenshots or Video
Screenshots or Video
With fontFamilyFallback ![with_fallback](https://github.com/flutter/flutter/assets/79097999/a6eb955f-1a00-4892-9352-065b30073f6f) Without fontFamilyFallback ![without_fallback](https://github.com/flutter/flutter/assets/79097999/5bd12049-4578-49f5-868a-616d66241671)Logs
Logs
```console Performing hot restart... [ +3 ms] Scanned through 629 files in 3ms Syncing files to device iPhone Yaroslav... [ +1 ms] <- reset [ ] Compiling dart to kernel with 1 updated files [ ] Processing bundle. [ ] <- recompile package:ios_fonts_test/main.dart 69d8796d-281f-4bcd-acdf-c71ab0a8be88 [ ] package:ios_fonts_test/main.dart [ ] <- 69d8796d-281f-4bcd-acdf-c71ab0a8be88 [ ] Bundle processing done. [ +20 ms] Updating files. [ +381 ms] DevFS: Sync finished [ ] Synced 35.0MB. [ ] <- accept [ +170 ms] Hot restart performed in 578ms. [ ] Restarted application in 580ms. ```Flutter Doctor output
Doctor output
``` [!] Flutter (Channel [user-branch], 3.19.6, on macOS 13.2 22D49 darwin-arm64, locale en-UA) ! Flutter version 3.19.6 on channel [user-branch] at ***path hidden*** Currently on an unknown channel. Run `flutter channel` to switch to an official channel. If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/docs/get-started/install. ! Warning: `dart` on your path resolves to /usr/local/Cellar/dart/2.15.1/libexec/bin/dart, which is not inside your current Flutter SDK checkout at ***path hidden*** Consider adding ***path hidden*** to the front of your path. ! Upstream repository unknown source is not a standard remote. Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error. [!] Android toolchain - develop for Android devices (Android SDK version 30.0.3) ✗ cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. ✗ Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/macos#android-setup for more details. [✓] Xcode - develop for iOS and macOS (Xcode 14.2) [✓] Chrome - develop for the web [✓] Android Studio (version 2022.2) [✓] IntelliJ IDEA Ultimate Edition (version 2022.3.2) [✓] Connected device (3 available) [✓] Network resources ```Device info
Real device (not simulator) iOS 16.2