1 ///////////////////////////////////////////////////////////////////////////// 
   3 // Purpose:     wxFont class 
   4 // Author:      David Webster 
   8 // Copyright:   (c) David Webster 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  12 // For compilers that support precompilation, includes "wx.h". 
  13 #include "wx/wxprec.h" 
  15 // ============================================================================ 
  17 // ============================================================================ 
  19 // ---------------------------------------------------------------------------- 
  21 // ---------------------------------------------------------------------------- 
  33 #include "wx/os2/private.h" 
  35 #include "wx/fontutil.h" 
  36 #include "wx/fontmap.h" 
  37 #include "wx/encinfo.h" 
  39 #include "wx/tokenzr.h" 
  43 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
) 
  45 // ---------------------------------------------------------------------------- 
  46 // wxFontRefData - the internal description of the font 
  47 // ---------------------------------------------------------------------------- 
  49 class WXDLLEXPORT wxFontRefData
: public wxGDIRefData
 
  54         Init(-1, wxFONTFAMILY_DEFAULT
, wxFONTSTYLE_NORMAL
, wxFONTWEIGHT_NORMAL
, FALSE
, 
  55              wxEmptyString
, wxFONTENCODING_DEFAULT
); 
  58     wxFontRefData( int             nSize
 
  63                   ,const wxString
& sFaceName
 
  64                   ,wxFontEncoding  vEncoding
 
  77     wxFontRefData( const wxNativeFontInfo
& rInfo
 
  88     wxFontRefData(const wxFontRefData
& rData
) 
  90         Init( rData
.m_nPointSize
 
  98         m_nFontId 
= rData
.m_nFontId
; 
 101     virtual ~wxFontRefData(); 
 106     bool Alloc(wxFont
* pFont
); 
 110     // All wxFont accessors 
 112     inline int GetPointSize(void) const 
 115         // We don't use the actual native font point size since it is 
 116         // the chosen physical font, which is usually only and approximation 
 117         // of the desired outline font.  The actual displayable point size 
 118         // is the one stored in the refData 
 123     inline int GetFamily(void) const 
 128     inline int GetStyle(void) const 
 130         return m_bNativeFontInfoOk 
? m_vNativeFontInfo
.GetStyle() 
 134     inline int GetWeight(void) const 
 136         return m_bNativeFontInfoOk 
? m_vNativeFontInfo
.GetWeight() 
 140     inline bool GetUnderlined(void) const 
 142         return m_bNativeFontInfoOk 
? m_vNativeFontInfo
.GetUnderlined() 
 146     inline wxString 
GetFaceName(void) const 
 150         if (m_bNativeFontInfoOk
) 
 151             sFaceName 
= m_vNativeFontInfo
.GetFaceName(); 
 153             sFaceName 
= m_sFaceName
; 
 158     inline wxFontEncoding 
GetEncoding(void) const 
 160         return m_bNativeFontInfoOk 
? m_vNativeFontInfo
.GetEncoding() 
 164     inline WXHFONT      
GetHFONT(void) const { return m_hFont
; } 
 165     inline HPS          
GetPS(void) const { return m_hPS
; } 
 166     inline PFONTMETRICS 
GetFM(void) const { return m_pFM
; } 
 167     inline int          GetNumFonts(void) const { return m_nNumFonts
; } 
 170     inline void SetPointSize(int nPointSize
) 
 172         if (m_bNativeFontInfoOk
) 
 173             m_vNativeFontInfo
.SetPointSize(nPointSize
); 
 175             m_nPointSize 
= nPointSize
; 
 178     inline void SetFamily(int nFamily
) 
 183     inline void SetStyle(int nStyle
) 
 185         if (m_bNativeFontInfoOk
) 
 186             m_vNativeFontInfo
.SetStyle((wxFontStyle
)nStyle
); 
 191     inline void SetWeight(int nWeight
) 
 193         if (m_bNativeFontInfoOk
) 
 194             m_vNativeFontInfo
.SetWeight((wxFontWeight
)nWeight
); 
 199     inline void SetFaceName(const wxString
& sFaceName
) 
 201         if (m_bNativeFontInfoOk
) 
 202             m_vNativeFontInfo
.SetFaceName(sFaceName
); 
 204             m_sFaceName 
= sFaceName
; 
 207     inline void SetUnderlined(bool bUnderlined
) 
 209         if (m_bNativeFontInfoOk
) 
 210             m_vNativeFontInfo
.SetUnderlined(bUnderlined
); 
 212             m_bUnderlined 
= bUnderlined
; 
 215     inline void SetEncoding(wxFontEncoding vEncoding
) 
 217         if (m_bNativeFontInfoOk
) 
 218             m_vNativeFontInfo
.SetEncoding(vEncoding
); 
 220             m_vEncoding 
= vEncoding
; 
 223     inline void SetPS(HPS hPS
) 
 228     inline void SetFM(PFONTMETRICS pFM
) 
 233     inline void SetNumFonts(int nNumFonts
) 
 235         m_nNumFonts 
= nNumFonts
; 
 239     // Native font info tests 
 241     bool HasNativeFontInfo() const { return m_bNativeFontInfoOk
; } 
 243     const wxNativeFontInfo
& GetNativeFontInfo() const 
 244         { return m_vNativeFontInfo
; } 
 248     // Common part of all ctors 
 255               ,const wxString
& rsFaceName
 
 256               ,wxFontEncoding  vEncoding
 
 259     void Init( const wxNativeFontInfo
& rInfo
 
 264     // If true, the pointer to the actual font is temporary and SHOULD NOT BE 
 265     // DELETED by destructor 
 271     // Font characterstics 
 278     wxString                        m_sFaceName
; 
 279     wxFontEncoding                  m_vEncoding
; 
 285     wxNativeFontInfo                m_vNativeFontInfo
; 
 286     bool                            m_bNativeFontInfoOk
; 
 289     // Some PM specific stuff 
 291     PFONTMETRICS                    m_pFM
;         // array of FONTMETRICS structs 
 292     int                             m_nNumFonts
;   // number of fonts in array 
 293     HPS                             m_hPS
;         // PS handle this font belongs to 
 294     FATTRS                          m_vFattrs
;     // Current fattrs struct 
 295     FACENAMEDESC                    m_vFname
;      // Current facename struct 
 296     bool                            m_bInternalPS
; // Internally generated PS? 
 297 }; // end of CLASS wxFontRefData 
 299 // ============================================================================ 
 301 // ============================================================================ 
 303 // ---------------------------------------------------------------------------- 
 305 // ---------------------------------------------------------------------------- 
 307 void wxFontRefData::Init( 
 313 , const wxString
&                   rsFaceName
 
 314 , wxFontEncoding                    vEncoding
 
 318     m_nPointSize  
= nPointSize
; 
 322     m_bUnderlined 
= bUnderlined
; 
 323     m_sFaceName   
= rsFaceName
; 
 324     m_vEncoding   
= vEncoding
; 
 327     m_bNativeFontInfoOk 
= FALSE
; 
 330     m_bTemporary  
= FALSE
; 
 331     m_pFM         
= (PFONTMETRICS
)NULL
; 
 334 } // end of wxFontRefData::Init 
 336 void wxFontRefData::Init( 
 337   const wxNativeFontInfo
&           rInfo
 
 338 , WXHFONT                           hFont 
//this is the FontId -- functions as the hFont for OS/2 
 339 , WXHANDLE                          hPS   
// Presentation Space we are using 
 343     // hFont may be zero, or it be passed in case we really want to 
 344     // use the exact font created in the underlying system 
 345     // (for example where we can't guarantee conversion from HFONT 
 346     // to LOGFONT back to HFONT) 
 349     m_nFontId 
= (int)hFont
; 
 351     m_bNativeFontInfoOk 
= true; 
 352     m_vNativeFontInfo 
= rInfo
; 
 354     if (hPS 
== NULLHANDLE
) 
 356         m_hPS 
= ::WinGetPS(HWND_DESKTOP
); 
 357         m_bInternalPS 
= true; 
 363     m_bTemporary  
= FALSE
; 
 364     m_pFM         
= (PFONTMETRICS
)NULL
; 
 366 } // end of wxFontRefData::Init 
 368 wxFontRefData::~wxFontRefData() 
 373 bool wxFontRefData::Alloc( wxFont
* pFont 
) 
 381     if (!m_bNativeFontInfoOk
) 
 383         wxFillLogFont( &m_vNativeFontInfo
.fa
 
 384                       ,&m_vNativeFontInfo
.fn
 
 391         m_bNativeFontInfoOk 
= true; 
 402     if((lRc 
= ::GpiCreateLogFont( m_hPS
 
 405                                  ,&m_vNativeFontInfo
.fa
 
 408        m_hFont 
= (WXHFONT
)flId
; 
 413         vError 
= ::WinGetLastError(vHabmain
); 
 414         sError 
= wxPMErrorToStr(vError
); 
 415         wxLogLastError(wxT("CreateFont")); 
 418     ::GpiSetCharSet(m_hPS
, flId
); // sets font for presentation space 
 419     ::GpiQueryFontMetrics(m_hPS
, sizeof(FONTMETRICS
), &m_vNativeFontInfo
.fm
); 
 422     // Set refData members with the results 
 424     memcpy(&m_vFattrs
, &m_vNativeFontInfo
.fa
, sizeof(m_vFattrs
)); 
 425     memcpy(&m_vFname
, &m_vNativeFontInfo
.fn
, sizeof(m_vFname
)); 
 427     // Going to leave the point size alone.  Mostly we use outline fonts 
 428     // that can be set to any point size inside of Presentation Parameters, 
 429     // regardless of whether or not the actual font is registered in the system. 
 430     // The GpiCreateLogFont will do enough by selecting the right family, 
 433     if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Times New Roman") == 0) 
 435     else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Times New Roman MT 30") == 0) 
 437     else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "@Times New Roman MT 30") == 0) 
 439     else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Tms Rmn") == 0) 
 441     else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "WarpSans") == 0) 
 442         m_nFamily 
= wxDECORATIVE
; 
 443     else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Helvetica") == 0) 
 445     else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Helv") == 0) 
 447     else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Script") == 0) 
 448         m_nFamily 
= wxSCRIPT
; 
 449     else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Courier New") == 0) 
 450         m_nFamily 
= wxTELETYPE
; 
 451     else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Courier") == 0) 
 452         m_nFamily 
= wxTELETYPE
; 
 453     else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "System Monospaced") == 0) 
 454         m_nFamily 
= wxTELETYPE
; 
 455     else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "System VIO") == 0) 
 456         m_nFamily 
