1 ///////////////////////////////////////////////////////////////////////////// 
   2 // Name:        src/x11/font.cpp 
   3 // Purpose:     wxFont class 
   4 // Author:      Julian Smart 
   8 // Copyright:   (c) Julian Smart 
   9 // Licence:     wxWindows licence 
  10 ///////////////////////////////////////////////////////////////////////////// 
  12 // for compilers that support precompilation, includes "wx.h". 
  13 #include "wx/wxprec.h" 
  15 // ============================================================================ 
  17 // ============================================================================ 
  19 // ---------------------------------------------------------------------------- 
  21 // ---------------------------------------------------------------------------- 
  24 #pragma message disable nosimpint 
  25 #include "wx/vms_x_fix.h" 
  29 #pragma message enable nosimpint 
  35     #include "wx/string.h" 
  36     #include "wx/utils.h"       // for wxGetDisplay() 
  37     #include "wx/settings.h" 
  38     #include "wx/gdicmn.h" 
  41 #include "wx/fontutil.h"    // for wxNativeFontInfo 
  42 #include "wx/tokenzr.h" 
  43 #include "wx/fontenum.h" 
  45 #include "wx/x11/private.h" 
  47 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
) 
  49 // ---------------------------------------------------------------------------- 
  51 // ---------------------------------------------------------------------------- 
  53 // the default size (in points) for the fonts 
  54 static const int wxDEFAULT_FONT_SIZE 
= 12; 
  59 // ---------------------------------------------------------------------------- 
  61 // ---------------------------------------------------------------------------- 
  63 // For every wxFont, there must be a font for each display and scale requested. 
  64 // So these objects are stored in wxFontRefData::m_fonts 
  65 class wxXFont 
: public wxObject
 
  71     WXFontStructPtr     m_fontStruct
;   // XFontStruct 
  72     WXDisplay
*          m_display
;      // XDisplay 
  73     int                 m_scale
;        // Scale * 100 
  78     m_fontStruct 
= (WXFontStructPtr
) 0; 
  79     m_display 
= (WXDisplay
*) 0; 
  85     // Freeing the font used to produce a segv, but 
  86     // appears to be OK now (bug fix in X11?) 
  87     XFontStruct
* fontStruct 
= (XFontStruct
*) m_fontStruct
; 
  88     XFreeFont((Display
*) m_display
, fontStruct
); 
  92 // ---------------------------------------------------------------------------- 
  94 // ---------------------------------------------------------------------------- 
  96 class wxFontRefData
: public wxGDIRefData
 
 101     wxFontRefData(int size 
= wxDEFAULT
, 
 102                   wxFontFamily family 
= wxFONTFAMILY_DEFAULT
, 
 103                   wxFontStyle style 
= wxFONTSTYLE_NORMAL
, 
 104                   wxFontWeight weight 
= wxFONTWEIGHT_NORMAL
, 
 105                   bool underlined 
= false, 
 106                   const wxString
& faceName 
= wxEmptyString
, 
 107                   wxFontEncoding encoding 
= wxFONTENCODING_DEFAULT
); 
 110     wxFontRefData(const wxFontRefData
& data
); 
 113     wxFontRefData(const wxString
& fontname
); 
 116     virtual ~wxFontRefData(); 
 118     // setters: all of them also take care to modify m_nativeFontInfo if we 
 119     // have it so as to not lose the information not carried by our fields 
 120     void SetPointSize(int pointSize
); 
 121     void SetFamily(wxFontFamily family
); 
 122     void SetStyle(wxFontStyle style
); 
 123     void SetWeight(wxFontWeight weight
); 
 124     void SetUnderlined(bool underlined
); 
 125     bool SetFaceName(const wxString
& facename
); 
 126     void SetEncoding(wxFontEncoding encoding
); 
 128     void SetNoAntiAliasing( bool no 
= true ) { m_noAA 
= no
; } 
 129     bool GetNoAntiAliasing() const { return m_noAA
; } 
 131     // and this one also modifies all the other font data fields 
 132     void SetNativeFontInfo(const wxNativeFontInfo
& info
); 
 135     // common part of all ctors 
 141               const wxString
& faceName
, 
 142               wxFontEncoding encoding
); 
 144     // set all fields from (already initialized and valid) m_nativeFontInfo 
 145     void InitFromNative(); 
 149     wxFontFamily  m_family
