FittableFontLabel icon indicating copy to clipboard operation
FittableFontLabel copied to clipboard

Why can't we fit the height of the text in single line labels?

Open Sweeper777 opened this issue 8 years ago • 4 comments

In the README, there is this sentence:

Make the text fit the label size: width and height if multilines, width only if single lines

Why do we only fit width in single line labels?

Sweeper777 avatar Sep 10 '17 06:09 Sweeper777

In case of single line, height is dynamically adapted following the label font size. So if it fits width, the height will follow. I never encounter a case where the height was the constraint, so never though about making work in this case.

Beside that, I'm ok to add this feature if you need it.

tbaranes avatar Sep 11 '17 06:09 tbaranes

I have labels where the text is shorter than the label's width. So when it tries the match the width, the text also grows taller and out of the bounds of the label. Can you add this feature?

Sweeper777 avatar Sep 17 '17 08:09 Sweeper777

That seems to be a bug, I don't think it's the right behaviour 🤔

tbaranes avatar Sep 18 '17 06:09 tbaranes

This is actually a common use case. Anytime you have a really long label the bottom or top of the text is liable to be clipped off.

I fixed this for myself by changing line 97 in the UILabelExtension to this: let state = multiLineSizeState(rect: rect, size: size)

Minimistro32 avatar Dec 30 '21 00:12 Minimistro32