View Issue Details

IDProjectCategoryView StatusLast Update
0036293LazarusWidgetsetpublic2019-11-12 23:29
ReporterCudaText manAssigned ToJuha Manninen 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
PlatformUbuntu 19 x64OSOS Version
Product Version2.1 (SVN)Product Build 
Target VersionFixed in Version 
Summary0036293: gtk2: Incorrect rendering of multiline label with Japanese text
DescriptionDemo shows the problem- multi-line label renders with bad height of wrapped parts.
2 screenshots-- before the fix, after the fix.
fix added.
TagsNo tags attached.
Fixed in Revisionr62231
LazTarget-
WidgetsetGTK 2
Attached Files
  • gtk2-before.png (18,186 bytes)
    gtk2-before.png (18,186 bytes)
  • gtk2-after.png (17,052 bytes)
    gtk2-after.png (17,052 bytes)
  • t.diff (2,098 bytes)
    Index: lcl/interfaces/gtk2/gtk2winapi.inc
    ===================================================================
    --- lcl/interfaces/gtk2/gtk2winapi.inc	(revision 62230)
    +++ lcl/interfaces/gtk2/gtk2winapi.inc	(working copy)
    @@ -2408,6 +2408,8 @@
       l: LongInt;
       Pt: TPoint;
       SavedRect: TRect; // if font orientation <> 0
    +  LineHeight: Integer;
    +  Size: TSize;
     
       function LeftOffset: Longint;
       begin
    @@ -2453,7 +2455,7 @@
       var
         AP: TSize;
         J, MaxWidth,
    -    LineWidth: Integer;
    +    LineWidth, ActualHeight: Integer;
       begin
         theRect := Rect;
     
    @@ -2497,6 +2499,7 @@
           if (Flags and DT_CALCRECT)<>0 then
           begin
             LineWidth := 0;
    +        ActualHeight := 0;
             if (Lines <> nil) then
             begin
               for J := 0 to NumLines - 1 do
    @@ -2503,14 +2506,18 @@
               begin
                 TextExtentPoint(Lines[J], StrLen(Lines[J]), AP);
                 LineWidth := Max(LineWidth, AP.cX);
    +            Inc(ActualHeight, AP.cY);
               end;
             end;
             LineWidth := Min(MaxWidth, LineWidth);
           end else
    +      begin
             LineWidth := MaxWidth;
    +        ActualHeight := NumLines*TM.tmHeight;
    +      end;
     
           theRect.Right := theRect.Left + LineWidth;
    -      theRect.Bottom := theRect.Top + NumLines*TM.tmHeight;
    +      theRect.Bottom := theRect.Top + ActualHeight;
           if NumLines>1 then
             Inc(theRect.Bottom, (NumLines-1)*TM.tmExternalLeading);// space between lines
     
    @@ -2771,12 +2778,17 @@
           and (tm.tmHeight > (theRect.Bottom - theRect.Top))
           then Break;
     
    -      if Lines[i] <> nil then begin
    +      if Lines[i] <> nil then
    +      begin
             l:=StrLen(Lines[i]);
             DrawLine(Lines[i], l, theRect.Top);
             dec(pIndex,l+length(LineEnding));
    -      end;
    -      Inc(theRect.Top, TM.tmExternalLeading + TM.tmHeight);// space between lines
    +        GetTextExtentPoint(DC, Lines[i], l, Size);
    +        LineHeight := Size.cY;
    +      end
    +      else
    +        LineHeight := TM.tmHeight;
    +      Inc(theRect.Top, LineHeight + TM.tmExternalLeading);// space between lines
         end;
     
       finally
    
    t.diff (2,098 bytes)
  • tst-jp-label.zip (3,137 bytes)

Relationships

related to 0036292 resolvedJuha Manninen gtk3: Problem with label autosize with Japanese text 

Activities

CudaText man

2019-11-11 13:55

reporter  

