Yeah! It works! Some bugs occurs, but I'm happy with the Lazarus evolution!
Congratulations

[]'s

darekm wrote:


DarekM wrote:

Hi
I'm proud to anons: Lazarus  under GTK2 don't crash

In patch:
conversion TFont to tLogFont in RetrieveLogFontForComparison
crash when empty in  Gtk2_ItemSelectionChanged
bug in extTextOut - maybe not all changes I have put to patch,

Darek

Index: components/synedit/syntextdrawer.pp =================================================================== --- components/synedit/syntextdrawer.pp (wersja 9401) +++ components/synedit/syntextdrawer.pp (kopia robocza) @@ -555,17 +555,48 @@ procedure TheFontsInfoManager.RetrieveLogFontForComparison(ABaseFont: TFont; var LF: TLogFont); -var - pEnd: PChar; + + procedure SetLogFontName(const NewName: string); + var l: integer; + aName: string; + begin + if IsFontNameXLogicalFontDesc(NewName) then + aName:=ExtractFamilyFromXLFDName(NewName) + else + aName:=NewName; + l:=High(LF.lfFaceName)-Low(LF.lfFaceName); + if l>length(aName) then l:=length(aName); + if l>0 then + Move(aName[1],LF.lfFaceName[Low(LF.lfFaceName)],l); + LF.lfFaceName[Low(LF.lfFaceName)+l]:=#0; + end; + + begin - GetObject(ABaseFont.Handle, SizeOf(TLogFont), @LF); with LF do begin + FillChar(LF,SizeOf(LF),0); + lfHeight := ABaseFont.Height; + lfWidth := 0; + lfEscapement := 0; + lfOrientation := 0; + + if fsBold in ABaseFont.Style then lfWeight:=FW_BOLD + else lfWeight:=FW_NORMAL; + lfCharSet := Byte(ABaseFont.Charset); + SetLogFontName(aBaseFont.Name); + lfQuality := DEFAULT_QUALITY; + lfOutPrecision := OUT_DEFAULT_PRECIS; + lfClipPrecision := CLIP_DEFAULT_PRECIS; + case ABaseFont.Pitch of + fpVariable: lfPitchAndFamily := VARIABLE_PITCH; + fpFixed: lfPitchAndFamily := FIXED_PITCH; + else + lfPitchAndFamily := DEFAULT_PITCH; + end; lfItalic := 0; lfUnderline := 0; lfStrikeOut := 0; - pEnd := StrEnd(lfFaceName); - FillChar(pEnd[1], @lfFaceName[High(lfFaceName)] - Pointer(pEnd), 0); end; end;

Index: lcl/interfaces/gtk2/gtk2winapi.inc
===================================================================
--- lcl/interfaces/gtk2/gtk2winapi.inc	(wersja 9406)
+++ lcl/interfaces/gtk2/gtk2winapi.inc	(kopia robocza)
@@ -82,7 +82,7 @@
         Exit;
       end;
       
-      if CompareText(lfFacename,'default')=0 then begin
+      if  (lfHeight=0) and (CompareText(lfFacename,'default')=0) then begin
         LoadDefaultFont;
         Result := HFONT(GdiObject);
         exit;
@@ -112,8 +112,8 @@
       else
         FullString:=IntToStr(aSize);
       FullString := AFamily + ' ' + aStyle + ' ' + FullString;
-      
 
+
       GdiObject^.GDIFontObject :=
         pango_font_description_from_string(PChar(FullString));
 
@@ -131,10 +131,10 @@
         // which would be great with the given lfheight value, but older gtk2 version
         // doesn't have this funtion
         if lfHeight<0 then
-          aSize:= (abs(lfheight) * 72) div ScreenInfo.PixelsPerInchX
+          aSize:= (abs(lfheight) * 72 * PANGO_SCALE) div ScreenInfo.PixelsPerInchX
         else
-          aSize:=lfHeight;
-        pango_font_description_set_size( GdiObject^.GDIFontObject, aSize*PANGO_SCALE);
+          aSize:=lfHeight*PANGO_SCALE;
+        pango_font_description_set_size( GdiObject^.GDIFontObject, aSize);
       end;
 
 
