View Issue Details

IDProjectCategoryView StatusLast Update
0026660LazarusWidgetsetpublic2014-09-07 10:14
ReporterZeljan Rikalo Assigned ToZeljan Rikalo  
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product Version1.3 (SVN) 
Summary0026660: Gtk2: GetObject() does not return correct font height
DescriptionTGtk2WinApi.GetObject() should return lfHeight of HFONT (when it's param of function), but it doesn't so, eg ScaleBy() does not work as expected.
Attached possible fix.
TagsNo tags attached.
Fixed in Revision46112
LazTarget-
WidgetsetGTK 2
Attached Files

Relationships

related to 0026652 confirmed ScaleBy does not shrink font size 

Activities

Zeljan Rikalo

2014-08-31 16:28

developer  

gtk2winapigetobject_hfont_fix.diff (1,386 bytes)   
Index: lcl/interfaces/gtk2/gtk2winapi.inc
===================================================================
--- lcl/interfaces/gtk2/gtk2winapi.inc	(revision 46095)
+++ lcl/interfaces/gtk2/gtk2winapi.inc	(working copy)
@@ -5137,6 +5137,7 @@
   AFontName: String;
   PangoDesc: PPangoFontDescription;
   i, RequiredSize: Integer;
+  AFontSize: gint;
 begin
   Result := 0;
   if not IsValidGDIObject(GDIObj) then Exit;
@@ -5177,6 +5178,22 @@
 
             if AFontName <> '' then
               PLogfont(Buf)^.lfFaceName := AFontName;
+          end else
+          if (GDIObject^.GDIFontObject <> nil) then
+          begin
+            AFont := GDIObject^.GDIFontObject;
+            if PANGO_IS_LAYOUT(AFont) then
+            begin
+              PangoDesc := pango_layout_get_font_description(GDIObject^.GDIFontObject);
+              if PangoDesc = nil then
+                PangoDesc := pango_context_get_font_description(pango_layout_get_context(AFont));
+
+              AFontSize := pango_font_description_get_size(PangoDesc);
+              if not pango_font_description_get_size_is_absolute(PangoDesc) or (AFontSize >= PANGO_SCALE) then
+                AFontSize := AFontSize div PANGO_SCALE;
+
+              PLogfont(Buf)^.lfHeight := MulDiv(AFontSize, GetDeviceCaps(0, LOGPIXELSX) , 72);
+            end;
           end;
         end else
         if BufSize > 0 then

Zeljan Rikalo

2014-09-03 09:40

developer   ~0076856

Works fine now. eg ScaleBy() now works correct.

Zeljan Rikalo

2014-09-07 10:14

developer   ~0076946

Works ok.

Issue History

Date Modified Username Field Change
2014-08-31 16:28 Zeljan Rikalo New Issue
2014-08-31 16:28 Zeljan Rikalo File Added: gtk2winapigetobject_hfont_fix.diff
2014-08-31 18:31 Zeljan Rikalo Assigned To => Zeljan Rikalo
2014-08-31 18:31 Zeljan Rikalo Status new => assigned
2014-09-03 09:40 Zeljan Rikalo Fixed in Revision => 46112
2014-09-03 09:40 Zeljan Rikalo Note Added: 0076856
2014-09-03 09:40 Zeljan Rikalo Status assigned => resolved
2014-09-03 09:40 Zeljan Rikalo Resolution open => fixed
2014-09-03 15:17 Bart Broersma Relationship added has duplicate 0026652
2014-09-03 16:09 Zeljan Rikalo Relationship deleted has duplicate 0026652
2014-09-03 16:10 Zeljan Rikalo Relationship added related to 0026652
2014-09-07 10:14 Zeljan Rikalo Note Added: 0076946
2014-09-07 10:14 Zeljan Rikalo Status resolved => closed