= wxMODERN
; 
 457     else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "System Proportional") == 0) 
 458         m_nFamily 
= wxMODERN
; 
 459     else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Arial") == 0) 
 461     else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Swiss") == 0) 
 466     if (m_vNativeFontInfo
.fa
.fsSelection 
& FATTR_SEL_ITALIC
) 
 467         m_nStyle 
= wxFONTSTYLE_ITALIC
; 
 469         m_nStyle 
= wxFONTSTYLE_NORMAL
; 
 470     switch(m_vNativeFontInfo
.fn
.usWeightClass
) 
 472         case FWEIGHT_DONT_CARE
: 
 473             m_nWeight 
= wxFONTWEIGHT_NORMAL
; 
 477             m_nWeight 
= wxFONTWEIGHT_NORMAL
; 
 481             m_nWeight 
= wxFONTWEIGHT_LIGHT
; 
 485             m_nWeight 
= wxFONTWEIGHT_BOLD
; 
 488         case FWEIGHT_ULTRA_BOLD
: 
 489             m_nWeight 
= wxFONTWEIGHT_MAX
; 
 493             m_nWeight 
= wxFONTWEIGHT_NORMAL
; 
 495     m_bUnderlined 
= ((m_vNativeFontInfo
.fa
.fsSelection 
& FATTR_SEL_UNDERSCORE
) != 0); 
 496     m_sFaceName 
