Skip to content

[Impeller] PaintingStyle.stroke for Text: Rendered text has an offset #133157

@LeoSandbox

Description

@LeoSandbox

Is there an existing issue for this?

Steps to reproduce

Hi, I am following up on #126010 and #41735 closed last month.

I am using 3.14.0-0.1.pre on beta channel and I can clearly see that outline of text is now supported on Impeller iOS using foreground in TextStyle as per doc.

However this fix introduced an offset issue on the rendered text with foreground stroke painter with both the default Flutter font (small offset) and other Google Fonts (large offset). See code example, screenshots and details below.

Expected results

This issue makes text outline impossible to use with foreground method as the goal of the outline is to be positioned exactly below the text without outline in the Stack - otherwise it is a shadow. The shadow method workaround still works but visually not great compared to a real outline stroke.

Actual results

Texts with strokes on iOS using Impeller have now an offset that can range from a few pixel if using the default Flutter font to a significant amount when using any other fonts (see Google Font Mulish in screenshots)

Code sample

import 'package:flutter/material.dart';

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

  @override
  Widget build(BuildContext context) => Material(
        color: Colors.blue,
        child: Center(
          child: Stack(
            children: [
              Text(
                "1,250 / 35,000",
                style: TextStyle(
                    fontSize: 30,
                    fontWeight: FontWeight.w700,
                    fontFamily: 'Mulish',
                    foreground: Paint()
                      ..style = PaintingStyle.stroke
                      ..strokeWidth = 1
                      ..color = Colors.black),
              ),
              const Text(
                "1,250 / 35,000",
                style: TextStyle(
                  color: Colors.white,
                  fontSize: 30,
                  fontWeight: FontWeight.w700,
                  fontFamily: 'Mulish',
                ),
              ),
            ],
          ),
        ),
      );
}

Screenshots or Video

Using the sample code with Mulish Google Font (this applies to other Google Fonts I tested)

textoutline-mulish

Using the default font (i.e. removing fontFamily)

textoutline-default

Using the default font and zooming in so you can see the offset

textoutline-default-zoom

Logs

No response

Flutter Doctor output

Doctor output
[✓] Flutter (Channel beta, 3.14.0-0.1.pre, on macOS 13.2.1 22D68 darwin-arm64, locale en-CA)
    • Flutter version 3.14.0-0.1.pre on channel beta at /Users/xxxxxxxxxxxxx/Developer/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 120d54d33a (6 days ago), 2023-08-17 14:10:34 -0500
    • Engine revision f613b67824
    • Dart version 3.2.0 (build 3.2.0-42.1.beta)
    • DevTools version 2.26.1

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.12.0

[✓] VS Code (version 1.81.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.70.0

[✓] Connected device (2 available)
    • iPhone (mobile) • 00008020-xxxxxxxxxxxxx • ios          • iOS 16.4.1 20E252
    • macOS (desktop) • macos                     • darwin-arm64 • macOS 13.2.1 22D68 darwin-arm64

[✓] Network resources
    • All expected network resources are available.

• No issues found!

Metadata

Metadata

Assignees

Labels

e: impellerImpeller rendering backend issues and features requestsengineflutter/engine related. See also e: labels.found in release: 3.14Found to occur in 3.14has reproducible stepsThe issue has been confirmed reproducible and is ready to work onr: fixedIssue is closed as already fixed in a newer versionteam-engineOwned by Engine team

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions