DO NOT REPLY [Bug 28208] - [PATCH] justification in PDF Renderer

2004-04-07 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://issues.apache.org/bugzilla/show_bug.cgi?id=28208.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=28208

[PATCH] justification in PDF Renderer





--- Additional Comments From [EMAIL PROTECTED]  2004-04-07 07:30 ---
Hi

The text upside-down depends on a missing - that I forgot to correct in the 
patch:
  [then branch of the if]
  pdf.append(1 0 0 -1  + ...
^^

Now I'm trying to understand what happens with your suggested change.

Luca


DO NOT REPLY [Bug 28208] - [PATCH] justification in PDF Renderer

2004-04-07 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://issues.apache.org/bugzilla/show_bug.cgi?id=28208.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=28208

[PATCH] justification in PDF Renderer





--- Additional Comments From [EMAIL PROTECTED]  2004-04-07 12:17 ---
Hi Chris, I'm here again.

I have done some tests, and it seems to me that a second Tw operand inside the 
array
  ... Tm 4 Tw [(first fragment ) 0 1 Tw (second fragment of text)] TJ
affects EVERY space in the array, not only the ones in the following string.

This is quite counter-intuitive, but you can see this if you look at the pdfs 
genereted in the two ways we proposed: with your patch it seems that the first 
space in the second line (which belongs to the first fragment of text) is as 
long as the other spaces (which belongs to the second fragment), while with 
mine it is visibly longer.

On this subject, I have a few doubts:
- is this behaviour (spaces in a same line are sometimes different) 
acceptable? Surely it is easier, as the LineLM has to compute only one 
adjustment factor which every TextLMs involved in the line building uses.
- if this is ok, then there are problems with fragments of text without spaces 
(this can happen with the last word before a linefeed treated as space, or the 
first after); maybe in these cases we could use letter spacing instead of word 
spacing.

Luca


DO NOT REPLY [Bug 28208] - [PATCH] justification in PDF Renderer

2004-04-07 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://issues.apache.org/bugzilla/show_bug.cgi?id=28208.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=28208

[PATCH] justification in PDF Renderer

[EMAIL PROTECTED] changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED



--- Additional Comments From [EMAIL PROTECTED]  2004-04-07 14:25 ---
Hi Luca,

I had another look at your proposal and ive decided its probably okay to 
delete the IF statement for emDiff  -33000. We are keeping the case that is 
supposed to be the work around for the issue described in the comments. So in 
theory we shouldnt hit the issue. Ive run a few test cases and the 
justification seems to work nicely.

However there seems to be an outstanding issue of text-align-last. In your 
test cases, setting text-align=justify does not justify the last line, but 
in examples\fo\basic\simple.fo, the last lines are justified even though only 
text-align=justify is specified.

For now, Im happy to apply your patch. Thanks


DO NOT REPLY [Bug 28208] - [PATCH] justification in PDF Renderer

2004-04-06 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://issues.apache.org/bugzilla/show_bug.cgi?id=28208.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=28208

[PATCH] justification in PDF Renderer





--- Additional Comments From [EMAIL PROTECTED]  2004-04-06 10:34 ---
There is still a problem concerning the way the PDFRenderer behave when the 
text of a line comes from different TLM (I'm going to attach a test fo file 
showing this problem).

[from PDFRenderer.renderText(), /*** comments added ***/]
  ...
  if (!textOpen || bl != prevWordY) {
  /*** this is done for the first fragment ***/
  /*** and it's OK ***/
  closeText();

  pdf.append(1 0 0 -1  + (rx / 1000f) +   + (bl / 1000f) +  Tm 
 + (text.getTSadjust()/1000f) +  Tw [ + startText);
  prevWordY = bl;
  textOpen = true;
  } else {
  // express the space between words in thousandths of an em
  int space = prevWordX - rx + prevWordWidth;
  float emDiff = (float) space / (float) currentFontSize * 1000f;
  // this prevents a problem in Acrobat Reader and other viewers
  // where large numbers cause text to disappear or default to
  // a limit
  if (emDiff  -33000) {
  /*** this would be OK, but it is not done ***/
  closeText();

  pdf.append(1 0 0 -1  + (rx / 1000f) +   + (bl / 1000f) +  Tm 
 + (text.getTSadjust()/1000f) +  Tw [ + startText);
  textOpen = true;
  } else {
  /*** this is done for the following fragments ***/
  /*** and it is not correct because it uses the***/
  /*** space adjustment of the first fragment!! ***/
  pdf.append(Float.toString(emDiff));
  pdf.append( );
  pdf.append(startText);
  }
  }
  ...

So the resulting pdf code contains:
  ... 4.869 Tw [(fragment 1) 0.0 (fragment 2)] TJ
  \--/
 |
 space adjustment for the FIRST fragment
instead of:
  ... 4.869 Tw [(fragment 1)] TJ
  ... 1.853 Tw [(fragment 2)] TJ

I have tried to fix this commenting out the if and the else branch, so 
that each fragment uses its own space adjustment, and it works.
But the comment says that the if was done to prevent a problem, so I fear that 
that problem could arise againg, removing the if.

Luca


DO NOT REPLY [Bug 28208] - [PATCH] justification in PDF Renderer

2004-04-06 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://issues.apache.org/bugzilla/show_bug.cgi?id=28208.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=28208

[PATCH] justification in PDF Renderer





--- Additional Comments From [EMAIL PROTECTED]  2004-04-06 10:36 ---
Created an attachment (id=11151)
fo file having a line whose text comes from 2 different TextLMs


DO NOT REPLY [Bug 28208] - [PATCH] justification in PDF Renderer

2004-04-06 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://issues.apache.org/bugzilla/show_bug.cgi?id=28208.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=28208

[PATCH] justification in PDF Renderer





--- Additional Comments From [EMAIL PROTECTED]  2004-04-06 12:55 ---
Hi Luca,

Im looking at your patch now. I tried removing the IF statement and the effect 
is one part line of text in your 2nd sample is flipped upside down!

Instead I tried keeping the IF statement there, but setting the word spacing 
in both bits, e.g.

if (emDiff  -33000) {
closeText();

pdf.append(1 0 0 1  + (rx / 1000f) +   + (bl / 1000f) +  
Tm 
   + (text.getTSadjust()/1000f) +  Tw [ + startText);
textOpen = true;
} else {
pdf.append(Float.toString(emDiff));
pdf.append(  + (text.getTSadjust()/1000f) +  Tw );
pdf.append(startText);
}

This is closer, but the justification is very slightly out on the 2nd 
paragraph. Ill take another look later. Thanks for all your efforts

Chris


DO NOT REPLY [Bug 28208] - [PATCH] justification in PDF Renderer

2004-04-05 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://issues.apache.org/bugzilla/show_bug.cgi?id=28208.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=28208

[PATCH] justification in PDF Renderer





--- Additional Comments From [EMAIL PROTECTED]  2004-04-05 14:06 ---
Created an attachment (id=11135)
suggested patch


DO NOT REPLY [Bug 28208] - [PATCH] justification in PDF Renderer

2004-04-05 Thread bugzilla
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
http://issues.apache.org/bugzilla/show_bug.cgi?id=28208.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=28208

[PATCH] justification in PDF Renderer





--- Additional Comments From [EMAIL PROTECTED]  2004-04-05 14:08 ---
Created an attachment (id=11136)
test fo file