= (wxChar
*)m_vNativeFontInfo
.fa
.szFacename
; 
 497     m_vEncoding 
= wxGetFontEncFromCharSet(m_vNativeFontInfo
.fa
.usCodePage
); 
 500     // We don't actuall keep the font around if using a temporary PS 
 505             ::GpiDeleteSetId( m_hPS
 
 509         ::WinReleasePS(m_hPS
); 
 513         // Select the font into the Presentation space 
 515         ::GpiSetCharSet(m_hPS
, flId
); // sets font for presentation space 
 517 } // end of wxFontRefData::Alloc 
 519 void wxFontRefData::Free() 
 523     m_pFM 
= (PFONTMETRICS
)NULL
; 
 527         ::GpiDeleteSetId(m_hPS
, 1L); /* delete the logical font          */ 
 532         ::WinReleasePS(m_hPS
); 
 534 } // end of wxFontRefData::Free 
 536 // ---------------------------------------------------------------------------- 
 538 // ---------------------------------------------------------------------------- 
 540 void wxNativeFontInfo::Init() 
 542     memset(&fa
, '\0', sizeof(FATTRS
)); 
 543 } // end of wxNativeFontInfo::Init 
 545 int wxNativeFontInfo::GetPointSize() const 
 548 } // end of wxNativeFontInfo::GetPointSize 
 550 wxFontStyle 
