-
-
Notifications
You must be signed in to change notification settings - Fork 934
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
feat: Aligned text in the TextBoxComponent #1620
Conversation
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
@spydon Please take a look at the failing test, I suspect it might be due to differences between Flutter versions on my machine and in the CI pipeline. |
I would guess that it is due to the classic font rendering problem when using goldens: |
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.
Golden tests involving texts are usually a pitfall because text rendering is influenced by the OS where the test is run, so if we generate a snapshot on linux and then try to run the test on MacOs or windows, there are high possibility that the test will fail.
So IMO we shouldn't use golden tests for these situations.
We can use them, but render boxes instead where the text would have been. |
|
Flutter is already doing this for us: packages/flame/test/_goldens/text_box_component_test_1.png. So the problem here must be something else. There are diff files generated by the test, but I can't see a way to access them from the CI. Could there be an option somewhere to include those files into the archive with the logs? Another approach could be to run the test on another local machine with a different version of Flutter and see if the test succeeds or not. |
Some links still remain broken after flame-engine#1663, as reported by linkcheck. This PR fixes all of them, except these 5: https://examples.flame-engine.org/#/Collision%20Detection_Circles https://examples.flame-engine.org/#/Collision%20Detection_Shapes%20without%20components https://examples.flame-engine.org/#/Collision%20Detection_Multiple%20shapes https://examples.flame-engine.org/#/Rendering_Isometric%20Tile%20Map https://examples.flame-engine.org/#/Controls_Joystick
…ne#1657) As described flame-engine#1546, It would be more convenient and can reduce the game widget updates if adding or removing overlays at once.
…ngine#1659) Make sure that subscription to GameStateChange events is properly updated when the game: property of a GameWidget changes.
changeParent should be allowed even when the current parent is null.
Fix the last remaining broken example links.
This was a planned move once we'd switch to Dart 2.15; and we're already on 2.16 since flame-engine#1617.
…-engine#1675) We were planning to make this change once we upgrade min Dart version to 2.16; which we finally did in flame-engine#1617.
In some places in code we used patterns like fold(0, (a, b) => a + b), which can be replaced with a simple .sum from the Iterable extension.
…lame-engine#1673) These methods can be simplified using the extension Iterable.firstOrNull getter.
Feels a bit like cheating though, since normal fonts aren't tested then (and this will most likely not be the last time we have this problem in the CI). |
I looked at Alchemist documentation, and they say they use Ahem font when rendering in CI, which replaces all glyphs with blocks. However, Flutter itself uses Ahem font for rendering goldens, yet somehow we see a 1-pixel shift. I'm not sure using Alchemist would solve this... There's also the |
I just noticed that all positions have .5 pixels, maybe this wouldn't cause anti-aliasing if the positions were in .0 instead? |
@st-pasha Let's put |
That is the classic Flutter issue, didn't we post that one here? Otherwise I know @erickzanardo has the link to it somewhere, because he has a workaround for it in that issue. |
Here is the issue (Erick digged it up): |
The suggested "workaround" - to change the font smoothing at system global level - would only work on a computer that is dedicated solely to running golden tests and to nothing else. Because in a day-to-day life font smoothing is a very much desirable feature, there is a reason companies invest money in improving it. Of course, ideally, Apple would have an API for rendering a specific string without any antialiasing. But apparently they don't have this, and it's not clear that they ever will (even if they do, we don't want tests that run on some version of OS but not on other, and not everyone can upgrade their OS easily). In view of this, there may be no other option than manual sprite-based fonts. If Alchemist has a work-around, then this is what they must be doing. |
Yeah, sorry I was unclear, I didn't mean that we should use that work around, it was just how I remembered the issue. :)
Indeed, let's investigate that post v1.2.0. |
Yeah, that workaround was something that used to work, but since some time isn't accurate anymore. There is only one workaround that I think is to be trusted. Running golden tests on the same environment as the CI will run them. On a multi platform world, docker would be an alternative for that, but that would render a very bad developer experience IMO.
I am a little bit skeptical about this still, giving the nature of the issue. But I would love to see this in action and would love even more to be proven wrong. Lets try to plan for doing this, even if as a POC for now. |
Description
align
in theTextBoxComponent
which controls the alignment of text.TextBoxComponent
to have a fixed size (before the only mode was for the textbox to automatically expand/shrink to fit the text).Checklist
fix:
,feat:
,docs:
etc).docs
and added dartdoc comments with///
.examples
.Breaking Change
Related Issues
Closes #1088