@@ -219,7 +219,7 @@
       aRect := Classes.Rect(0,0,0,0);
       pango_layout_get_pixel_size(Layout, @arect.Right, @arect.Bottom);
 
-      OffsetRect(aRect, X+DCOrigin.X,Y+DCOrigin.Y);
+      OffsetRect(aRect, X,Y);
 
       gdk_draw_layout_with_colors(drawable, gc, aRect.Left, aRect.Top, Layout, Foreground, nil);
     end;
@@ -307,7 +307,7 @@
           UpdateDCTextMetric(TDeviceContext(DC));
           TxtPt.X := X + DCOrigin.X;
           LineHeight := DCTextMetric.TextMetric.tmHeight;
-          TxtPt.Y := TopY + LineHeight + DCOrigin.Y;
+          TxtPt.Y := TopY  + DCOrigin.Y;
 
           SelectedColors := dcscCustom;
 
@@ -499,11 +499,10 @@
   Count: Integer) : Boolean;
 var
   DCOrigin: TPoint;
-  aRect : TRect;
-
   UnRef,
   Underline,
   StrikeOut : Boolean;
+  yOffset   : integer;
 
   Layout : PPangoLayout;
   UseFontDesc : PPangoFontDescription;
@@ -537,6 +536,9 @@
         DebugLn('WARNING: [TGtk2WidgetSet.TextOut] Missing Font')
       else begin
         DCOrigin:=GetDCOffset(TDeviceContext(DC));
+        with DCTextMetric.TextMetric do
+          yOffset:= tmHeight-tmDescent-tmAscent;
+        if yOffset<0 then yOffset:=0;
         GetStyle(lgsdefault);
         Layout := gtk_widget_create_pango_layout (GetStyleWidget(lgsdefault), nil);
         pango_layout_set_font_description(Layout, UseFontDesc);
@@ -571,15 +573,9 @@
         //cross-compatibility with GTK1.2 and win32 interfaces.....
 
         pango_layout_set_text(Layout, Str, Count);
-
-        aRect := Rect(0,0,0, 0);
-        pango_layout_get_pixel_size(Layout, @arect.Right, @arect.Bottom);
-
-        OffsetRect(aRect, X+DCOrigin.X,Y+DCOrigin.Y);
-
         EnsureGCColor(DC, dccCurrentTextColor, True, False);
 
-        gdk_draw_layout_with_colors(drawable, GC, aRect.Left, aRect.Top, Layout, nil, nil);
+        gdk_draw_layout_with_colors(drawable, GC, X+DCOrigin.X, Y+DCOrigin.Y+yOffset, Layout, nil, nil);
         g_object_unref(Layout);
         Result := True;
         If UnRef then
Index: lcl/interfaces/gtk2/gtk2object.inc
===================================================================
--- lcl/interfaces/gtk2/gtk2object.inc	(wersja 9406)
+++ lcl/interfaces/gtk2/gtk2object.inc	(kopia robocza)
@@ -1,3 +1,4 @@
+{%MainUnit gtk2int.pp}
 {******************************************************************************
                                    TGtk2WidgetSet
  ******************************************************************************
Index: lcl/interfaces/gtk2/gtk2wscustomlistview.inc
===================================================================
--- lcl/interfaces/gtk2/gtk2wscustomlistview.inc	(wersja 9406)
+++ lcl/interfaces/gtk2/gtk2wscustomlistview.inc	(kopia robocza)
@@ -142,6 +142,10 @@
   //DebugLn('Gtk2_ItemSelectionChanged');
   Widgets := PTVWidgets(WidgetInfo^.UserData);
   msg.Msg := CN_NOTIFY;
+  if (widgets=nil) or (Widgets^.ItemCache=nil) or (Widgets^.ItemCache.Count=0) then begin
+    debugln(' Gtk2_ItemSelectionChanged  ItemChache=nil ',tComponent(widgetInfo^.lclObject).name);
+    exit;
+  end;
   for i := 0 to Widgets^.ItemCache.Count -1 do begin
 
     FillChar(NM, SizeOf(NM), 0);

  


--
Fernando Kochhann
Fone: (51) 3714 6653
Rua Comandante Wagner, 12
Bairro São Cristóvão
95900-000 Lajeado - RS

Reply via email to