View Issue Details

IDProjectCategoryView StatusLast Update
0034871LazarusLazReportpublic2020-06-03 12:06
ReporterPaweł Dmitruk Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version2.1 (SVN) 
Summary0034871: [PATCH] Problem with polish letter in wrapped text
DescriptionProblem with polish letter in wrapped text
TagsNo tags attached.
Fixed in Revision
LazTarget
WidgetsetWin32/Win64
Attached Files

Relationships

related to 0037170 resolvedJuha Manninen Wrong UTF8 text hyphenation in LazReport - WrapMemo - FPPrintGrid (and others) 

Activities

Paweł Dmitruk

2019-01-14 14:30

reporter  

lr_class.pas.patch (2,562 bytes)   
--- D:/Temp/lr_class.pas-revBASE.svn000.tmp.pas	sob. 2018-09-08 08:30:49
+++ C:/lazarus/components/lazreport/source/lr_class.pas	pon. 2019-01-14 14:10:23
@@ -3802 +3802 @@ var
-    ch: char;
+    ch: string;
@@ -3806 +3806 @@ var
-    for i := 1 to Length(s) do
+    for i := 1 to UTF8Length(s) do
@@ -3808 +3808,2 @@ var
-      if s[i] in [#10, #13] then
+	  ch:=UTF8Copy(s, i, 1);
+      if (ch=#10) or (ch=#13) then
@@ -3816 +3817 @@ var
-    if not CRLF and ((Length(s) <= 1) or (WCanvas.TextWidth(s) <= maxwidth)) then
+    if not CRLF and ((UTF8Length(s) <= 1) or (WCanvas.TextWidth(s) <= maxwidth)) then
@@ -3823 +3824 @@ var
-      Len := length(s);
+      Len := UTF8length(s);
@@ -3827 +3828 @@ var
-        Ch := s[cur];
+        Ch := UTF8Copy(s, cur, 1);;
@@ -3834 +3835 @@ var
-          if (cur < length(s)) then
+          if (cur < UTF8length(s)) then
@@ -3836 +3837 @@ var
-            ch := s[cur+1];
+            ch := UTF8Copy(s, cur+1, 1);
@@ -3838 +3839 @@ var
-            if s[cur+1]<>#10 then
+            if UTF8Copy(s, cur+1, 1)<>#10 then
@@ -3844 +3845 @@ var
-          OutLine(copy(s, beg, cur - beg) + #1);
+          OutLine(UTF8copy(s, beg, cur - beg) + #1);
@@ -3855 +3856 @@ var
-        if WCanvas.TextWidth(copy(s, beg, cur - beg + 1)) > maxwidth then
+        if WCanvas.TextWidth(UTF8Copy(s, beg, cur - beg + 1)) > maxwidth then
@@ -3864 +3865 @@ var
-            while (i <= Len) and not (ch in [' ', '.', ',', '-']) do
+            while (i <= Len) and not ((Length(ch)=1) and (ch[1] in [' ', '.', ',', '-'])) do
@@ -3867 +3868 @@ var
-              ch := s[i];
+              ch := UTF8Copy(s, i, 1);
@@ -3873 +3874 @@ var
-            aWord := copy(s, last, i - last);
+            aWord := UTF8Copy(s, last, i - last);
@@ -3890 +3891 @@ var
-                (WCanvas.TextWidth(copy(s, beg, last - beg + Ord(b[i])) + '-') <= maxwidth) do
+                (WCanvas.TextWidth(UTF8Copy(s, beg, last - beg + Ord(b[i])) + '-') <= maxwidth) do
@@ -3914 +3915 @@ var
-            OutLine(copy(s, beg, last - beg) + '-');
+            OutLine(UTF8Copy(s, beg, last - beg) + '-');
@@ -3918 +3919 @@ var
-            OutLine(copy(s, beg, last - beg));
+            OutLine(UTF8Copy(s, beg, last - beg));
@@ -3927 +3928 @@ var
-        if Ch in [' ', '.', ',', '-'] then
+        if (Length(ch)=1) and (Ch[1] in [' ', '.', ',', '-']) then
@@ -3933 +3934 @@ var
-        OutLine(copy(s, beg, cur - beg + 1) + #1);
+        OutLine(UTF8Copy(s, beg, cur - beg + 1) + #1);
lr_class.pas.patch (2,562 bytes)   

Juha Manninen

2019-01-15 00:34

developer   ~0113417

Last edited: 2019-01-15 00:35

View 2 revisions

The patch changes procedure WrapLine inside procedure TfrCustomMemoView.WrapMemo.
It slows down the operation a lot because UTF8...() functions are used inside loops.
Maybe a similar but optimized function for wrapping a line can be found.
If not, then the slow version should be applied naturally.

Issue History

Date Modified Username Field Change
2019-01-14 14:30 Paweł Dmitruk New Issue
2019-01-14 14:30 Paweł Dmitruk File Added: lr_class.pas.patch
2019-01-15 00:34 Juha Manninen Note Added: 0113417
2019-01-15 00:35 Juha Manninen Note Edited: 0113417 View Revisions
2020-06-03 12:06 Juha Manninen Relationship added related to 0037170