wxNativeFontInfo::GetStyle() const 
 552     return fa
.fsSelection 
& FATTR_SEL_ITALIC 
? wxFONTSTYLE_ITALIC 
: wxFONTSTYLE_NORMAL
; 
 553 } // end of wxNativeFontInfo::GetStyle 
 555 wxFontWeight 
wxNativeFontInfo::GetWeight() const 
 557     switch(fn
.usWeightClass
) 
 559         case FWEIGHT_DONT_CARE
: 
 560             return wxFONTWEIGHT_NORMAL
; 
 563             return wxFONTWEIGHT_NORMAL
; 
 566             return wxFONTWEIGHT_LIGHT
; 
 569             return wxFONTWEIGHT_BOLD
; 
 571         case FWEIGHT_ULTRA_BOLD
: 
 572             return wxFONTWEIGHT_MAX
; 
 574     return wxFONTWEIGHT_NORMAL
; 
 575 } // end of wxNativeFontInfo::GetWeight 
 577 bool wxNativeFontInfo::GetUnderlined() const 
 579     return ((fa
.fsSelection 
& FATTR_SEL_UNDERSCORE
) != 0); 
 580 } // end of wxNativeFontInfo::GetUnderlined 
 582 wxString 
wxNativeFontInfo::GetFaceName() const 
 584     return (wxChar
*)fm
.szFacename
; 
 585 } // end of wxNativeFontInfo::GetFaceName 
 587 wxFontFamily 
wxNativeFontInfo::GetFamily() const 
 592     // Extract family from facename 
 594     if (strcmp(fm
.szFamilyname
, "Times New Roman") == 0) 
 596     else if (strcmp(fm
.szFamilyname
, "Times New Roman MT 30") == 0) 
 598     else if (strcmp(fm
.szFamilyname
, "@Times New Roman MT 30") == 0) 
 600     else if (strcmp(fm
.szFamilyname
, "Tms Rmn") == 0) 
 602     else if (strcmp(fm
.szFamilyname
, "WarpSans") == 0) 
 603         nFamily 
= wxDECORATIVE
; 
 604     else if (strcmp(fm
.szFamilyname
, "Helvetica") == 0) 
 606     else if (strcmp(fm
.szFamilyname
, "Helv") == 0) 
 608     else if (strcmp(fm
.szFamilyname
, "Script") == 0) 
 610     else if (strcmp(fm
.szFamilyname
, "Courier New") == 0) 
 611         nFamily 
= wxTELETYPE
; 
 612     else if (strcmp(fm
.szFamilyname
, "Courier") == 0) 
 613         nFamily 
= wxTELETYPE
; 
 614     else if (strcmp(fm
.szFamilyname
, "System Monospaced") == 0) 
 615         nFamily 
= wxTELETYPE
; 
 616     else if (strcmp(fm
.szFamilyname
, "System VIO") == 0) 
 618     else if (strcmp(fm
.szFamilyname
, "System Proportional") == 0) 
 620     else if (strcmp(fm
.szFamilyname
, "Arial") == 0) 
 622     else if (strcmp(fm
.szFamilyname
, "Swiss") == 0) 
 626     return (wxFontFamily
)nFamily
; 
 627 } // end of wxNativeFontInfo::GetFamily 
 629 wxFontEncoding 
