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

Overflow Y Hidden

Open Pelican104 opened this issue 2 years ago • 8 comments

This is very impressive.

Is there a way to stop text spilling out of the text box bounds?

If i provide too much text or increase the font size too much the text is spilling out of the text box at the top and bottom.

Pelican104 avatar Aug 04 '23 22:08 Pelican104

Based on the current font style, text, and preferred width, I think we should be able to calculate the minimum height of the text box.

jiakuan avatar Aug 05 '23 06:08 jiakuan

Have we not already provided the height of the text box? It would be useful if there was a setting to stop text displaying outside the box, I guess like the css overflow hidden property

Pelican104 avatar Aug 05 '23 16:08 Pelican104

Height calculation is really easy, I'm still unsure how the effect should be. Any inputs @Pelican104 @jiakuan ?

Frame 1 (28)

geongeorge avatar Aug 24 '23 19:08 geongeorge

I was imagining exactly what you have shown in option A.

Pelican104 avatar Aug 24 '23 21:08 Pelican104

For my use case, I normally pre-calculate the text box based on the text content/style and preferred width, and then draw text exactly in the text box.

In case of the text box is too small, perhaps we could provide a configuration, like CSS, e.g. overflow: visible or hidden, which means either the Current (visible) or Option A (hidden), not sure if Option B is useful in some scenarios or not.

jiakuan avatar Aug 25 '23 01:08 jiakuan

Hey, I think I have the solution for this.

May be I can make pull request.

I have one question, Is there an option to supply font color?

pulimoodan avatar Jan 17 '24 15:01 pulimoodan

@pulimoodan

Your solution to clipping the overflow seems good to me.

I have one question, Is there an option to supply font color?

Not currently, but in #95, I have added color support for individual words in the text. 😄

stefcameron avatar Feb 03 '24 20:02 stefcameron

I would like to have another option, to truncate the text instead of hiding the overflow (as also already asked in #91).

bobvandevijver avatar Feb 20 '24 13:02 bobvandevijver