Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Simplify RenderParagraph ideographic baseline tests
  • Loading branch information
koji-1009 committed Apr 23, 2026
commit 0cf58ae57542740142f61d2490c8b67c37ac210b
62 changes: 10 additions & 52 deletions packages/flutter/test/rendering/paragraph_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1509,60 +1509,18 @@ void main() {
semanticsHandle.dispose();
});

group('RenderParagraph ideographic baseline', () {
test('latin text', () {
// Even without CJK characters, the ideographic baseline (bottom of the line)
// should be distinct from the alphabetic baseline.
final paragraph = RenderParagraph(
const TextSpan(text: 'Hello world', style: TextStyle(fontSize: 10.0)),
textDirection: TextDirection.ltr,
);
layout(paragraph);

final double alphabetic = paragraph.computeDistanceToActualBaseline(TextBaseline.alphabetic);
final double ideographic = paragraph.computeDistanceToActualBaseline(
TextBaseline.ideographic,
);

expect(alphabetic, 7.5);
expect(ideographic, 10.0);
});

test('CJK text', () {
// Verify that the ideographic baseline is correctly calculated based on
// CJK font metrics.
final paragraph = RenderParagraph(
const TextSpan(text: '一二三', style: TextStyle(fontSize: 10.0)),
textDirection: TextDirection.ltr,
);
layout(paragraph);

final double alphabetic = paragraph.computeDistanceToActualBaseline(TextBaseline.alphabetic);
final double ideographic = paragraph.computeDistanceToActualBaseline(
TextBaseline.ideographic,
);

expect(alphabetic, 7.5);
expect(ideographic, 10.0);
});

test('mixed text', () {
// Verify that the baseline calculation correctly handles mixed fonts,
// extending the metrics to cover both.
final paragraph = RenderParagraph(
const TextSpan(text: 'Hello world 一二三', style: TextStyle(fontSize: 10.0)),
textDirection: TextDirection.ltr,
);
layout(paragraph);
test('RenderParagraph ideographic baseline', () {
final paragraph = RenderParagraph(
const TextSpan(text: 'Hello world', style: TextStyle(fontSize: 10.0)),
textDirection: TextDirection.ltr,
);
layout(paragraph);

final double alphabetic = paragraph.computeDistanceToActualBaseline(TextBaseline.alphabetic);
final double ideographic = paragraph.computeDistanceToActualBaseline(
TextBaseline.ideographic,
);
final double alphabetic = paragraph.computeDistanceToActualBaseline(TextBaseline.alphabetic);
final double ideographic = paragraph.computeDistanceToActualBaseline(TextBaseline.ideographic);

expect(alphabetic, 7.5);
expect(ideographic, 10.0);
});
expect(alphabetic, 7.5);
expect(ideographic, 10.0);
});

test('RenderParagraph computeDryBaseline ideographic baseline', () {
Expand Down
Loading