Hi
 as in subject
work with UTF8 and color
Darek

PS. how to discover on runtime which widgetset is running
Index: interfaces/gtk/gtklclintf.inc
===================================================================
--- interfaces/gtk/gtklclintf.inc       (wersja 9179)
+++ interfaces/gtk/gtklclintf.inc       (kopia robocza)
@@ -288,11 +288,7 @@
 function TGTKWidgetSet.FontCanUTF8(Font: HFont): boolean;
 begin
   Result:=IsValidGDIObject(Font) and
-{$IFDEF GTK2}
- 
FontIsDoubleByteCharsFont(gdk_font_from_description(PGdiObject(Font)^.GDIFontObject));
-{$ELSE GTK2}
- FontIsDoubleByteCharsFont(PGdiObject(Font)^.GDIFontObject);
-{$ENDIF GTK2}
+  FontIsDoubleByteCharsFont(PGdiObject(Font)^.GDIFontObject);
 end;
 
 {------------------------------------------------------------------------------
Index: interfaces/gtk2/gtk2winapi.inc
===================================================================
--- interfaces/gtk2/gtk2winapi.inc      (wersja 9179)
+++ interfaces/gtk2/gtk2winapi.inc      (kopia robocza)
@@ -134,13 +134,12 @@
       if IsFontNameXLogicalFontDesc(LongFontName) then
           if  (PointSize <> '') and  (CompareText(PointSize,'*')<>0) then
             sizeFont:=StrToInt(PointSize) div 10;
-      if sizeFont = 0 then sizeFont:=abs(lfHeight);
-      if sizeFont = 0 then sizeFont:=12;
+      if (sizeFont=0) and (lfHeight=0) then sizeFont:=10;
 
 
 
 
-      FullString := FamilyName + ' '+ IntToStr(sizeFont );
+      FullString := FamilyName + ' ' + IntToStr(sizeFont );
 
       if FontNameRegistry='' then ;
       if Foundry='' then ;
@@ -161,14 +160,17 @@
       if lfWeight <> FW_DONTCARE then
         pango_font_description_set_weight(GdiObject^.GDIFontObject, lfWeight);
 
-      if lfItalic = 0 then
+      if lfItalic <> 0 then
         pango_font_description_set_style(GdiObject^.GDIFontObject,
-                                         PANGO_STYLE_NORMAL)
-      else
-        pango_font_description_set_style(GdiObject^.GDIFontObject,
                                          PANGO_STYLE_ITALIC);
-      if lfHeight<>0 then
-        
pango_font_description_set_size(GdiObject^.GDIFontObject,abs(lfHeight)*PANGO_SCALE);
+      if (sizefont=0) and (lfHeight<>0) then begin
+//      when Pango >1.8
+//        
pango_font_description_set_absolute_size(GdiObject^.GDIFontObject,abs(lfHeight)*PANGO_SCALE);
+        if lfHeight<0 then
+           
pango_font_description_set_size(GdiObject^.GDIFontObject,(abs(lfHeight)*72*PANGO_SCALE)
 div 96)
+        else
+           
pango_font_description_set_size(GdiObject^.GDIFontObject,abs(lfHeight)*PANGO_SCALE)
 ;
+      end;
 
       GdiObject^.StrikeOut := lfStrikeOut <> 0;
       GdiObject^.Underline := lfUnderline <> 0;
@@ -339,7 +341,7 @@
           TopY := Y;
           UpdateDCTextMetric(TDeviceContext(DC));
           TxtPt.X := X + DCOrigin.X;
-          LineHeight := DCTextMetric.TextMetric.tmAscent;
+          LineHeight := DCTextMetric.TextMetric.tmHeight;
           TxtPt.Y := TopY + LineHeight + DCOrigin.Y;
 
           SelectedColors := dcscCustom;
@@ -355,14 +357,14 @@
           end;
 
           EnsureGCColor(DC, dccCurrentTextColor, True, False);
-          RGBColor := ColorToRGB(CurrentTextColor.ColorRef);
+{          RGBColor := ColorToRGB(CurrentTextColor.ColorRef);
 
           Attr := pango_attr_foreground_new(gushort(GetRValue(RGBColor)) shl 8,
                                             gushort(GetGValue(RGBColor)) shl 8,
                                             gushort(GetBValue(RGBColor)) shl 
8);
 
           pango_attr_list_change(AttrList,Attr);
-
+}
           pango_layout_set_attributes(Layout, AttrList);
 
           Foreground := StyleForegroundColor(CurrentTextColor.ColorRef, nil);
@@ -549,7 +551,6 @@
   StrikeOut : Boolean;
 
   RGBColor : Longint;
-  Foreground : PGDKColor;
   Layout : PPangoLayout;
   UseFontDesc : PPangoFontDescription;
   AttrList : PPangoAttrList;
@@ -602,21 +603,8 @@
         pango_attr_list_change(AttrList,Attr);
 
         SelectedColors := dcscCustom;
-        EnsureGCColor(DC, dccCurrentBackColor, True, False);
         EnsureGCColor(DC, dccCurrentTextColor, True, False);
-
-        RGBColor := ColorToRGB(CurrentTextColor.ColorRef);
-
-        Attr := pango_attr_foreground_new(gushort(GetRValue(RGBColor)) shl 8,
-                                        gushort(GetGValue(RGBColor)) shl 8,
-                                        gushort(GetBValue(RGBColor)) shl 8);
-
-        pango_attr_list_change(AttrList,Attr);
-        
         pango_layout_set_attributes(Layout, AttrList);
-
-        Foreground := StyleForegroundColor(CurrentTextColor.ColorRef, nil);
-
         pango_layout_set_single_paragraph_mode(Layout, TRUE);
         pango_layout_set_width(Layout, -1);
 
@@ -635,7 +623,7 @@
 
         OffsetRect(aRect, X+DCOrigin.X,Y+DCOrigin.Y);
 
-        gdk_draw_layout_with_colors(drawable, GC, aRect.Left, aRect.Top, 
Layout, Foreground, nil);
+        gdk_draw_layout_with_colors(drawable, GC, aRect.Left, aRect.Top, 
Layout, nil, nil);
         g_object_unref(Layout);
         Result := True;
         If UnRef then
Index: interfaces/gtk2/gtk2lclintf.inc
===================================================================
--- interfaces/gtk2/gtk2lclintf.inc     (wersja 9179)
+++ interfaces/gtk2/gtk2lclintf.inc     (kopia robocza)
@@ -30,6 +30,29 @@
 
 //##apiwiz##sps##   // Do not remove
 
+function TGtk2WidgetSet.ExtUTF8Out(DC: HDC; X, Y: Integer; Options: Longint;
+  Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean;
+begin
+    Result:=ExtTextOut(DC,X,Y,Options,Rect,Str,Count,Dx);
+end;
+function TGtk2WidgetSet.TextUTF8Out(DC: HDC; X, Y: Integer; Str: PChar; Count: 
Longint): Boolean;
+begin
+    Result:=TextOut(DC,X,Y,Str,Count);
+end;
 
+
+{------------------------------------------------------------------------------
+  function TGTKWidgetSet.FontCanUTF8(Font: HFont): boolean;
+
+  True if font recognizes Unicode.
+ 
------------------------------------------------------------------------------}
+function TGTK2WidgetSet.FontCanUTF8(Font: HFont): boolean;
+begin
+  Result:=IsValidGDIObject(Font) and
+ 
FontIsDoubleByteCharsFont(gdk_font_from_description(PGdiObject(Font)^.GDIFontObject));
+end;
+
+
+
 //##apiwiz##eps##   // Do not remove, no wizard declaration after this line
 
Index: interfaces/gtk2/gtk2lclintfh.inc
===================================================================
--- interfaces/gtk2/gtk2lclintfh.inc    (wersja 9179)
+++ interfaces/gtk2/gtk2lclintfh.inc    (kopia robocza)
@@ -29,6 +29,11 @@
 }
 
 //##apiwiz##sps##   // Do not remove
+function ExtUTF8Out(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect;
+  Str: PChar; Count: Longint; Dx: PInteger): Boolean; override;
+function TextUTF8Out(DC: HDC; X, Y: Integer; Str: PChar; Count: Longint): 
Boolean; override;
+function FontCanUTF8(Font: HFont): boolean; override;
 
+
 //##apiwiz##eps##   // Do not remove, no wizard declaration after this line
 

Reply via email to