View Issue Details

IDProjectCategoryView StatusLast Update
0023135LazarusLazReportpublic2012-11-02 19:25
ReporterTony Whyman Assigned ToJesus Reyes  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version1.0.2 
Target Version1.2.0Fixed in Version1.1 (SVN) 
Summary0023135: Right Justified text incorrectly aligned on printer
DescriptionRight justified text appears correct in the preview but when printed is mis-aligned
Additional InformationThe problem seems to be due to computing the location for the text using the screen canvas metrics rather than the printer canvas metrics. The attached patch fixes this.
TagsNo tags attached.
Fixed in Revision39232
LazTarget1.2
WidgetsetGTK 2
Attached Files

Activities

2012-10-16 09:05

 

raggedright.diff (800 bytes)   
diff -urpN lazarus.orig/components/lazreport/source/lr_class.pas lazarus/components/lazreport/source/lr_class.pas
--- components/lazreport/source/lr_class.pas	2012-05-06 09:15:33.000000000 +0100
+++ lazarus/components/lazreport/source/lr_class.pas	2012-10-15 19:20:00.599498994 +0100
@@ -2886,9 +2895,9 @@ var
         {$ENDIF}
         case Alignment of
           Classes.taLeftJustify : CurX :=x+gapx;
-          Classes.taRightJustify: CurX :=x+dx-1-gapx-nw;
-          Classes.taCenter      : CurX :=x+gapx+(dx-gapx-gapx-nw) div 2;
+          Classes.taRightJustify: CurX :=x+dx-1-gapx-Canvas.TextWidth(St);
+          Classes.taCenter      : CurX :=x+gapx+(dx-gapx-gapx-Canvas.TextWidth(St)) div 2;
         end;
 
         if not Exporting then
           Canvas.TextRect(DR, CurX, CurY, St)

raggedright.diff (800 bytes)   

2012-10-16 09:13

 

vertraggedright.diff (1,265 bytes)   
diff -urpN lazarus.orig/components/lazreport/source/lr_class.pas lazarus/components/lazreport/source/lr_class.pas
--- components/lazreport/source/lr_class.pas	2012-05-06 09:15:33.000000000 +0100
+++ lazarus/components/lazreport/source/lr_class.pas	2012-10-15 19:20:00.599498994 +0100
@@ -2933,14 +2942,24 @@ var
     procedure OutLine(str: String);
     var
       cury: Integer;
+      Ts: TTextStyle;
     begin
       SetLength(str, Length(str) - 2);
       if str[Length(str)] = #1 then
         SetLength(str, Length(str) - 1);
       cury := 0;
+
+      Ts := Canvas.TextStyle;
+      Ts.Layout    :=tlTop;
+      Ts.Alignment :=self.Alignment;
+      Ts.Wordbreak :=false;
+      Ts.SingleLine:=True;
+      Ts.Clipping  :=True;
+      Canvas.TextStyle := Ts;
+
       case Alignment of
           Classes.taLeftJustify : CurY :=y + dy-gapy;
-          Classes.taRightJustify: CurY :=y - gapy + Canvas.TextWidth(str);
-          Classes.taCenter      : CurY :=y - gapy + (dy + Canvas.TextWidth(str)) div 2;
+          Classes.taRightJustify: CurY :=y + gapy + 1 + Canvas.TextWidth(str);
+          Classes.taCenter      : CurY :=y + gapy + (dy + Canvas.TextWidth(str)) div 2;
       end;
       if not Exporting then
          canvas.TextOut(curx,cury,str)

vertraggedright.diff (1,265 bytes)   

Julio Jiménez Borreguero

2012-10-18 11:07

reporter   ~0063266

Last edited: 2012-10-18 11:39

This patch is not working properly due chars using more than one byte (UTF8 chars).

ie: try right align these numbers: 1234,00€ 1234,00C 12,00C and you'll see the effect. (the strings containing utf8 chars, will be shifted left)

Jesus Reyes

2012-11-02 19:25

developer   ~0063644

Thanks, Applied.

Issue History

Date Modified Username Field Change
2012-10-16 09:05 Tony Whyman New Issue
2012-10-16 09:05 Tony Whyman File Added: raggedright.diff
2012-10-16 09:05 Tony Whyman Widgetset => GTK 2
2012-10-16 09:13 Tony Whyman File Added: vertraggedright.diff
2012-10-16 17:37 Jesus Reyes Status new => assigned
2012-10-16 17:37 Jesus Reyes Assigned To => Jesus Reyes
2012-10-18 11:07 Julio Jiménez Borreguero Note Added: 0063266
2012-10-18 11:35 Julio Jiménez Borreguero Note Edited: 0063266
2012-10-18 11:39 Julio Jiménez Borreguero Note Edited: 0063266
2012-11-02 19:25 Jesus Reyes Fixed in Revision => 39232
2012-11-02 19:25 Jesus Reyes LazTarget => 1.2
2012-11-02 19:25 Jesus Reyes Status assigned => resolved
2012-11-02 19:25 Jesus Reyes Fixed in Version => 1.1 (SVN)
2012-11-02 19:25 Jesus Reyes Resolution open => fixed
2012-11-02 19:25 Jesus Reyes Note Added: 0063644
2012-11-02 19:25 Jesus Reyes Target Version => 1.2.0