maroto
maroto copied to clipboard
TableList wrong row height calculation with Unicode content
Describe the bug
TableList
while calculating row height based on text content internally converts text to cp1252
:
https://github.com/johnfercher/maroto/blob/609811dca909f444babbb9ab3a520cbb2f080ed4/internal/text.go#L72
https://github.com/jung-kurt/gofpdf/blob/a2a0e7f8a28b2eabe1a32097f0071a0f715a8102/util.go#L275-L277
That converts any characters out of cp1252
to dots .
including for example Cyrillic characters. And so instead of long 3-lines Cyrillic text it has 1-2 lines of dots and spaces like .. . ...... ....
. As the result, some rows in the result document may have wrong height.
Related code:
m.TableList(
[]string{"Lorem", "Ipsum"},
[][]string{
{"Foo bar", "Lorem ipsum dolor sit amet consectepture adipisicing elit sed do eiusmod tempor incididunt ut labore."},
{"Lorem ipsum", "Съешь ещё этих мягких французских булок, да выпей же чаю. Съешь ещё этих мягких французских булок."},
{"space", "nothing here"},
{"dots", "..... ... .... ...... ........... ....., .. ..... .. .... ..... ... .... ...... ........... ......"},
},
props.TableList{
HeaderProp: props.TableListContent{
Size: 8,
GridSizes: []uint{2, 3},
},
ContentProp: props.TableListContent{
Size: 8,
GridSizes: []uint{2, 3},
},
VerticalContentPadding: 1,
Line: true,
},
)
Notice: 4th row's content has same content with dots, as 2nd row's content internally before height calculation. So, row 4 is how row 2 calculated: 2 lines. However, 1st row has correct height to fit 3 lines.
Expected behavior Correct row height.
Additional info
- maroto
0.37.0
- go
1.16.2
- May be related to #212.