; 
 151     wxFontWeight  m_weight
; 
 154     wxFontEncoding m_encoding
;   // Unused in Unicode mode 
 155     bool            m_noAA
;      // No anti-aliasing 
 157     wxNativeFontInfo m_nativeFontInfo
; 
 159     void ClearX11Fonts(); 
 163     // A list of wxXFonts 
 168 #define M_FONTDATA ((wxFontRefData*)m_refData) 
 170 // ---------------------------------------------------------------------------- 
 172 // ---------------------------------------------------------------------------- 
 174 void wxFontRefData::Init(int pointSize
, 
 179                          const wxString
& faceName
, 
 180                          wxFontEncoding encoding
) 
 182     m_family 
= family 
== wxFONTFAMILY_DEFAULT 
? wxFONTFAMILY_SWISS 
: family
; 
 184     m_faceName 
= faceName
; 
 186     // we accept both wxDEFAULT and wxNORMAL here - should we? 
 187     m_style 
= style 
== wxDEFAULT 
? wxFONTSTYLE_NORMAL 
: style
; 
 188     m_weight 
= weight 
== wxDEFAULT 
? wxFONTWEIGHT_NORMAL 
: weight
; 
 190     m_underlined 
= underlined
; 
 191     m_encoding 
= encoding
; 
 194     if ( m_nativeFontInfo
.description 
) 
 195         pango_font_description_free(m_nativeFontInfo
.description
); 
 197     // Create native font info 
 198     m_nativeFontInfo
.description 
= pango_font_description_new(); 
 200     // if a face name is specified, use it if it's available, otherwise use 
 202     if ( faceName
.empty() || !wxFontEnumerator::IsValidFacename(faceName
) ) 
 204         // TODO: scan system for valid fonts matching the given family instead 
 205         //       of hardcoding them here 
 208             case wxFONTFAMILY_TELETYPE
: 
 209                 m_faceName 
= wxT("monospace"); 
 212             case wxFONTFAMILY_ROMAN
: 
 213                 m_faceName 
= wxT("serif"); 
 217                 m_faceName 
= wxT("sans"); 
 220     else // specified face name is available, use it 
 222         m_faceName 
= faceName
; 
 225     m_nativeFontInfo
.SetFaceName(m_faceName
); 
 226     m_nativeFontInfo
.SetWeight((wxFontWeight
)m_weight
); 
 227     m_nativeFontInfo
.SetStyle((wxFontStyle
)m_style
); 
 228 #endif // wxUSE_UNICODE 
 230     SetPointSize(pointSize
); 
 233 void wxFontRefData::InitFromNative() 
 239     PangoFontDescription 
*desc 
= m_nativeFontInfo
.description
; 
 242     m_faceName 
= wxGTK_CONV_BACK( pango_font_description_get_family( desc 
) ); 
 244     m_pointSize 
= pango_font_description_get_size( desc 
) / PANGO_SCALE
; 
 246     switch (pango_font_description_get_style( desc 
)) 
 248         case PANGO_STYLE_NORMAL
: 
 249             m_style 
= wxFONTSTYLE_NORMAL
; 
 251         case PANGO_STYLE_ITALIC
: 
 252             m_style 
= wxFONTSTYLE_ITALIC
; 
 254         case PANGO_STYLE_OBLIQUE
: 
 255             m_style 
= wxFONTSTYLE_SLANT
; 
 259 // Not defined in some Pango versions 
 260 #define wxPANGO_WEIGHT_SEMIBOLD 600 
 262     switch (pango_font_description_get_weight( desc 
)) 
 264         case PANGO_WEIGHT_ULTRALIGHT
: 
 265         case PANGO_WEIGHT_LIGHT
: 
 266             m_weight 
= wxFONTWEIGHT_LIGHT
; 
 270             wxFAIL_MSG(_T("unknown Pango font weight")); 
 273         case PANGO_WEIGHT_NORMAL
: 
 274             m_weight 
= wxFONTWEIGHT_NORMAL
; 
 277         case wxPANGO_WEIGHT_SEMIBOLD
: 
 278         case PANGO_WEIGHT_BOLD
: 
 279         case PANGO_WEIGHT_ULTRABOLD
: 
 280         case PANGO_WEIGHT_HEAVY
: 
 281             m_weight 
