Skip to content

Wrong justification of non-breaking space #1454

@aftframe369

Description

@aftframe369

When justifying text in column, which has a U+00A0 no-break space character and ColumnText.setSpaceCharRatio >1 it is clearly visible that non-breaking space is not being stretched and is being treated as text character.

To Reproduce


        ColumnText ct = new ColumnText(writer.getDirectContent());
        String s = "";
        String nbs = "\u00a0";
        for(int i = 0; i<30; i++){
            s += "text" + nbs + "text" + " ";
        }
        ct.setSimpleColumn(0,0,300,300);
        ct.setAlignment(3);
        ct.setSpaceCharRatio(100);
        ct.setText(new Phrase(s));
        ct.go();

Expected behavior

Both no-breaking spaces should be stretched like normal spaces

Screenshots

Image

System

  • OS: linux
  • Used font: all
  • OpenPDF version: 3.0.0

Additional context

This is a real problem for polish typesetting because we have a unique rule that you can't have single letter words at the end of the line. Easiest solution is to search for all of them and replace spaces with no-break spaces and it is common in texts written in any word processor. If no-break spaces are not stretched correctly the char ratio must be 1 or text can't be justified and that's a sad compromise.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions