Re: [ROOT] changing the GUI font locally

From: Christian Holm Christensen (cholm@hehi03.nbi.dk)
Date: Tue Aug 14 2001 - 08:47:09 MEST


Hi Stephane, 

On Mon, 13 Aug 2001 19:27:34 -0500 (CDT)
Stephane Tourneur <tourneur@fnal.gov> wrote
concerning ": [ROOT] changing the GUI font locally":
> 
> Dear rooters,
> 
> I'm using the GUI class TGLabel to display some titles in my
> root application.
> But the default font is very small. I'd like to have my titles more or
> less bigger.
> I already know that we can globally change the GUI default size by editing 
> a .rootrc file where we can increase the numbers 10 and 12 :
> 
> {//.rootrc file
> Gui.NormalFont: -adobe-helvetica-medium-r-*-*-12-*-*-*-*-*-iso8859-1
> Gui.BoldFont: -adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-iso8859-1
> Gui.SmallFont: -adobe-helvetica-medium-r-*-*-10-*-*-*-*-*-iso8859-1
> Gui.ProportionalFont: -adobe-courier-medium-r-*-*-10-*-*-*-*-*-iso8859-1
> }
> 
> But, does somebody know how to do it in a less global way, that is to say
> how to use several different fonts for different GUI objects of an
> application?
> Thanks a lot for your help

Have a member/variable of class TGGC, and FontStruct_t
member/variable: 
  
  FontStruct_t fFontStruct       = gClient->GetFontByName(name); 
  TGGC*        fGraphicsContext  = new TGGC(TGLabel::GetDefaultGC());
  fGraphicsContext->SetFont(gVirtualX->GetFontHandle(fFontStruct));

where name is the name of your font, like in the .rootrc file. 

Use the TGGC object with the GUI CTOR.  Remember to delete it when not
used anymore. AFAIK, the TGGC are _not_ adopted by the GUI classes. 

Using your custom Graphics Context (TGGC) you can set all sorts of
things.  Please refer to 

  http://root.cern.ch/root/html/TGGC.html 

Also do a search on roottalk: Your question has been asked before! 

Yours, 

Christian Holm Christensen -------------------------------------------
Address: Sankt Hansgade 23, 1. th.           Phone:  (+45) 35 35 96 91 
         DK-2200 Copenhagen N                Cell:   (+45) 28 82 16 23
         Denmark                             Office: (+45) 353  25 305 
Email:   cholm@nbi.dk                        Web:    www.nbi.dk/~cholm



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:57 MET