= wxFONTWEIGHT_BOLD
; 
 285     if (m_faceName 
== wxT("monospace")) 
 287         m_family 
= wxFONTFAMILY_TELETYPE
; 
 289     else if (m_faceName 
== wxT("sans")) 
 291         m_family 
= wxFONTFAMILY_SWISS
; 
 295         m_family 
= wxFONTFAMILY_UNKNOWN
; 
 298     // Pango description are never underlined (?) 
 299     m_underlined 
= false; 
 301     // Cannot we choose that 
 302     m_encoding 
= wxFONTENCODING_SYSTEM
; 
 304     // get the font parameters from the XLFD 
 305     // ------------------------------------- 
 307     m_faceName 
= m_nativeFontInfo
.GetXFontComponent(wxXLFD_FAMILY
); 
 309     m_weight 
= wxFONTWEIGHT_NORMAL
; 
 311     wxString w 
= m_nativeFontInfo
.GetXFontComponent(wxXLFD_WEIGHT
).Upper(); 
 312     if ( !w
.empty() && w 
!= _T('*') ) 
 314         // the test below catches all of BOLD, EXTRABOLD, DEMIBOLD, ULTRABOLD 
 316         if ( ((w
[0u] == _T('B') && (!wxStrcmp(w
.c_str() + 1, wxT("OLD")) || 
 317                                    !wxStrcmp(w
.c_str() + 1, wxT("LACK"))))) || 
 318              wxStrstr(w
.c_str() + 1, _T("BOLD")) ) 
 320             m_weight 
= wxFONTWEIGHT_BOLD
; 
 322         else if ( w 
== _T("LIGHT") || w 
== _T("THIN") ) 
 324             m_weight 
= wxFONTWEIGHT_LIGHT
; 
 328     switch ( wxToupper( m_nativeFontInfo
. 
 329                         GetXFontComponent(wxXLFD_SLANT
)[0u]).GetValue() ) 
 331         case _T('I'):   // italique 
 332             m_style 
= wxFONTSTYLE_ITALIC
; 
 335         case _T('O'):   // oblique 
 336             m_style 
= wxFONTSTYLE_SLANT
; 
 340             m_style 
= wxFONTSTYLE_NORMAL
; 
 344     if ( m_nativeFontInfo
.GetXFontComponent(wxXLFD_POINTSIZE
).ToLong(&ptSize
) ) 
 346         // size in XLFD is in 10 point units 
 347         m_pointSize 
= (int)(ptSize 
/ 10); 
 351         m_pointSize 
= wxDEFAULT_FONT_SIZE
; 
 354     // examine the spacing: if the font is monospaced, assume wxTELETYPE 
 355     // family for compatibility with the old code which used it instead of 
 357     if ( m_nativeFontInfo
.GetXFontComponent(wxXLFD_SPACING
).Upper() == _T('M') ) 
 359         m_family 
= wxFONTFAMILY_TELETYPE
; 
 361     else // not monospaceed 
 363         // don't even try guessing it, it doesn't work for too many fonts 
 365         m_family 
= wxFONTFAMILY_UNKNOWN
; 
 368     // X fonts are never underlined... 
 369     m_underlined 
= false; 
 371     // deal with font encoding 
 373         registry 
= m_nativeFontInfo
.GetXFontComponent(wxXLFD_REGISTRY
).Upper(), 
 374         encoding 
= m_nativeFontInfo
.GetXFontComponent(wxXLFD_ENCODING
).Upper(); 
 376     if ( registry 
== _T("ISO8859") ) 
 379         if ( wxSscanf(encoding
, wxT("%d"), &cp
) == 1 ) 
 381             m_encoding 
= (wxFontEncoding
)(wxFONTENCODING_ISO8859_1 
+ cp 
- 1); 
 384     else if ( registry 
== _T("MICROSOFT") ) 
 387         if ( wxSscanf(encoding
, wxT("cp125%d"), &cp
) == 1 ) 
 389             m_encoding 
= (wxFontEncoding
)(wxFONTENCODING_CP1250 
+ cp
); 
 392     else if ( registry 
== _T("KOI8") ) 
 394         m_encoding 
= wxFONTENCODING_KOI8
; 
 396     else // unknown encoding 
 398         // may be give a warning here? or use wxFontMapper? 
 399         m_encoding 
= wxFONTENCODING_SYSTEM
; 
 404 wxFontRefData::wxFontRefData( const wxFontRefData
& data 
) 
 407     m_pointSize 
= data
.m_pointSize
; 
 408     m_family 
= data
.m_family
; 
 409     m_style 
= data
.m_style
; 
 410     m_weight 
= data
.m_weight
; 
 412     m_underlined 
= data
.m_underlined
; 
 414     m_faceName 
= data
.m_faceName
; 
 415     m_encoding 
= data
.m_encoding
; 
 417     m_noAA 
= data
.m_noAA
; 
 419     m_nativeFontInfo 
= data
.m_nativeFontInfo
; 
 422 wxFontRefData::wxFontRefData(int size
, wxFontFamily family
, wxFontStyle style
, 
 423                              wxFontWeight weight
, bool underlined
, 
 424                              const wxString
& faceName
, 
 425                              wxFontEncoding encoding
) 
 427     Init(size
, family
, style
, weight
, underlined
, faceName
, encoding
); 
 430 wxFontRefData::wxFontRefData(const wxString
& fontname
) 
 432     // VZ: FromString() should really work in both cases, doesn't it? 
 434     m_nativeFontInfo
.FromString( fontname 
); 
 436     m_nativeFontInfo
.SetXFontName(fontname
); 
 442 void wxFontRefData::ClearX11Fonts() 
 446     wxList::compatibility_iterator node 
= m_fonts
.GetFirst(); 
 449         wxXFont
* f 
= (wxXFont
*) node
->GetData(); 
 451         node 
= node
->GetNext(); 
 457 wxFontRefData::~wxFontRefData() 
 462 // ---------------------------------------------------------------------------- 
 463 // wxFontRefData SetXXX() 
 464 // ---------------------------------------------------------------------------- 
 466 void wxFontRefData::SetPointSize(int pointSize
) 
 468     // NB: Pango doesn't support point sizes less than 1 
 469     m_pointSize 
= pointSize 
== wxDEFAULT 
|| pointSize 
< 1 ? wxDEFAULT_FONT_SIZE
 
 473     m_nativeFontInfo
.SetPointSize(m_pointSize
); 
 477 void wxFontRefData::SetFamily(wxFontFamily family
) 
 481     // TODO: what are we supposed to do with m_nativeFontInfo here? 
 484 void wxFontRefData::SetStyle(wxFontStyle style
) 
 490     PangoFontDescription 
*desc 
= m_nativeFontInfo
.description
; 
 494         case wxFONTSTYLE_ITALIC
: 
 495             pango_font_description_set_style( desc
, PANGO_STYLE_ITALIC 
); 
 497         case wxFONTSTYLE_SLANT
: 
 498             pango_font_description_set_style( desc
, PANGO_STYLE_OBLIQUE 
); 
 501             wxFAIL_MSG( _T("unknown font style") ); 
 503         case wxFONTSTYLE_NORMAL
: 
 504             pango_font_description_set_style( desc
, PANGO_STYLE_NORMAL 
); 
 510 void wxFontRefData::SetWeight(wxFontWeight weight
) 
 515 void wxFontRefData::SetUnderlined(bool underlined
) 
 517     m_underlined 
= underlined
; 
 519     // the XLFD doesn't have "underlined" field anyhow 
 522 bool wxFontRefData::SetFaceName(const wxString
& facename
) 
 524     m_faceName 
= facename
; 
 528 void wxFontRefData::SetEncoding(wxFontEncoding encoding
) 
 530     m_encoding 
= encoding
; 
 533 void wxFontRefData::SetNativeFontInfo(const wxNativeFontInfo
& info
) 
 535     // previously cached fonts shouldn't be used 
 538     m_nativeFontInfo 
= info
; 
 540     // set all the other font parameters from the native font info 
 544 // ---------------------------------------------------------------------------- 
 546 // ---------------------------------------------------------------------------- 
 548 wxFont::wxFont(const wxNativeFontInfo
& info
) 
 551     Create( info
.GetPointSize(), 
 555             info
.GetUnderlined(), 
 557             info
.GetEncoding() ); 
 559     (void) Create(info
.GetXFontName()); 
 563 bool wxFont::Create(int pointSize
, 
 568                     const wxString
& faceName
, 
 569                     wxFontEncoding encoding
) 
 573     m_refData 
= new wxFontRefData(pointSize
, family
, style
, weight
, 
 574                                   underlined
, faceName
, encoding
); 
 581 bool wxFont::Create(const wxString
& fontname
, wxFontEncoding enc
) 
 585         *this = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT
); 
 589     m_refData 
= new wxFontRefData(); 
 591     M_FONTDATA
->m_nativeFontInfo
.SetXFontName(fontname
);  // X font name 
 595     wxStringTokenizer 
tn( fontname
, wxT("-") ); 
 597     tn
.GetNextToken();                           // skip initial empty token 
 598     tn
.GetNextToken();                           // foundry 
 601     M_FONTDATA
->m_faceName 
= tn
.GetNextToken();  // family 
 603     tmp 
= tn
.GetNextToken().MakeUpper();         // weight 
 604     if (tmp 
== wxT("BOLD")) M_FONTDATA
->m_weight 
= wxFONTWEIGHT_BOLD
; 
 605     if (tmp 
== wxT("BLACK")) M_FONTDATA
->m_weight 
= wxFONTWEIGHT_BOLD
; 
 606     if (tmp 
== wxT("EXTRABOLD")) M_FONTDATA
->m_weight 
= wxFONTWEIGHT_BOLD
; 
 607     if (tmp 
== wxT("DEMIBOLD")) M_FONTDATA
->m_weight 
= wxFONTWEIGHT_BOLD
; 
 608     if (tmp 
== wxT("ULTRABOLD")) M_FONTDATA
->m_weight 
= wxFONTWEIGHT_BOLD
; 
 610     if (tmp 
== wxT("LIGHT")) M_FONTDATA
->m_weight 
= wxFONTWEIGHT_LIGHT
; 
 611     if (tmp 
== wxT("THIN")) M_FONTDATA
->m_weight 
= wxFONTWEIGHT_LIGHT
; 
 613     tmp 
= tn
.GetNextToken().MakeUpper();        // slant 
 614     if (tmp 
== wxT("I")) M_FONTDATA
->m_style 
= wxFONTSTYLE_ITALIC
; 
 615     if (tmp 
== wxT("O")) M_FONTDATA
->m_style 
= wxFONTSTYLE_ITALIC
; 
 617     tn
.GetNextToken();                           // set width 
 618     tn
.GetNextToken();                           // add. style 
 619     tn
.GetNextToken();                           // pixel size 
 621     tmp 
= tn
.GetNextToken();                     // pointsize 
 624         long num 
= wxStrtol (tmp
.c_str(), (wxChar 
**) NULL
, 10); 
 625         M_FONTDATA
->m_pointSize 
= (int)(num 
/ 10); 
 628     tn
.GetNextToken();                           // x-res 
 629     tn
.GetNextToken();                           // y-res 
 631     tmp 
= tn
.GetNextToken().MakeUpper();         // spacing 
 634         M_FONTDATA
->m_family 
= wxFONTFAMILY_MODERN
; 
 635     else if (M_FONTDATA
->m_faceName 
== wxT("TIMES")) 
 636         M_FONTDATA
->m_family 
= wxFONTFAMILY_ROMAN
; 
 637     else if (M_FONTDATA
->m_faceName 
== wxT("HELVETICA")) 
 638         M_FONTDATA
->m_family 
= wxFONTFAMILY_SWISS
; 
 639     else if (M_FONTDATA
->m_faceName 
== wxT("LUCIDATYPEWRITER")) 
 640         M_FONTDATA
->m_family 
= wxFONTFAMILY_TELETYPE
; 
 641     else if (M_FONTDATA
->m_faceName 
== wxT("LUCIDA")) 
 642         M_FONTDATA
->m_family 
= wxFONTFAMILY_DECORATIVE
; 
 643     else if (M_FONTDATA
->m_faceName 
== wxT("UTOPIA")) 
 644         M_FONTDATA
->m_family 
= wxFONTFAMILY_SCRIPT
; 
 646     tn
.GetNextToken();                           // avg width 
 648     // deal with font encoding 
 649     M_FONTDATA
->m_encoding 
= enc
; 
 650     if ( M_FONTDATA
->m_encoding 
== wxFONTENCODING_SYSTEM 
) 
 652         wxString registry 
= tn
.GetNextToken().MakeUpper(), 
 653                  encoding 
= tn
.GetNextToken().MakeUpper(); 
 655         if ( registry 
== _T("ISO8859") ) 
 658             if ( wxSscanf(encoding
, wxT("%d"), &cp
) == 1 ) 
 660                 M_FONTDATA
->m_encoding 
= 
 661                     (wxFontEncoding
)(wxFONTENCODING_ISO8859_1 
+ cp 
- 1); 
 664         else if ( registry 
== _T("MICROSOFT") ) 
 667             if ( wxSscanf(encoding
, wxT("cp125%d"), &cp
) == 1 ) 
 669                 M_FONTDATA
->m_encoding 
= 
 670                     (wxFontEncoding
)(wxFONTENCODING_CP1250 
+ cp
); 
 673         else if ( registry 
== _T("KOI8") ) 
 675             M_FONTDATA
->m_encoding 
= wxFONTENCODING_KOI8
; 
 677         //else: unknown encoding - may be give a warning here? 
 683 #endif // !wxUSE_UNICODE 
 689 wxGDIRefData 
*wxFont::CreateGDIRefData() const 
 691     return new wxFontRefData
; 
 694 wxGDIRefData 
*wxFont::CloneGDIRefData(const wxGDIRefData 
*data
) const 
 696     return new wxFontRefData(*static_cast<const wxFontRefData 
*>(data
)); 
 699 // ---------------------------------------------------------------------------- 
 700 // change the font attributes 
 701 // ---------------------------------------------------------------------------- 
 703 void wxFont::Unshare() 
 705     // Don't change shared data 
 708         m_refData 
= new wxFontRefData(); 
 712         wxFontRefData
* ref 
= new wxFontRefData(*(wxFontRefData
*)m_refData
); 
 718 // ---------------------------------------------------------------------------- 
 720 // ---------------------------------------------------------------------------- 
 722 int wxFont::GetPointSize() const 
 724     wxCHECK_MSG( Ok(), 0, wxT("invalid font") ); 
 726     return M_FONTDATA
->m_pointSize
; 
 729 wxString 
wxFont::GetFaceName() const 
 731     wxCHECK_MSG( Ok(), wxEmptyString
, wxT("invalid font") ); 
 733     return M_FONTDATA
->m_faceName
; 
 736 wxFontFamily 
wxFont::GetFamily() const 
 738     wxCHECK_MSG( Ok(), wxFONTFAMILY_MAX
, wxT("invalid font") ); 
 740     return M_FONTDATA
->m_family
; 
 743 wxFontStyle 
wxFont::GetStyle() const 
 745     wxCHECK_MSG( Ok(), wxFONTSTYLE_MAX
, wxT("invalid font") ); 
 747     return M_FONTDATA
->m_style
; 
 750 wxFontWeight 
wxFont::GetWeight() const 
 752     wxCHECK_MSG( Ok(), wxFONTWEIGHT_MAX
, wxT("invalid font") ); 
 754     return M_FONTDATA
->m_weight
; 
 757 bool wxFont::GetUnderlined() const 
 759     wxCHECK_MSG( Ok(), false, wxT("invalid font") ); 
 761     return M_FONTDATA
->m_underlined
; 
 764 wxFontEncoding 
wxFont::GetEncoding() const 
 766     wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT
, wxT("invalid font") ); 
 768     return M_FONTDATA
->m_encoding
; 
 771 bool wxFont::GetNoAntiAliasing() const 
 773     wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT
, wxT("invalid font") ); 
 775     return M_FONTDATA
->m_noAA
; 
 778 const wxNativeFontInfo 
*wxFont::GetNativeFontInfo() const 
 780     wxCHECK_MSG( Ok(), (wxNativeFontInfo 
*)NULL
, wxT("invalid font") ); 
 784     if ( M_FONTDATA
->m_nativeFontInfo
.GetXFontName().empty() ) 
 788     return &(M_FONTDATA
->m_nativeFontInfo
); 
 791 bool wxFont::IsFixedWidth() const 
 793     wxCHECK_MSG( Ok(), false, wxT("invalid font") ); 
 796    return wxFontBase::IsFixedWidth(); 
 798     // Robert, is this right? HasNativeFont doesn't exist. 
 800     //    if ( M_FONTDATA->HasNativeFont() ) 
 802         // the monospace fonts are supposed to have "M" in the spacing field 
 803         wxString spacing 
= M_FONTDATA
-> 
 804                             m_nativeFontInfo
.GetXFontComponent(wxXLFD_SPACING
); 
 806         return spacing
.Upper() == _T('M'); 
 808    // Unreaceable code for now 
 809    // return wxFontBase::IsFixedWidth(); 
 814 // ---------------------------------------------------------------------------- 
 815 // change font attributes 
 816 // ---------------------------------------------------------------------------- 
 818 void wxFont::SetPointSize(int pointSize
) 
 822     M_FONTDATA
->SetPointSize(pointSize
); 
 825 void wxFont::SetFamily(wxFontFamily family
) 
 829     M_FONTDATA
->SetFamily(family
); 
 832 void wxFont::SetStyle(wxFontStyle style
) 
 836     M_FONTDATA
->SetStyle(style
); 
 839 void wxFont::SetWeight(wxFontWeight weight
) 
 843     M_FONTDATA
->SetWeight(weight
); 
 846 bool wxFont::SetFaceName(const wxString
& faceName
) 
 850     return M_FONTDATA
->SetFaceName(faceName
) && 
 851         wxFontBase::SetFaceName(faceName
); 
 854 void wxFont::SetUnderlined(bool underlined
) 
 858     M_FONTDATA
->SetUnderlined(underlined
); 
 861 void wxFont::SetEncoding(wxFontEncoding encoding
) 
 865     M_FONTDATA
->SetEncoding(encoding
); 
 868 void wxFont::DoSetNativeFontInfo( const wxNativeFontInfo
& info 
) 
 872     M_FONTDATA
->SetNativeFontInfo( info 
); 
 875 void wxFont::SetNoAntiAliasing( bool no 
) 
 879     M_FONTDATA
->SetNoAntiAliasing( no 
); 
 885 // ---------------------------------------------------------------------------- 
 886 // X11 implementation 
 887 // ---------------------------------------------------------------------------- 
 889 // Find an existing, or create a new, XFontStruct 
 890 // based on this wxFont and the given scale. Append the 
 891 // font to list in the private data for future reference. 
 892 wxXFont
* wxFont::GetInternalFont(double scale
, WXDisplay
* display
) const 
 895         return (wxXFont 
*)NULL
; 
 897     long intScale 
= long(scale 
* 100.0 + 0.5); // key for wxXFont 
 898     int pointSize 
= (M_FONTDATA
->m_pointSize 
* 10 * intScale
) / 100; 
 900     // search existing fonts first 
 901     wxList::compatibility_iterator node 
= M_FONTDATA
->m_fonts
.GetFirst(); 
 904         wxXFont
* f 
= (wxXFont
*) node
->GetData(); 
 905         if ((!display 
|| (f
->m_display 
== display
)) && (f
->m_scale 
== intScale
)) 
 907         node 
= node
->GetNext(); 
 910     wxString xFontName 
= M_FONTDATA
->m_nativeFontInfo
.GetXFontName(); 
 911     if (xFontName 
== "-*-*-*-*-*--*-*-*-*-*-*-*-*") 
 912       // wxFont constructor not called with native font info parameter => take M_FONTDATA values 
 915     // not found, create a new one 
 916     XFontStruct 
*font 
= (XFontStruct 
*) 
 917                         wxLoadQueryNearestFont(pointSize
, 
 918                                                M_FONTDATA
->m_family
, 
 920                                                M_FONTDATA
->m_weight
, 
 921                                                M_FONTDATA
->m_underlined
, 
 923                                                M_FONTDATA
->m_encoding
, 
 928         wxFAIL_MSG( wxT("Could not allocate even a default font -- something is wrong.") ); 
 930         return (wxXFont
*) NULL
; 
 933     wxXFont
* f 
= new wxXFont
; 
 934     f
->m_fontStruct 
= (WXFontStructPtr
)font
; 
 935     f
->m_display 
= ( display 
? display 
: wxGetDisplay() ); 
 936     f
->m_scale 
= intScale
; 
 937     M_FONTDATA
->m_fonts
.Append(f
); 
 942 WXFontStructPtr 
wxFont::GetFontStruct(double scale
, WXDisplay
* display
) const 
 944     wxXFont
* f 
= GetInternalFont(scale
, display
); 
 946     return (f 
? f
->m_fontStruct 
: (WXFontStructPtr
) 0);