Closed peteward closed 9 months ago
NOTE: We will retain the overflow behaviour as it currently is for when you exceed the available box space even after shrinking text to the minimum size as per #169
Hey @peteward , is this issue same with https://github.com/pdfme/pdfme/issues/169?
if you already handle same problem, i will close https://github.com/pdfme/pdfme/issues/169.
Hi @hand-dot,
No, this is not the same issue.
Currently when you apply dynamic font sizing it starts to reduce the font size based on the first/longest line, it does not consider the full height of the box. In the scenario below it should only start reducing the font size once it starts to over flow the box:
Similarly, it should grow to fill the box up to the maximum font size.
Dynamic font size, if used, will reduce the chance of overflow but it can still happen and I'm not sure what the best course of action is when it does. There are arguments for both truncating/clipping and allowing the overflow in this scenario. I would probably keep the existing behaviour of overflow.
Hey @peteward ah, got it. this is not same with https://github.com/pdfme/pdfme/issues/169
I want to ensure that an overflow does not occur in the above issue.
The method I'm planning to use is to reduce the font size even if the text overflows vertically from the bounding box. By controlling the height of the font, we can definitely prevent overflow by reducing the font size until it becomes 0.
If you have any concerns, please let me know.
Yes, I think this is a good approach 👍
Update on progress:
https://github.com/pdfme/pdfme/assets/7068515/3cb898f6-b0d7-45e0-b76a-b4435d8c2443
A few static examples.
Current pdfme playground, where dynamic font sizing does not 'grow' to fit the available box space because it does not consider height:
New version where both height and line length are considered:
Rendered PDF:
Closed by https://github.com/pdfme/pdfme/pull/222
Describe the bug
The current implementation scales font based on the length of the longest line. This means that if you create a large text box and expect the content to span multiple lines, it will shrink the text down to a minimum to fit on the top line only.
To Reproduce
Expected behavior
It needs to consider scaling based on the full available height of potentially multiple lines from the defined text box.
A good example of how it should behave is shown in the google docs gif from issue #169.
Your Environment
Your Error Log
Additional context
We are working on a fix/improvement to this.