In Konva, we can use attributes like fontSize
to determine the text size.
But we want more, we are implementing a feature that can allow us to shrink the text size automatically.
For example, we have a text element in canvas with different lengths of paragraphs.
we want to dynamically determine fontsize
to fit in the text DOM.
So, if the width and height don't have enough space to accommodate text, then we adjust fontsize smaller.
if the width and height can accommodate text, then we make fontsize bigger.
We found this post, but the downside is that will keep text in one line. if your paragraph has multiple lines, then the font will be very small and only one line.
Is there any workaround or idea we can try? I think the issue is we need to calculate the text is over boundary or not.