8000 Text loses color on iPhone XR, 8, SE, 6 and 5s · Issue #24234 · flutter/flutter · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Text loses color on iPhone XR, 8, SE, 6 8000 and 5s #24234

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

Closed
MarcL01 opened this issue Nov 12, 2018 · 10 comments
Closed

Text loses color on iPhone XR, 8, SE, 6 and 5s #24234

MarcL01 opened this issue Nov 12, 2018 · 10 comments
Labels
a: assets Packaging, accessing, or using assets dependency: skia Skia team may need to help us e: device-specific Only manifests on certain devices engine flutter/engine repository. See also e: labels. found in release: 1.24 Found to occur in 1.24 has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list platform-ios iOS applications specifically r: fixed Issue is closed as already fixed in a newer version team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team

Comments

@MarcL01
Copy link
MarcL01 commented Nov 12, 2018

Originally I came across this using flutter run -d all to view how the app looked on multiple devices, and I realized when I lowered the font weight that the text turned black on the iPhone SE. I then ran the app on only iPhone SE through IntelliJ and it yielded the same results (meaning it had nothing to do with it running on multiple devices at once). I got rid of the SizedBox and the same thing happened.

Font weight 500:

screen shot 2018-11-11 at 8 00 24 pm

Font weight 900:

screen shot 2018-11-11 at 8 01 27 pm

Maybe it was just the iPhone SE? Nope:
screen shot 2018-11-11 at 8 08 14 pm

At this point I said heck with it and launched all of them:
screen shot 2018-11-11 at 8 20 19 pm

5s, 6, SE, 8 and XR all showed the text in black.
XS Max, XS, X, 8 Plus and 7 Plus all showed the text correctly.

Steps to Reproduce

SizedBox(
  width: double.infinity,
    child: Text(
      "“",
      style: TextStyle(
        color: Color(0xFFE971).withOpacity(1.0),
        fontSize: 120.0,
        fontFamily: "Source Code Variable",
        fontWeight: FontWeight.w300,
      ),
      textAlign: TextAlign.left,
   ),
),
  1. Use Source Code Variable Roman font (https://github.com/adobe-fonts/source-code-pro/releases)
  2. Use a font weight below 600 (600, 700, 800, 900 all have the correct color) or not including a font weight yields same result. I don't believe there is anything wrong with the font because it displays perfectly with all font weights on the iPhone XS Max and iPhone 8 Plus.
  3. Use the code above

flutter analyze

Analyzing quotee...                                              

   info • The value of the local variable 'prefs' isn't used • lib/main.dart:13:21 • unused_local_variable
   info • Name non-constant identifiers using lowerCamelCase • lib/main.dart:18:22 • non_constant_identifier_names
   info • Name non-constant identifiers using lowerCamelCase • lib/main.dart:19:22 • non_constant_identifier_names
   info • Name non-constant identifiers using lowerCamelCase • lib/main.dart:20:22 • non_constant_identifier_names
   info • Name non-constant identifiers using lowerCamelCase • lib/main.dart:21:22 • non_constant_identifier_names
   info • Name non-constant identifiers using lowerCamelCase • lib/main.dart:22:22 • non_constant_identifier_names
   info • Name non-constant identifiers using lowerCamelCase • lib/main.dart:23:22 • non_constant_identifier_names
   info • Name non-constant identifiers using lowerCamelCase • lib/main.dart:24:22 • non_constant_identifier_names
   info • Name non-constant identifiers using lowerCamelCase • lib/main.dart:27:17 • non_constant_identifier_names

9 issues found. (ran in 1.6s)

flutter doctor -v

[✓] Flutter (Channel master, v0.11.4-pre.5, on Mac OS X 10.14 18A391, locale en-US)
    • Flutter version 0.11.4-pre.5 at /Users/bigmarco/Repositories/flutter
    • Framework revision 70c6fb1fbb (7 hours ago), 2018-11-11 10:57:41 -0800
    • Engine revision 5646e86a6f
    • Dart version 2.1.0 (build 2.1.0-dev.9.3 9c07fb64c4)

[✓] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at /Users/bigmarco/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    • All Android licenses accepted.

[✓] iOS toolchain - develop for iOS devices (Xcode 10.0)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.0, Build version 10A255
    • ios-deploy 2.0.0
    • CocoaPods version 1.5.3

[✓] Android Studio (version 3.2)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 29.1.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] IntelliJ IDEA Ultimate Edition (version 2018.2.4)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 29.1.3
    • Dart plugin version 182.4323.44

