[#9491] - Line breaks calculated inaccurate (text disappears in output)

Category:
Bug report
Priority:
Urgent
Status:
Confirmed
Project: Severity:
Critical
Resolution:
Open
Component: Reproducibility:
Always
Assigned to:
0

In AbstractTextRenderer the constant LINE_BREAK_FONT_RENDER_CONTEXT is instantiated like this: new FontRenderContext(null, true, true);

According to javadoc "Typically, instances of FontRenderContext are obtained from a Graphics2D object. A FontRenderContext which is directly constructed will most likely not represent any actual graphics device, and may lead to unexpected or incorrect results.",

Because no affine transformation is used in the constructor to increase the resolution, the line breaks are calculated at 72 dpi.

Depending on the font used, the calculated line breaks at fill time can be different from the actual line breaks at export time and as a consequence the calculated vertical space may not suffice.

Because of this mismatch text can "disappear" in hight resolution output formats like PDF (especially parts of long texts that stretch with overflow).

Possible Solutions:

(1) Increase the resolution of the FontRenderContext in AbstractTextRenderer by using an Affine Transform with constant values, e.g.:
private static final AffineTransform TRX = new AffineTransform(4, 0, 0, 4, 0, 0);
public static final FontRenderContext LINE_BREAK_FONT_RENDER_CONTEXT = new FontRenderContext(TRX, true, true);
(2) Provide a configuration property (e.g. LINE_BREAK_FONT_RENDER_CONTEXT_SCALE) for the AffineTransform to increase the scale if needed.

v6.4
sgrueter's picture
Joined: Dec 20 2007 - 12:47am
Last seen: 2 months 3 weeks ago

4 Comments:

#1

Do you have a self contained test case that demonstrates the problem that you are describing?

Thank you,
Lucian

#2
AttachmentSize
lbcidemo.zip145.09 KB
#3

I uploaded a simple Maven project to demonstrate the problem. Instructions are contained in README.md

#4
  • Status:New» Confirmed
Feedback