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
Flutter Fonts are not rendering correctly, Antialiasing is doubled on desktop #67034
Comments
Hi @GeniusVentures |
flutter doctor -v[✓] Flutter (Channel unknown, 1.20.0, on Mac OS X 10.14.6 18G87, locale en-US)
• Flutter version 1.20.0 at /thirdparty/flutter
• Framework revision 9d58a87066 (4 months ago), 2020-05-22 22:37:01 -0700
• Engine revision 9ce1e5c5c7
• Dart version 2.9.0 (build 2.9.0-10.0.dev 7706afbcf5)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /SSDevelopment/Development/ThirdParty/Android
• Platform android-30, build-tools 30.0.2
• ANDROID_HOME =/ThirdParty/Android
• Java binary at: /Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_265-b01)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3.1, Build version 11C504
• CocoaPods version 1.9.3
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
[✓] IntelliJ IDEA Ultimate Edition (version 2020.2.2)
• IntelliJ at /Users/<user>/Applications/JetBrains Toolbox/IntelliJ IDEA Ultimate.app
• Flutter plugin version 49.0.4
• Dart plugin version 202.7319.5
[!] VS Code (version 1.49.1)
• 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 (5 available)
• Android SDK built for x86 64 • emulator-5554 • android-x64 • Android 6.0 (API 23) (emulator)
• iPhone 11 Pro Max • 587F01B8-3759-4D54-ACF9-3548CDB943F8 • ios • com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)
• macOS • macOS • darwin-x64 • Mac OS X 10.14.6 18G87
• Web Server • web-server • web-javascript • Flutter Tools
• Chrome • chrome • web-javascript • Google Chrome 85.0.4183.121 Complete project is here: https://github.com/genius-ventures/FontTest, it includes the sketch app file that the code was derived from. All 4 app runs where in Intellij, so there isn't any run command with verbose output, but here's a screen shot of the 4 devices that where launched to show the issues Left to Right ImagesAndroid x86/64 Pixel XL API 23 (looks correct for Antialiasing and possibly kerning), This is a zoom in of the fonts between iPhone X11 and MacOS, showing the double antialiasing on Desktop, hence causing the font to look heavier because of the double sampling. |
Here's the 4 device runs with flutter -v -d <devicename> > <devicename>-verbose.txt macos-verbose.txt |
On the web, when rendering to HTML we don't have much control over this. The behavior is mostly browser-specific. We can control this in the CanvasKit renderer. However, this is not web-specific, so we'll probably go with whatever Flutter+Skia decides for mobile/desktop. |
We should test these fonts look like in Chrome, but not in a Flutter app, on the same platform to see if this is just Skia behavior, or if Flutter is doing something different (and wrong). |
The web is not doubling the antialiasing as far as I could tell. I would focus on the Skia behavior as mentioned. I'm an expert at 3d graphics (wrote my own 3d engine, worked for nVidia for years). I might clone the skia repo and see if I can find the problem. I've fixed a bunch of these in the past with cocos2d-x and other games, so I can probably find and fix it fairly quickly. |
OK, this seems to be a skia issue maybe, and possibly only on OSX, skia is using CoreText to render fonts and not FreeType or other systems like Android, Linux, etc. I looked at the code briefly, but can't get it to compile, but they are probably setting some sort of edge antialiasing or sub-pixel accurate anti-aliasing. Here's the difference between a flutter osx app and another app rendering the same text. You can see the fonts are much thicker looking because of the double anti-aliasing. I guess it should go to the skia folks. |
I have noticed this issue with the slight variation in font rendering sharpness on Windows platform as well. With DomCanvas Web fonts being the most fuzzy version, SKIA fonts on Web CanvasKit next in line, followed by SKIA fonts on Windows desktop and finally just Windows system fonts being the sharpest. If it is of any use and interest I could try to produce some zoomed examples of them all as well. Generally though I am glad the issue is now recognized. The Skia fonts on Web and Windows Desktop are pretty good, almost passable, but the DomCanvas Web font renderings are still imo too fuzzy, they used to be even worse, they are better now than they were in earlier days, but I can still usually tell just by looking at the render of the text if an app running on Windows in a browser was built with DomCanvas or CanvasKit. |
Hey guys, any progress on this? Any ideas? This is a blocker for our project because we need to present a lot of text and the font is rendered very differently to how it looks in other apps on MacOS. We've come across a project that apparently dates back to the experimental days of flutter embedding: https://feather-apps.com/ . If you take a look at the test app there, you can see a typography test. The text is rendered perfectly fine within that app. |
Experiencing the same issue deploying to macOS, and this is definitely a blocker for us. I have tested with a sample application using three variations:
All of the text on screen is notably blurred relative to the same text shown in something like Figma. Here is an example screenshot of the findings below. The first line explains what font is being used, the second is how this font looks in the Flutter application, and the third line is how the equivalent looks in Figma. All of these examples are asset fonts, with the exception of Lato_regular and Roboto_regular, which are from GoogleFonts. Interestingly also, the SF Pro Display text seems to have much different letter spacing (it's using 0.0 in the application, but equates to roughly 6.2% in Figma). |
I am also seeing this on Windows. |
I noticed this when making our fonts Fortunately, we are not deploying to desktop, so it's not a huge problem. |
This issue makes widget tests with golden images useless when not running on the platform the goldens were created on. I.e. |
I've been running into a rendering problem with the Lexend font and our custom icon font in which some things are lighter or bolder. I don't know if it's this problem exactly but if you look at this screen shot, there are two problems: Lexend is rendered lighter (by I guess 50~70 units) on every size, and then our custom font has its engravings rendered lighter if you look which is kinda this issue but feels the oppsite:
|
Any update? same issue on GNU/Linux, the texts are blurred in desktop and mobile versions but works fine in web version. |
Yeah, this bug seems like a pretty great deal. Everything we design eventually gets crushed when coded and all of them get to look broken. |
please fix this, it's a pretty big problem when you face corrupted fonts on different devices. |
So, a very ironic thing. We discovered that while the fonts are usually rendered heavier, on the iPad they are rendered lighter 🙃 So I had to decrease each typeface weight by one hundred units so that when Flutter rendered them wrong, they look like the design we had. Now on iPad they are rendered a hundred units lighter and not heavier :)) thus we having them set a hounded units lighter has resulted our designs to be two hounded units lighter :)))) some of them are becoming invisible to naked eye! I honestly have no idea what should we do here :))) but I'm sure it'll take some huge refactoring. Please do think about something here! |
Is there an update on this? I have a web-app where the fonts look fine on desktop browsers, but looks very different (thinner or bolder) on iOS and Android mobile browsers. Possibly because it uses html renderer on mobile browsers instead of canvas kit? It makes my website looks broken, please help! |
Steps to Reproduce
Use the code below in a widget to render the text in MacOS, Web and compare to Photoshop or Sketch rendering of the text.
Details
Render text with Kerning is not working and rendering system is double sampling antialiasing on fonts on MacOS at least.
Kerning is not working on web rendering either.
The following screen shot shows the difference, the top text is from the Sketch app and rendered at size on a Mac.
The second set of text is rendered in the MacOS APP generated code. My guess is that the TTF font is being rendered with antialiasing to a texture and then the image is placed BLIT'd as a texture also with antialiasing resulting in thicker font. This is pretty clear on the 'our' of 'Your' at the top of each letter and also does not happen with the web renderer. This oversampling causes blurred letters.
The third line of text is the web rendered code and you can see the Kerning is not correct and is ignored but at least the sampling is correct.
Expected results:
All text in the fonts should match layout and kerning.
The text was updated successfully, but these errors were encountered: