mirror of
https://github.com/docusealco/docuseal
synced 2026-11-04 22:42:32 -05:00
adjust font size if long text
This commit is contained in:
1 parent
a42ae0b39e
commit
fc11078cae
4 files changed
+54
-5
No files matched your search
@@ -157,6 +157,17 @@ module Submissions
|
||||
|
||||
lines = layouter.fit([text], area['w'] * width, height).lines
|
||||
box_height = lines.sum(&:height)
|
||||
|
||||
if box_height > (area['h'] * height) + 1
|
||||
text = HexaPDF::Layout::TextFragment.create(Array.wrap(value).join(', '),
|
||||
font: pdf.fonts.add(FONT_NAME),
|
||||
font_size: (font_size / 1.4).to_i)
|
||||
|
||||
lines = layouter.fit([text], area['w'] * width, height).lines
|
||||
|
||||
box_height = lines.sum(&:height)
|
||||
end
|
||||
|
||||
height_diff = [0, box_height - (area['h'] * height)].max
|
||||
|
||||
layouter.fit([text], area['w'] * width, height_diff.positive? ? box_height : area['h'] * height)
|
||||
|
||||
Reference in new issue
Block a user