[!] VS Code (version 1.28.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension not installed; install from
      https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (1 available)
    • iPhone SE • 42E5E469-59CA-4858-8F53-02A8400257BB • ios • iOS 12.0 (simulator)

! Doctor found issues in 1 category.
@MarcL01 MarcL01 changed the title Text loses color on iPhone SE Text loses color on iPhone XR, 8, SE, 6 and 5s Nov 12, 2018
@zoechi
Copy link
Contributor
zoechi commented Nov 12, 2018

The issue is the quote (in case someone else has to look 2 minutes to see it :D )

image
vs
image

@zoechi zoechi added e: device-specific Only manifests on certain devices platform-ios iOS applications specifically engine flutter/engine repository. See also e: labels. dependency: skia Skia team may need to help us labels Nov 12, 2018
@zoechi zoechi added this to the Goals milestone Nov 12, 2018
@xster
Copy link
Member
xster commented Nov 12, 2018

@GaryQian may know

@GaryQian
Copy link
Contributor

So the way font weight resolution works is that if a requested weight is not available, it will either try to fake-bold it by extending the edges or use the closest available weight font.

Here are a few ideas that may or may not be applicable:

One possible idea is that since this is dependent on the weighting of the font, could it be that not all of the available weights of the font have been included? The source code Roman font defines Black, Bold, ExtraLight, Light, Medium, Regular, and SemiBold. That seems consistent with most well-defined font families.

However, it seems that you are able to find the correct glyph, which indicates the correct character was found, but somehow it failed to render in the right color. The black color could possibly come from another TextStyle overlaid on top of the one defined. In the libTxt code, TextStyles stack on top of each other, with properties defined by upper layers overriding the ones below.

Regarding it only happening on certain devices, it is within the realm of possibility that certain devices ship with different fonts, and that it is font-availability based (we have seen this with Samsung devices) but I think it is less likely with iOS.

Those are just some early exploratory thoughts on the issue.

@MarcL01
Copy link
Author
MarcL01 commented Nov 12, 2018

A idea I had was that it might be caused by the resolution, so I mapped out the resolution and screen size of each device but there seemed to be no pattern:
screen shot 2018-11-12 at 5 34 36 pm
Then I thought maybe it was font size and or just that specific character so I added some more words to it and decreased the size (this yielded the same result with black text):
screen shot 2018-11-12 at 5 31 24 pm

A new idea/question I have is if flutter is able to read multiple font styles front 1 font file. Normally you import a font with multiple assets and set the font weight for each asset but in this case all of the styles are in 1 file. I am going to experiment with other fonts that do not have their styles divided into separate files and share my findings here.

@MarcL01
Copy link
Author
MarcL01 commented Nov 13, 2018

Alright so I tried using the OTF file provided from the releases but that crashed the app. However, I converted the old TTF font file to OTF using https://convertio.co/ttf-otf/ and added it to the assets and now it works but only displays 2 styles even though there should be a bunch more. The issue comes down to how flutter reads multiple styles from a single font file, to fix this I downloaded the font into multiple TTF files separated by style and imported each with the appropriate font weight. This is something that can be fixed in the far future when flutter is in release as it is not an immediate issue in beta therefore you guys can close this unless you want to keep it open for a future goal.

@GaryQian
Copy link
Contributor

@jason-simmons @goderbauer You guys might have some insight on the font-loading aspect of this bug. Thanks @littlemarc2011 for figuring this out, that looks like some good information to go off of!

@XHL-study
Copy link
XHL-study commented Dec 20, 2018

@jason-simmons @goderbauer You guys might have some insight on the font-loading aspect of this bug. Thanks @littlemarc2011 for figuring this out, that looks like some good information to go off of!

@zoechi @GaryQian
I have some new discoveries.
#25358

image

image

new Text.rich(new TextSpan(
                    text: AliIcons.select_string + "sdsdd英文不sdsdd显示啊",
                    style: new TextStyle(fontFamily: '',background: new Paint()..color=Colors.green),
                    children: [new TextSpan(text: "ddd的english这里有一段",style: TextStyle(fontFamily: 'xdxwzxxbx',background: new Paint()..color=Colors.deepOrange))]))

image

image

@kf6gpe kf6gpe added the P2 Important issues not at the top of the work list label May 29, 2020
@Hixie Hixie removed this from the None. milestone Aug 17, 2020
@TahaTesser
Copy link
Member

I can reproduce using w300 and w900, on these simulators

Font
https://github.com/adobe-fonts/source-code-pro/releases

complete code sample
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Material App',
      theme: ThemeData.dark(),
      home: Home(),
    );
  }
}

class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Material App Bar'),
      ),
      body: Center(
        child: SizedBox(
          width: double.infinity,
          child: Text(
            "“",
            style: TextStyle(
              color: Color(0xFFE971).withOpacity(1.0),
              fontSize: 120.0,
              fontFamily: "SourceCodeVariable",
              fontWeight: FontWeight.w900,
            ),
            textAlign: TextAlign.left,
          ),
        ),
      ),
      floatingActionButton: FloatingActionButton(
        child: Icon(Icons.add),
        onPressed: () {},
      ),
    );
  }
}
  fonts:
    - family: SourceCodeVariable
      fonts:
        - asset: fonts/SourceCodeVariable-Italic.ttf
        - asset: fonts/SourceCodeVariable-Roman.ttf
flutter doctor -v
[✓] Flutter (Channel master, 1.24.0-4.0.pre.33, on Mac OS X 10.15.7 19H2
    darwin-x64, locale en-GB)
    • Flutter version 1.24.0-4.0.pre.33 at /Users/tahatesser/Code/flutter_master
    • Framework revision 351ccf7eaf (5 hours ago), 2020-10-22 23:28:51 -0700
    • Engine revision defa8be2b1
    • Dart version 2.11.0 (build 2.11.0-242.0.dev)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/tahatesser/Code/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Users/tahates
8000
ser/Code/sdk
    • Java binary at: /Applications/Android
      Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.1, Build version 12A7403
    • CocoaPods version 1.10.0.rc.1

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.50.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.15.1

[✓] Connected device (4 available)
    • Taha’s iPhone (mobile) • 00008020-001059882212002E • ios            • iOS
      14.1
    • macOS (desktop)        • macos                     • darwin-x64     • Mac
      OS X 10.15.7 19H2 darwin-x64
    • Web Server (web)       • web-server                • web-javascript •
      Flutter Tools
    • Chrome (web)           • chrome                    • web-javascript •
      Google Chrome 86.0.4240.111

• No issues found!

@TahaTesser TahaTesser added found in release: 1.24 Found to occur in 1.24 has reproducible steps The issue has been confirmed reproducible and is ready to work on labels Oct 23, 2020
@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team labels Jul 7, 2023
@darshankawar
Copy link
Member

Verified this issue using the code sample provided + mentioned custom font and ran on below iOS simulators with latest stable version and confirmed that the text is now rendered properly with the color as shown below:

Screenshot 2023-09-29 at 6 11 44 PM Screenshot 2023-09-29 at 6 12 38 PM Screenshot 2023-09-29 at 6 13 34 PM Screenshot 2023-09-29 at 6 14 50 PM Screenshot 2023-09-29 at 6 17 44 PM

Based on above verification, I think it is safe to close this issue as fixed, since there have been lot of updates to the framework since the issue was filed and last triaged. If anybody disagrees or still seeing the same issue using latest version, file a new issue with relevant details.

@darshankawar darshankawar added the r: fixed Issue is closed as already fixed in a newer version label Sep 29, 2023
@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: assets Packaging, accessing, or using assets dependency: skia Skia team may need to help us e: device-specific Only manifests on certain devices engine flutter/engine repository. See also e: labels. found in release: 1.24 Found to occur in 1.24 has reproducible steps The issue has been confirmed reproducible and is ready to work on P2 Important issues not at the top of the work list platform-ios iOS applications specifically r: fixed Issue is closed as already fixed in a newer version team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team
Projects
None yet
Development

No branches or pull requests

9 participants
0