gtk2-before.png (18,186 bytes)
gtk2-before.png (18,186 bytes)
gtk2-after.png (17,052 bytes)
gtk2-after.png (17,052 bytes)
t.diff (2,098 bytes)
Index: lcl/interfaces/gtk2/gtk2winapi.inc
===================================================================
--- lcl/interfaces/gtk2/gtk2winapi.inc	(revision 62230)
+++ lcl/interfaces/gtk2/gtk2winapi.inc	(working copy)
@@ -2408,6 +2408,8 @@
   l: LongInt;
   Pt: TPoint;
   SavedRect: TRect; // if font orientation <> 0
+  LineHeight: Integer;
+  Size: TSize;
 
   function LeftOffset: Longint;
   begin
@@ -2453,7 +2455,7 @@
   var
     AP: TSize;
     J, MaxWidth,
-    LineWidth: Integer;
+    LineWidth, ActualHeight: Integer;
   begin
     theRect := Rect;
 
@@ -2497,6 +2499,7 @@
       if (Flags and DT_CALCRECT)<>0 then
       begin
         LineWidth := 0;
+        ActualHeight := 0;
         if (Lines <> nil) then
         begin
           for J := 0 to NumLines - 1 do
@@ -2503,14 +2506,18 @@
           begin
             TextExtentPoint(Lines[J], StrLen(Lines[J]), AP);
             LineWidth := Max(LineWidth, AP.cX);
+            Inc(ActualHeight, AP.cY);
           end;
         end;
         LineWidth := Min(MaxWidth, LineWidth);
       end else
+      begin
         LineWidth := MaxWidth;
+        ActualHeight := NumLines*TM.tmHeight;
+      end;
 
       theRect.Right := theRect.Left + LineWidth;
-      theRect.Bottom := theRect.Top + NumLines*TM.tmHeight;
+      theRect.Bottom := theRect.Top + ActualHeight;
       if NumLines>1 then
         Inc(theRect.Bottom, (NumLines-1)*TM.tmExternalLeading);// space between lines
 
@@ -2771,12 +2778,17 @@
       and (tm.tmHeight > (theRect.Bottom - theRect.Top))
       then Break;
 
-      if Lines[i] <> nil then begin
+      if Lines[i] <> nil then
+      begin
         l:=StrLen(Lines[i]);
         DrawLine(Lines[i], l, theRect.Top);
         dec(pIndex,l+length(LineEnding));
-      end;
-      Inc(theRect.Top, TM.tmExternalLeading + TM.tmHeight);// space between lines
+        GetTextExtentPoint(DC, Lines[i], l, Size);
+        LineHeight := Size.cY;
+      end
+      else
+        LineHeight := TM.tmHeight;
+      Inc(theRect.Top, LineHeight + TM.tmExternalLeading);// space between lines
     end;
 
   finally
t.diff (2,098 bytes)

CudaText man

2019-11-11 13:56

reporter  

tst-jp-label.zip (3,137 bytes)

Juha Manninen

2019-11-12 23:29

developer   ~0119245

Applied, thanks.

Issue History

Date Modified Username Field Change
2019-11-11 13:55 CudaText man New Issue
2019-11-11 13:55 CudaText man File Added: gtk2-before.png
2019-11-11 13:55 CudaText man File Added: gtk2-after.png
2019-11-11 13:55 CudaText man File Added: t.diff
2019-11-11 13:56 CudaText man File Added: tst-jp-label.zip
2019-11-12 23:14 Juha Manninen Relationship added related to 0036292
2019-11-12 23:19 Juha Manninen Assigned To => Juha Manninen
2019-11-12 23:19 Juha Manninen Status new => assigned
2019-11-12 23:29 Juha Manninen Status assigned => resolved
2019-11-12 23:29 Juha Manninen Resolution open => fixed
2019-11-12 23:29 Juha Manninen Fixed in Revision => r62231
2019-11-12 23:29 Juha Manninen LazTarget => -
2019-11-12 23:29 Juha Manninen Widgetset GTK 2 => GTK 2
2019-11-12 23:29 Juha Manninen Note Added: 0119245