Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

text value spacing issue #6

Closed
husnain067 opened this issue Feb 23, 2022 · 8 comments
Closed

text value spacing issue #6

husnain067 opened this issue Feb 23, 2022 · 8 comments

Comments

@husnain067
Copy link

AnimatedFlipCounter(
curve: Curves.slowMiddle,
value: price,
fractionDigits: 2, // decimal precision
textStyle: const TextStyle(
letterSpacing: -4.0,
wordSpacing: 0.0,
color: simpleTextColor,
fontWeight: FontWeight.w700,
fontSize: 32.0,
),
),

@husnain067
Copy link
Author

image

@husnain067
Copy link
Author

image

extra space before 1 this creating the issue

@h65wang
Copy link
Owner

h65wang commented Feb 23, 2022

This is intended. Each digit has a fixed width, to avoid jumping around when values are changed.

image

It's the 1 that makes it look like there's extra space.

image

@h65wang h65wang closed this as completed Feb 23, 2022
@h65wang
Copy link
Owner

h65wang commented Mar 2, 2022

It's worth adding that, using a monospaced font can be a valid workaround, see this issue.

@h65wang h65wang reopened this Mar 4, 2022
@h65wang
Copy link
Owner

h65wang commented Mar 4, 2022

Oops, turns out this could be caused by a bug. I just released a fix in v0.2.4, please help test and report if your issue has been resolved. Thanks!

@SimonVillage
Copy link

I have seen that you use this for spacing

    final prototypeDigit = TextPainter(
      text: TextSpan(text: "8", style: style),
      textDirection: TextDirection.ltr,
      textScaleFactor: MediaQuery.of(context).textScaleFactor,
    )..layout();

I think it would be better to use

  style: TextStyle(
    fontFeatures: [
      FontFeature.tabularFigures()
    ],
  ),

https://api.flutter.dev/flutter/dart-ui/FontFeature/FontFeature.tabularFigures.html

@husnain067
Copy link
Author

I have seen that you use this for spacing

    final prototypeDigit = TextPainter(
      text: TextSpan(text: "8", style: style),
      textDirection: TextDirection.ltr,
      textScaleFactor: MediaQuery.of(context).textScaleFactor,
    )..layout();

I think it would be better to use

  style: TextStyle(
    fontFeatures: [
      FontFeature.tabularFigures()
    ],
  ),

https://api.flutter.dev/flutter/dart-ui/FontFeature/FontFeature.tabularFigures.html

@h65wang what about this solution

@h65wang
Copy link
Owner

h65wang commented Mar 28, 2024

A request to use FontFeature.tabularFigures has been added to v0.3.1. Hopefully this can help resolve alignment issues for fonts that support tabular figures.

@h65wang h65wang closed this as completed Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants