labelmake icon indicating copy to clipboard operation
labelmake copied to clipboard

Line wrapping bug

Open verdant-spark opened this issue 2 years ago • 1 comments

When creating a label with the below definition, the last char of a couple of lines wraps to the next line, with the next line overlapping that last/first char.

        basePdf: {width: 50, height: 25},
        schemas: [
            {
                'order_name': {
                    'type': 'text',
                    'position': {'x': 0, 'y': 1},
                    'width': 49,
                    'height': 2,
                    'alignment': 'right',
                    'fontSize': 5,
                    'characterSpacing': 0,
                    'lineHeight': 1,
                },
                'message': {
                    'type': 'text',
                    'position': {'x': 2, 'y': 3},
                    'width': 46,
                    'height': 17,
                    'alignment': 'left',
                    'fontSize': 10,
                    'characterSpacing': 0,
                    'lineHeight': 1,
                }
            }],
    };
    inputs = rows.map(row => ({
        order_name: row.order_name,
        message: row.message,
    }));

For testing: row.order_name = ABC-1234 row.message = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec posuere nulla risus, eu suscipit ex imperdiet sed. Nam consectetur ullamcorper nibh, non.'

Resultant pdf: messages (7).pdf

Note that if font size is dropped to 9 then the issue doesn't appear, so I'm guessing it's just a magical combination of character line length and font size vs box width.

verdant-spark avatar Oct 27 '21 07:10 verdant-spark

Thank's report.

Note that if font size is dropped to 9 then the issue doesn't appear, so I'm guessing it's just a magical combination of character line length and font size vs box width.

I see. Could you use 'splitThreshold' option to avoid this problem? https://github.com/hand-dot/labelmake/pull/40

hand-dot avatar Feb 10 '22 06:02 hand-dot