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

Prop scaleToFit on the Text component still overflows #1737

Open
cour64 opened this issue Jul 28, 2023 · 1 comment
Open

Prop scaleToFit on the Text component still overflows #1737

cour64 opened this issue Jul 28, 2023 · 1 comment

Comments

@cour64
Copy link

cour64 commented Jul 28, 2023

The scaleToFit property doesn't seem to scale the text to fit the container.

This can be reproduced in the demo:

Screen.Recording.2023-07-28.at.11.37.42.mov
@Rowansdabomb
Copy link

I believe I found the issue. It appears that the fontSize prop is not factored into the style parameter passed to the getStringWidth function, within the useText hook.

  const {
    // ... other prop imports above
    style: _style,
    fontSize,
    ...textProps
  } = props;
  
  const style = useMemo(() => {
    if (typeof fontSize === 'number') {
      return { ..._style, fontSize: `${fontSize}px` };
    }
    if (typeof fontSize === 'string') {
      return { ..._style, fontSize };
    }
    return _style;
  }, [_style, fontSize]);

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

2 participants