wxNativeFontInfo::GetEncoding() const 
 631     return wxGetFontEncFromCharSet(fa
.usCodePage
); 
 632 } // end of wxNativeFontInfo::GetEncoding 
 634 void wxNativeFontInfo::SetPointSize( 
 638     fm
.lEmHeight 
= (LONG
)nPointsize
; 
 639 } // end of wxNativeFontInfo::SetPointSize 
 641 void wxNativeFontInfo::SetStyle( 
 648             wxFAIL_MSG( _T("unknown font style") ); 
 651         case wxFONTSTYLE_NORMAL
: 
 654         case wxFONTSTYLE_ITALIC
: 
 655         case wxFONTSTYLE_SLANT
: 
 656             fa
.fsSelection 
|= FATTR_SEL_ITALIC
; 
 659 } // end of wxNativeFontInfo::SetStyle 
 661 void wxNativeFontInfo::SetWeight( 
 668             wxFAIL_MSG( _T("unknown font weight") ); 
 671         case wxFONTWEIGHT_NORMAL
: 
 672             fn
.usWeightClass 
= FWEIGHT_NORMAL
; 
 675         case wxFONTWEIGHT_LIGHT
: 
 676             fn
.usWeightClass 
= FWEIGHT_LIGHT
; 
 679         case wxFONTWEIGHT_BOLD
: 
 680             fn
.usWeightClass 
= FWEIGHT_BOLD
; 
 683 } // end of wxNativeFontInfo::SetWeight 
 685 void wxNativeFontInfo::SetUnderlined( 
 690         fa
.fsSelection 
|= FATTR_SEL_UNDERSCORE
; 
 691 } // end of wxNativeFontInfo::SetUnderlined 
 693 void wxNativeFontInfo::SetFaceName( 
 697     wxStrncpy((wxChar
*)fa
.szFacename
, sFacename
, WXSIZEOF(fa
.szFacename
)); 
 698 } // end of wxNativeFontInfo::SetFaceName 
 700 void wxNativeFontInfo::SetFamily( 
 709             sFacename 
= wxT("Tms Rmn"); 
 713             sFacename 
= wxT("WarpSans"); 
 717             sFacename 
= wxT("Tms Rmn"); 
 721             sFacename 
= wxT("Courier") ; 
 725             sFacename 
= wxT("System VIO") ; 
 729             sFacename 
= wxT("Helv") ; 
 734             sFacename 
= wxT("System VIO") ; 
 737     if (!wxStrlen((wxChar
*)fa
.szFacename
) ) 
 739         SetFaceName(sFacename
); 
 741 } // end of wxNativeFontInfo::SetFamily 
 743 void wxNativeFontInfo::SetEncoding( wxFontEncoding eEncoding 
) 
 745     wxNativeEncodingInfo            vInfo
