Skip to content

Conversation

@koji-1009
Copy link
Contributor

@koji-1009 koji-1009 commented Dec 25, 2025

fix #22625

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

import 'package:flutter/material.dart';

void main() {
  runApp(const MaterialApp(home: BaselineTest()));
}

class BaselineTest extends StatelessWidget {
  const BaselineTest({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: SafeArea(
        child: Padding(
          padding: const .all(16),
          child: Column(
            spacing: 8,
            crossAxisAlignment: .start,
            children: [
              _List(title: 'TextBaseline.alphabetic', baseline: .alphabetic),
              _List(title: 'TextBaseline.ideographic', baseline: .ideographic),
            ],
          ),
        ),
      ),
    );
  }
}

class _List extends StatelessWidget {
  const _List({required this.title, required this.baseline});

  final String title;
  final TextBaseline baseline;

  @override
  Widget build(BuildContext context) {
    return Column(
      spacing: 8,
      crossAxisAlignment: .start,
      children: [
        Text(title, style: Theme.of(context).textTheme.titleLarge),
        Container(
          color: Colors.grey[200],
          child: Row(
            crossAxisAlignment: .baseline,
            textBaseline: baseline,
            children: [
              const Text(
                'Highg',
                style: TextStyle(
                  fontSize: 60,
                  backgroundColor: Colors.amberAccent,
                ),
              ),
              const Text(
                '国jp',
                style: TextStyle(
                  fontSize: 60,
                  backgroundColor: Colors.orangeAccent,
                ),
              ),
              const SizedBox(width: 16),
              const Text(
                'Highg',
                style: TextStyle(
                  fontSize: 20,
                  backgroundColor: Colors.greenAccent,
                ),
              ),
              const Text(
                '国jp',
                style: TextStyle(
                  fontSize: 20,
                  backgroundColor: Colors.blueAccent,
                ),
              ),
              const SizedBox(width: 16),
              const Text(
                'Mixed国jp',
                style: TextStyle(
                  fontSize: 30,
                  backgroundColor: Colors.purpleAccent,
                ),
              ),
            ],
          ),
        ),
      ],
    );
  }
}

Screenshot

main fix
Android android_main android_fix
iOS ios_main ios_fix
Web web_main web_fix

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-assist bot 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.

@github-actions github-actions bot added the framework flutter/packages/flutter repository. See also f: labels. label Dec 25, 2025
@koji-1009 koji-1009 marked this pull request as ready for review December 26, 2025 04:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

framework flutter/packages/flutter repository. See also f: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Properly implement ideographic baseline

1 participant