Canvas-Txt icon indicating copy to clipboard operation
Canvas-Txt copied to clipboard

Fit text on N lines

Open PoeHaH opened this issue 2 years ago • 7 comments

Hi @geongeorge

I know this library is probably not maintained anymore but I'm happy to pay for your time.

In your opinion, would it be a lot of work to add an option to force the content on 1 line (or N lines)? So when the width exceeds 1 line, the font size becomes smaller so the text still fits on that one line.

PoeHaH avatar May 19 '22 12:05 PoeHaH

@geongeorge any feedback on this? :)

PoeHaH avatar Jun 14 '22 05:06 PoeHaH

@PoeHaH Sorry for the delay. I was busy with a few other things.

Currently, we recognize all line breaks and try to fit text accordingly. How would you suggest having a "fit to n lines" work with this? Should we ignore linebreaks?

image

geongeorge avatar Jun 14 '22 11:06 geongeorge

I mean, instead of the text going out of bounds (like the example image attached), it would decrease the font size so it stays inside the bounds. Is that possible? image

PoeHaH avatar Jun 25 '22 06:06 PoeHaH

How is this issue?

agenciadw avatar Jul 18 '22 17:07 agenciadw

@PoeHaH @agenciadw This is something that makes total sense. I will try to fit this in the 4.0.0 release

geongeorge avatar Aug 16 '22 10:08 geongeorge

@PoeHaH @agenciadw This is something that makes total sense. I will try to fit this in the 4.0.0 release

Thank you.

agenciadw avatar Aug 16 '22 10:08 agenciadw

I would love if you guys can provide some input here @PoeHaH @agenciadw : https://github.com/geongeorge/Canvas-Txt/issues/77

geongeorge avatar Aug 16 '22 14:08 geongeorge

You can now do this with splitText and only rendering that fit into your height

drawText returns the heigth now

geongeorge avatar Jul 14 '23 16:07 geongeorge