; 
 747     if ( !wxGetNativeFontEncoding( eEncoding
 
 751         if (wxFontMapper::Get()->GetAltForEncoding( eEncoding
 
 755             if (!vInfo
.facename
.empty()) 
 758                 // If we have this encoding only in some particular facename, use 
 759                 // the facename - it is better to show the correct characters in a 
 760                 // wrong facename than unreadable text in a correct one 
 762                 SetFaceName(vInfo
.facename
); 
 767             // unsupported encoding, replace with the default 
 771     fa
.usCodePage 
= (USHORT
)vInfo
.charset
; 
 772 } // end of wxNativeFontInfo::SetFaceName 
 774 bool wxNativeFontInfo::FromString( const wxString
& rsStr 
) 
 778     wxStringTokenizer               
vTokenizer(rsStr
, _T(";")); 
 783     wxString                        sToken 
= vTokenizer
.GetNextToken(); 
 785     if (sToken 
!= _T('0')) 
 788     sToken 
= vTokenizer
.GetNextToken(); 
 789     if (!sToken
.ToLong(&lVal
)) 
 793     sToken 
= vTokenizer
.GetNextToken(); 
 794     if (!sToken
.ToLong(&lVal
)) 
 796     fa
.lAveCharWidth 
= lVal
; 
 798     sToken 
= vTokenizer
.GetNextToken(); 
 799     if (!sToken
.ToLong(&lVal
)) 
 801     fa
.fsSelection 
= (USHORT
)lVal
; 
 803     sToken 
= vTokenizer
.GetNextToken(); 
 804     if (!sToken
.ToLong(&lVal
)) 
 806     fa
.fsType 
= (USHORT
)lVal
; 
 808     sToken 
= vTokenizer
.GetNextToken(); 
 809     if (!sToken
.ToLong(&lVal
)) 
 811     fa
.fsFontUse 
= (USHORT
)lVal
; 
 813     sToken 
= vTokenizer
.GetNextToken(); 
 814     if (!sToken
.ToLong(&lVal
)) 
 816     fa
.idRegistry 
= (USHORT
)lVal
; 
 818     sToken 
= vTokenizer
.GetNextToken(); 
 819     if (!sToken
.ToLong(&lVal
)) 
 821     fa
.usCodePage 
= (USHORT
)lVal
; 
 823     sToken 
= vTokenizer
.GetNextToken(); 
 824     if (!sToken
.ToLong(&lVal
)) 
 828     sToken 
= vTokenizer
.GetNextToken(); 
 829     if (!sToken
.ToLong(&lVal
)) 
 831     fn
.usWeightClass 
= (USHORT
)lVal
; 
 833     sToken 
= vTokenizer
.GetNextToken(); 
 836     wxStrcpy((wxChar
*)fa
.szFacename
, sToken
.c_str()); 
 838 } // end of wxNativeFontInfo::FromString 
 840 wxString 
wxNativeFontInfo::ToString() const 
 844     sStr
.Printf(_T("%d;%ld;%ld;%ld;%d;%d;%d;%d;%d;%ld;%d;%s"), 
 845                 0, // version, in case we want to change the format later 
 858 } // end of wxNativeFontInfo::ToString 
 860 // ---------------------------------------------------------------------------- 
 862 // ---------------------------------------------------------------------------- 
 866 } // end of wxFont::Init 
 868 bool wxFont::Create( const wxNativeFontInfo
& rInfo
, 
 872     m_refData 
= new wxFontRefData( rInfo
 
 877 } // end of wxFont::Create 
 880   const wxString
&                   rsFontdesc
 
 883     wxNativeFontInfo                vInfo
; 
 885     if (vInfo
.FromString(rsFontdesc
)) 
 887 } // end of wxFont::wxFont 
 889 // ---------------------------------------------------------------------------- 
 890 // Constructor for a font. Note that the real construction is done 
 891 // in wxDC::SetFont, when information is available about scaling etc. 
 892 // ---------------------------------------------------------------------------- 
 893 bool wxFont::Create( int             nPointSize
, 
 898                      const wxString
& rsFaceName
, 
 899                      wxFontEncoding  vEncoding 
) 
 904     // wxDEFAULT is a valid value for the font size too so we must treat it 
 905     // specially here (otherwise the size would be 70 == wxDEFAULT value) 
 907     if (nPointSize 
== wxDEFAULT
) 
 909         nPointSize 
= wxNORMAL_FONT
->GetPointSize(); 
 911     m_refData 
= new wxFontRefData( nPointSize
 
 921 } // end of wxFont::Create 
 925 } // end of wxFont::~wxFont 
 927 // ---------------------------------------------------------------------------- 
 928 // real implementation 
 929 // Boris' Kovalenko comments: 
 930 //   Because OS/2 fonts are associated with PS we can not create the font 
 931 //   here, but we may check that font definition is true 
 932 // ---------------------------------------------------------------------------- 
 934 bool wxFont::RealizeResource() 
 936     if ( GetResourceHandle() ) 
 940     return M_FONTDATA
->Alloc(this); 
 941 } // end of wxFont::RealizeResource 
 943 bool wxFont::FreeResource( bool WXUNUSED(bForce
) ) 
 945     if (GetResourceHandle()) 
 951 } // end of wxFont::FreeResource 
 953 WXHANDLE 
wxFont::GetResourceHandle() 
 956 } // end of wxFont::GetResourceHandle 
 958 WXHFONT 
wxFont::GetHFONT() const 
 960     return M_FONTDATA 
? M_FONTDATA
->GetHFONT() : 0; 
 961 } // end of wxFont::GetHFONT 
 963 bool wxFont::IsFree() const 
 965     return M_FONTDATA 
&& (M_FONTDATA
->GetHFONT() == 0); 
 966 } // end of wxFont::IsFree 
 968 void wxFont::Unshare() 
 970     // Don't change shared data 
 973         m_refData 
= new wxFontRefData(); 
 977         wxFontRefData
* ref 
= new wxFontRefData(*M_FONTDATA
); 
 981 } // end of wxFont::Unshare 
 983 // ---------------------------------------------------------------------------- 
 984 // change font attribute: we recreate font when doing it 
 985 // ---------------------------------------------------------------------------- 
 987 void wxFont::SetPointSize( 
 993     M_FONTDATA
->SetPointSize(nPointSize
); 
 996 } // end of wxFont::SetPointSize 
 998 void wxFont::SetFamily( 
1004     M_FONTDATA
->SetFamily(nFamily
); 
1007 } // end of wxFont::SetFamily 
1009 void wxFont::SetStyle( 
1015     M_FONTDATA
->SetStyle(nStyle
); 
1018 } // end of wxFont::SetStyle 
1020 void wxFont::SetWeight( 
1026     M_FONTDATA
->SetWeight(nWeight
); 
1029 } // end of wxFont::SetWeight 
1031 void wxFont::SetFaceName( 
1032   const wxString
&                   rsFaceName
 
1037     M_FONTDATA
->SetFaceName(rsFaceName
); 
1040 } // end of wxFont::SetFaceName 
1042 void wxFont::SetUnderlined( 
1048     M_FONTDATA
->SetUnderlined(bUnderlined
); 
1051 } // end of wxFont::SetUnderlined 
1053 void wxFont::SetEncoding( 
1054   wxFontEncoding                    vEncoding
 
1059     M_FONTDATA
->SetEncoding(vEncoding
); 
1062 } // end of wxFont::SetEncoding 
1064 void wxFont::DoSetNativeFontInfo( 
1065   const wxNativeFontInfo
&           rInfo
 
1072     *M_FONTDATA 
= wxFontRefData(rInfo
); 
1077 // ---------------------------------------------------------------------------- 
1079 // ---------------------------------------------------------------------------- 
1081 int wxFont::GetPointSize() const 
1083     wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); 
1085     return M_FONTDATA
->GetPointSize(); 
1086 } // end of wxFont::GetPointSize 
1088 int wxFont::GetFamily() const 
1090     wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); 
1092     return M_FONTDATA
->GetFamily(); 
1093 } // end of wxFont::GetFamily 
1095 int wxFont::GetStyle() const 
1097     wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); 
1099     return M_FONTDATA
->GetStyle(); 
1100 } // end of wxFont::GetStyle 
1102 int wxFont::GetWeight() const 
1104     wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); 
1106     return M_FONTDATA
->GetWeight(); 
1109 bool wxFont::GetUnderlined() const 
1111     wxCHECK_MSG( Ok(), FALSE
, wxT("invalid font") ); 
1113     return M_FONTDATA
->GetUnderlined(); 
1114 } // end of wxFont::GetUnderlined 
1116 wxString 
wxFont::GetFaceName() const 
1118     wxCHECK_MSG( Ok(), wxT(""), wxT("invalid font") ); 
1120     return M_FONTDATA
->GetFaceName(); 
1121 } // end of wxFont::GetFaceName 
1123 wxFontEncoding 
wxFont::GetEncoding() const 
1125     wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT
, wxT("invalid font") ); 
1127     return M_FONTDATA
->GetEncoding(); 
1128 } // end of wxFont::GetEncoding 
1130 const wxNativeFontInfo
* wxFont::GetNativeFontInfo() const 
1132     return M_FONTDATA
->HasNativeFontInfo() ? &(M_FONTDATA
->GetNativeFontInfo()) 
1134 } // end of wxFont::GetNativeFontInfo 
1137 // Internal use only method to set the FONTMETRICS array 
1144     M_FONTDATA
->SetFM(pFM
); 
1145     M_FONTDATA
->SetNumFonts(nNumFonts
); 
1146 } // end of wxFont::SetFM 
1155     M_FONTDATA
->SetPS(hPS
); 
1158 } // end of wxFont::SetPS