Repository navigation
Conversation
Renzo-Olivares
left a comment
There was a problem hiding this comment.
Hi @koji-1009, thank you for your patience on this one! Overall this LGTM with a small comment about computeDryBaseline.
I'm curious if this also fixes related issues like #96713 and #94680
Another note is that RenderEditable does not have its similar methods hard-coded to alphabetic.
| // property when the ideographic baseline is properly implemented | ||
| // (https://github.com/flutter/flutter/issues/22625). | ||
| return _textPainter.computeDistanceToActualBaseline(TextBaseline.alphabetic); | ||
| return _textPainter.computeDistanceToActualBaseline(baseline); |
There was a problem hiding this comment.
Looks like this was also hard-coded in computeDryBaseline we should change that as well and add a test to verify its behavior.
|
#94680 has been fixed, I believe.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(title: 'Flutter Demo', home: const MyHomePage());
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Row(
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic,
children: const [
Text('ABCDefgh 漢字漢字漢字'),
Text('ABCDefg 漢字', style: TextStyle(fontSize: 20)),
],
),
),
);
}
} |
|
It does not appear to affect #96713.
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(),
body: Padding(
padding: const .all(16),
child: Column(
children: [
..._buildOne(leadingDistribution: null),
..._buildOne(leadingDistribution: .proportional),
],
),
),
),
);
}
List<Widget> _buildOne({
required TextLeadingDistribution? leadingDistribution,
}) {
return [
Text('leadingDistribution=${leadingDistribution?.name}'),
const SizedBox(height: 32),
for (final text in ['探索文本工王田一二三四口', 'ABCijk123', '探索文本工王田一二三四口ABCijk123'])
Container(
color: Colors.orange[200],
margin: const .only(bottom: 32),
child: Text(
text,
style: TextStyle(
fontSize: 24,
height: 1,
leadingDistribution: leadingDistribution,
),
),
),
];
}
} |
|
Regarding text centering, this is a problem that can be seen by the naked eye, and it will appear everywhere, hoping to be solved. https://github.com/flutter/flutter/issues/96713 |
|
@Renzo-Olivares The In Additionally, |
|
Hi @Renzo-Olivares, friendly ping on this one. I've addressed your review comment — added the fix for |
There was a problem hiding this comment.
LGTM, thank you for the patience on this one @koji-1009 and for the amazing contribution! I'm happy we are cleaning this up! Also for more context the original issue that was worked around by always using alphabetic baseline is still fixed after this change #25782.
We still need a secondary review and i'm also curious how google testing will do.
Can you please rebase to the latest master commit when you get a chance.
|
Google testing is failing because a user was explicitly setting baseline for their row to |
|
Going to rebase to re-trigger Google testing here and see if we can move this forward to land. |
LongCatIsLooong
left a comment
There was a problem hiding this comment.
The changes LGTM except for a few nits.
The screenshot (thank you for providing one!) of the ideo-baseline-aligned row surprised me since the text within each RenderParagraph isn't properly aligned. I guess skparagraph also needs to be told which baseline to use. Just curious is .ideographic useful at all if skparagraph only uses latin baselines? Do you have to manually separate ideographs in a document into dedicated paragraphs to work around this?
| expect(alphabetic, isNot(equals(ideographic))); | ||
| expect(ideographic, greaterThan(alphabetic)); | ||
|
|
||
| // Verify that the ideographic baseline is correctly calculated based on |
There was a problem hiding this comment.
FYI I don't think these tests do anything, the test font only has DFLT baseline IIRC: https://github.com/flutter/flutter/blob/master/docs/contributing/testing/Flutter-Test-Fonts.md
There was a problem hiding this comment.
Changed the test text to 一二三 in d72335e. Thanks!
There was a problem hiding this comment.
Still it's unlikely these tests are going to behave any differently from the tests you added above (it doesn't matter what script each glyph comes from, because the test font use the same baseline for all scripts IIRC). I think it's safe to delete the CJK and mixed text tests, but it's just a nit, not blocking.
There was a problem hiding this comment.
Thanks for the clarification! I added those tests thinking the CJK/latin interaction could be tricky, but you're right — given the test font, they were redundant. Removed them in 0cf58ae.
| ); | ||
| layout(paragraph); | ||
|
|
||
| double alphabetic = paragraph.computeDistanceToActualBaseline(TextBaseline.alphabetic); |
There was a problem hiding this comment.
Also you can hard code the baseline values. alphabetic should be 7.5 and ideographic should be 10.
| if (_isBaselineAligned) { | ||
| // If this Flex is baseline aligned, and the caller is asking for the same baseline | ||
| // as the alignment baseline, then we can just return the baseline offset we calculated | ||
| // during layout. |
There was a problem hiding this comment.
nit: during layout -> using _computeSizes.
e28cb0f
|
Discussed with @Renzo-Olivares offline: I don't think skparagraph is using the baseline anywhere so that probably means setting this in |
|
I suspect this by itself does not close #22625 because skparagraph isn't respecting I tried specifying @Rusino it looks like skparagraph isn't using |
|
Edited to mark #94680 as a partial fix, as we don't think we should close that with this PR until baseline configuration is supported in Skia too. |
|
Looks like this is still failing as of last week. 😞 |
|
@koji-1009 Thanks for the patience with this one. There's an associated g3fix but I have not requested approval from the roller yet. Our current plan to move forward with this PR is to investigate adding ideographic baseline support to SkParagraph before we move forward with landing this. This way we don't break google testing twice and the fix is fully robust. As it stands |
|
Greetings from stale triage, is this one still on hold for now? Should we mark it a draft in the meantime? |
|
@Piinks Yeah I think for now I'll mark it as draft until I can take a deeper look at the changes necessary. |













partial fix for #22625
partial fix #94680
The latest code shows that the implementation has been updated to call Skia's
GetIdeographicBaseline.https://github.com/flutter/flutter/blob/3.38.5/engine/src/flutter/lib/ui/text/paragraph.cc#L54
Skia's implementation was updated several years ago to use the calculation formula
fDescent - fAscent + fLeading;.https://github.com/google/skia/blob/33c2d9840f4e61e121c95a19ec7a0eb3bd2356a3/modules/skparagraph/src/Run.h#L496
Screenshot
Pre-launch Checklist
///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.