Project

General

Profile

Problems with Rendering justified text

Added by Helmar Spangenberg almost 11 years ago

I'm using WPdfRenderer (3.3.1) to create justified text. There are 2 problems:

a) The text is not expanded totally to the right side, the lines do not end exactly at the same position.

b) Every once in a while you can find a line displaying the last word in a bigger distance to the rest of the line

I was able to patch Wt for my application to get rid of problem b):

In line 1057 of Block.C a part of the text is chosen to fit into maxWidth. Some lines later, an additional lenght of whitespaceWidth might be added under some circumstances. The consequence is, a text fragment, which seemed to fit into the line, may be extended to just not fitting anymore in special cases. I observed lines with two blocks leading to the b9-Problem.

My solution for this particular problem was to decrease maxWidth by whitespaceWidth, thus avoiding situations as described. I changed the original line 1057

_= renderer.painter()device()>measureText(text, maxWidth, true);_

by

_= renderer.painter()device()>measureText(text, maxWidth-whitespaceWidth, true);_

My question: Could any other functionality be affected by this change?

With regards to problem a) I have no real idea what could be done. I have the feeling that the calculation of the ratio between text and remaining space seems to be buggy.


Replies (4)

RE: Problems with Rendering justified text - Added by Wim Dumon almost 11 years ago

Hello Helmar,

Can you add the HTML that produces the bad result?

Best regards,

Wim.

RE: Problems with Rendering justified text - Added by Helmar Spangenberg almost 11 years ago

Hello Wim,

the text is the output of tinyMCE - I will add it as a short file.

With best regards,

Helmar

RE: Problems with Rendering justified text - Added by Helmar Spangenberg almost 11 years ago

Ah - maybe I should add my page parameters I submitted to hpdf/WPdfRenderer:

page = HPDF_AddPage(hpdf);

HPDF_Page_SetSize(page, HPDF_PAGE_SIZE_A4, HPDF_PAGE_PORTRAIT);

renderer = new Render::WPdfRenderer(hpdf, page);

dev = renderer->startPage(0);

double faktorX = renderer->pageWidth(0)/210.; // DIN A4 hat als Breite 210 mm

double faktorY = renderer->pageHeight(0)/297.; // DIN A4 hat als Höhe 297 mm

renderer->setMargin(2.0,Left|Right);

renderer->setFontScale(0.75);

RE: Problems with Rendering justified text - Added by Koen Deforche almost 11 years ago

Hey,

Thanks for the test file. I've filed this as a bug: #2634.

Regards,

koen

    (1-4/4)