Skip to content

CupertinoTextField default font differs from that of UITextField's default. #67953

Description

@DanielEdrisian

The UIKit textfield's font seems to be a bit narrower. Two examples:

Screen Shot 2020-10-12 at 1 04 16 PM

Screen Shot 2020-10-12 at 1 07 33 PM

Activity

  1. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    a: fidelityMatching the OEM platforms better
    a: text inputEntering text in a text field or keyboard related problems
    on Oct 13, 2020
  2. removed their assignment
    on Dec 8, 2020
  3. justinmc commented on Oct 5, 2022

    @justinmc
    Contributor

    CC @MitchellGoodwin maybe something to look at in the comparison tool, not sure what's different.

  4. MitchellGoodwin commented on Oct 20, 2022

    @MitchellGoodwin
    Contributor

    Compared to the text in both CupertinoSearchField and CupertinoTextField, the font weight of a SwiftUI text input does seem to be different slightly (or I've gone crazy from staring at pixels too much). Here's an S side by side for comparison.
    Screen Shot 2022-10-20 at 4 16 06 PM
    The Flutter text is on the left, the SwiftUi is on the right. The tricky thing is that the text's font weight seems to be in between our FontWeight.w400 and our FontWeight.w500. Maybe by about 20%, as far as my eyeballs can tell. In order to match native, seems like we'd have to either:

    • Adjust the font weight enums to match perfectly.
    • Do something tricky to the default font to get it to match, which the developer would likely not be able to match fully with a style overwrite.
      Both of these feel like overkill and a small breaking change that may break too many goldens compared to the benefit they'd bring.

    However the padding of both CupertinoSearchField and CupertinoTextField can be adjusted to match native a little better, which causes the text to overlap a little more naturally.

    CupertinoSearchField defaults before:
    Screen Shot 2022-10-20 at 4 15 10 PM

    And after adjusting:
    Screen Shot 2022-10-20 at 4 14 56 PM

    It's a little harder to see with the CupertinoTextField, but here's the SwiftUi text field overlayed the Flutter CupertinoTextField at 50% opacity. Before:
    Screen Shot 2022-10-20 at 4 40 56 PM

    After
    Screen Shot 2022-10-20 at 4 40 38 PM

    I think for now just making the adjustments to the padding would be fine? And we can see if there's interest in making the small adjustment to the font size?

  5. justinmc commented on Oct 20, 2022

    @justinmc
    Contributor

    Thanks for doing that detailed analysis! The padding change seems like a major win to me...

  6. MitchellGoodwin commented on Oct 26, 2022

    @MitchellGoodwin
    Contributor

    Partially addressed by #113958 adjusting the padding. If there's enough interest in getting the font width for the weights 100% aligned, we can reopen this issue, but I'm going to close this as that would be a fairly substantial change for a lot of apps for seemingly not a lot of interest.

  7. MitchellGoodwin commented on Oct 26, 2022

    @MitchellGoodwin
    Contributor

    Reopened from merge failure

  8. MitchellGoodwin commented on Nov 30, 2022

    @MitchellGoodwin
    Contributor

    Addressed by #115164

  9. github-actions commented on Mar 5, 2023

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  10. locked as resolved and limited conversation to collaborators on Mar 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: fidelityMatching the OEM platforms bettera: text inputEntering text in a text field or keyboard related problemsframeworkflutter/packages/flutter repository. See also f: labels.p: cupertino_uicupertino_ui package in flutter/packages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions