On Mon, 27 Feb 2006 18:28:04 +0200
"A.J. Venter" <[EMAIL PROTECTED]> wrote:

> 
> > >
> > > If this is possible, then this is *the* way to go.
> >
> > At least I know it is possible for gtk2 - I implemented dynamic fonts in
> > one of my (C++, unfortunately) programs. The documentation seems to talk
> > about the font code as something New and Improved (tm), so I'd say it's
> > quite hard in gtk1.
> Well I could find the documentation on how to do it, but the actual method
> 
> isn't implemented somewhere, it is not impossible that the PLACE where it
> is  missing is in the FPC units, but since those were autogenerated my
> gutt tells  me that it is more likely to be somewhere in the LCL.
> 
> I am not exactly sure how the GTK2 objects were turned into OP classes for
> the  LCL, I would have to look at the wrapper code first, my feeling
> however is  that the likely scenario is that somewhere an external
> declaration needs to  be added that can enable GTKWidget.Modify_font from
> the GTK2 libs.
> 
> GTK1 already has support for this, and if I I didn't REALLY need UTF-8
> support  for text-out I would have just compiled my app for GTK1 instead
> but since I  don't know how, and it would be GREAT if this works, I am
> happy to help write  code to make it happen, if I can get help from some
> of the gtk2 guru's it  would just happen faster. 
> 
> My current code:
> In gtk2object.inc add this (I put mine just above TGTKWidget.SetCallBack):
> Procedure TGTK2WidgetSet.SetWidgetFont(const AWidget: PGTK2Widget; const 
> Afont: tFont);
> Var
>   PangoDescStr,DescOpts : String;
>   NewFontDescription : PPangoFontDescription;
> 
> Begin
> {$IFDEF GTK2}
>         PangoDescStr := AFont.Name;
>         DescOpts := '';
>       If FSBold in AFont.Style then
>                 DescOpts := DescOpts + ' bold';
>       If FSItalic in AFont.Style then
>                 DescOpts := DescOpts + ' italic';
>       If FSUnderline in AFont.Style then
>                 DescOpts := DescOpts + ' underline';
>       If FSStrikeOut in AFont.Style then
>                 DescOpts := DescOpts + ' strikethrough';
> 
>        PangoDescStr := PangoDescStr+DescOpts+' '+intToStr(Afont.Size);
> //Pango does not appear to have a way to set the character set in the
> //font description but seems to default to UTF-8 this probably
> //requires some or other todo item.
> try
>         NewFontDescription := PPangoFontDescription(PangoDescStr);
>         AWidget.Modify_Font(NewFontDescription);

I will take a look ...

Mattias



> 
> except
>         debugln('COULD NOT SET FONT');
> end;
> {$ENDIF}
> end;
> 
> 
> In GTK2Int.pas  change
>   protected
>     procedure AppendText(Sender: TObject; Str: PChar);
> to:
>   protected
>     procedure SetWidgetFont(const AWidget: PGTK2Widget; const Afont:
>     tFont); procedure AppendText(Sender: TObject; Str: PChar);
> 
> Note that the current code DOES NOT COMPILE due to the missing
> Modify_Font.
> 
> PS. Thanks Darek, I managed to get THIS far by studying your patch and
> will  look at it again when doing the per-widget bits.
> 
> PPS. As you can see, right now tfont.color is NOT yet handled at all.
> 
> Ciao
> A.J.
> 

_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to