This repository was archived by the owner on Feb 25, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6k
[Web] Draw tab characters as single space #36107
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
loic-sharma
commented
Sep 12, 2022
| } | ||
| } | ||
| return true; | ||
| } |
Member
Author
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a copy of:
engine/testing/dart/canvas_test.dart
Lines 116 to 133 in 3cfc77d
| /// @returns true When the images are reasonably similar. | |
| /// @todo Make the search actually fuzzy to a certain degree. | |
| Future<bool> fuzzyCompareImages(Image golden, Image img) async { | |
| if (golden.width != img.width || golden.height != img.height) { | |
| return false; | |
| } | |
| int getPixel(ByteData data, int x, int y) => data.getUint32((x + y * golden.width) * 4); | |
| final ByteData goldenData = (await golden.toByteData())!; | |
| final ByteData imgData = (await img.toByteData())!; | |
| for (int y = 0; y < golden.height; y++) { | |
| for (int x = 0; x < golden.width; x++) { | |
| if (getPixel(goldenData, x, y) != getPixel(imgData, x, y)) { | |
| return false; | |
| } | |
| } | |
| } | |
| return true; | |
| } |
Please let me know if there's a way to deduplicate this by sharing code between lib/web_ui and testing/dart!
mdebbar
approved these changes
Sep 13, 2022
harryterkelsen
approved these changes
Sep 14, 2022
Contributor
harryterkelsen
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Do you know if replaceTabCharacters will use the font's tab glyph if one is available? Or does it do the replacement no matter what?
Member
Author
|
@hterkelsen It'll do the replacement no matter what, which is consistent with how the other platforms work now. |
engine-flutter-autoroll
added a commit
to engine-flutter-autoroll/flutter
that referenced
this pull request
Sep 14, 2022
Oleh-Sv
pushed a commit
to Oleh-Sv/engine
that referenced
this pull request
Sep 28, 2022
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
autosubmit
Merge PR when tree becomes green via auto submit App
platform-web
Code specifically for the web engine
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This change makes Flutter web render tabs as a single space. Previously, tabs rendered differently depending on your platform:
This change was tested on this repro...
Here was the tab tofu fix for Windows: #34389
Part of flutter/flutter#79153.
Background
Most fonts don't have a glyph for
\t, so the "unknown" glyph should be selected and a tofu should be drawn. However, some platforms will override this using their own platform-specific logic and select the glyph for a single space instead. For more information, see: https://bugs.chromium.org/p/skia/issues/detail?id=12334Skia added a feature to substitute tabs with a single space so that platforms could behave consistently. This feature was added to CanvasKit in version 0.37.0 (skia#574296). This change enables this new feature on Flutter web, thereby making tabs no longer render as a tofu.
Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.