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 // ----------------------------------------------------------------------------
49 // ----------------------------------------------------------------------------
51 // the default size (in points) for the fonts
52 static const int wxDEFAULT_FONT_SIZE
= 12;
57 // ----------------------------------------------------------------------------
59 // ----------------------------------------------------------------------------
61 // For every wxFont, there must be a font for each display and scale requested.
62 // So these objects are stored in wxFontRefData::m_fonts
63 class wxXFont
: public wxObject
69 WXFontStructPtr m_fontStruct
; // XFontStruct
70 WXDisplay
* m_display
; // XDisplay
71 int m_scale
; // Scale * 100
76 m_fontStruct
= (WXFontStructPtr
) 0;
77 m_display
= (WXDisplay
*) 0;
83 // Freeing the font used to produce a segv, but
84 // appears to be OK now (bug fix in X11?)
85 XFontStruct
* fontStruct
= (XFontStruct
*) m_fontStruct
;
86 XFreeFont((Display
*) m_display
, fontStruct
);
90 // ----------------------------------------------------------------------------
92 // ----------------------------------------------------------------------------
94 class wxFontRefData
: public wxGDIRefData
99 wxFontRefData(int size
= wxDEFAULT
,
100 wxFontFamily family
= wxFONTFAMILY_DEFAULT
,
101 wxFontStyle style
= wxFONTSTYLE_NORMAL
,
102 wxFontWeight weight
= wxFONTWEIGHT_NORMAL
,
103 bool underlined
= false,
104 const wxString
& faceName
= wxEmptyString
,
105 wxFontEncoding encoding
= wxFONTENCODING_DEFAULT
);
108 wxFontRefData(const wxFontRefData
& data
);
111 wxFontRefData(const wxString
& fontname
);
114 virtual ~wxFontRefData();
116 // setters: all of them also take care to modify m_nativeFontInfo if we
117 // have it so as to not lose the information not carried by our fields
118 void SetPointSize(int pointSize
);
119 void SetFamily(wxFontFamily family
);
120 void SetStyle(wxFontStyle style
);
121 void SetWeight(wxFontWeight weight
);
122 void SetUnderlined(bool underlined
);
123 bool SetFaceName(const wxString
& facename
);
124 void SetEncoding(wxFontEncoding encoding
);
126 // and this one also modifies all the other font data fields
127 void SetNativeFontInfo(const wxNativeFontInfo
& info
);
130 // common part of all ctors
136 const wxString
& faceName
,
137 wxFontEncoding encoding
);
139 // set all fields from (already initialized and valid) m_nativeFontInfo
140 void InitFromNative();
144 wxFontFamily m_family
;
146 wxFontWeight m_weight
;
149 wxFontEncoding m_encoding
; // Unused in Unicode mode
151 wxNativeFontInfo m_nativeFontInfo
;
153 void ClearX11Fonts();
157 // A list of wxXFonts
162 #define M_FONTDATA ((wxFontRefData*)m_refData)
164 // ----------------------------------------------------------------------------
166 // ----------------------------------------------------------------------------
168 void wxFontRefData::Init(int pointSize
,
173 const wxString
& faceName
,
174 wxFontEncoding encoding
)
176 m_family
= family
== wxFONTFAMILY_DEFAULT
? wxFONTFAMILY_SWISS
: family
;
178 m_faceName
= faceName
;
180 // we accept both wxDEFAULT and wxNORMAL here - should we?
181 m_style
= style
== wxDEFAULT
? wxFONTSTYLE_NORMAL
: style
;
182 m_weight
= weight
== wxDEFAULT
? wxFONTWEIGHT_NORMAL
: weight
;
184 m_underlined
= underlined
;
185 m_encoding
= encoding
;
188 if ( m_nativeFontInfo
.description
)
189 pango_font_description_free(m_nativeFontInfo
.description
);
191 // Create native font info
192 m_nativeFontInfo
.description
= pango_font_description_new();
194 // if a face name is specified, use it if it's available, otherwise use
196 if ( faceName
.empty() || !wxFontEnumerator::IsValidFacename(faceName
) )
198 // TODO: scan system for valid fonts matching the given family instead
199 // of hardcoding them here
202 case wxFONTFAMILY_TELETYPE
:
203 m_faceName
= wxT("monospace");
206 case wxFONTFAMILY_ROMAN
:
207 m_faceName
= wxT("serif");
211 m_faceName
= wxT("sans");
214 else // specified face name is available, use it
216 m_faceName
= faceName
;
219 m_nativeFontInfo
.SetFaceName(m_faceName
);
220 m_nativeFontInfo
.SetWeight((wxFontWeight
)m_weight
);
221 m_nativeFontInfo
.SetStyle((wxFontStyle
)m_style
);
222 #endif // wxUSE_UNICODE
224 SetPointSize(pointSize
);
227 void wxFontRefData::InitFromNative()
231 PangoFontDescription
*desc
= m_nativeFontInfo
.description
;
234 m_faceName
= wxGTK_CONV_BACK( pango_font_description_get_family( desc
) );
236 m_pointSize
= pango_font_description_get_size( desc
) / PANGO_SCALE
;
238 switch (pango_font_description_get_style( desc
))
240 case PANGO_STYLE_NORMAL
:
241 m_style
= wxFONTSTYLE_NORMAL
;
243 case PANGO_STYLE_ITALIC
:
244 m_style
= wxFONTSTYLE_ITALIC
;
246 case PANGO_STYLE_OBLIQUE
:
247 m_style
= wxFONTSTYLE_SLANT
;
251 // Not defined in some Pango versions
252 #define wxPANGO_WEIGHT_SEMIBOLD 600
254 switch (pango_font_description_get_weight( desc
))
256 case PANGO_WEIGHT_ULTRALIGHT
:
257 case PANGO_WEIGHT_LIGHT
:
258 m_weight
= wxFONTWEIGHT_LIGHT
;
262 wxFAIL_MSG(wxT("unknown Pango font weight"));
265 case PANGO_WEIGHT_NORMAL
:
266 m_weight
= wxFONTWEIGHT_NORMAL
;
269 case wxPANGO_WEIGHT_SEMIBOLD
:
270 case PANGO_WEIGHT_BOLD
:
271 case PANGO_WEIGHT_ULTRABOLD
:
272 case PANGO_WEIGHT_HEAVY
:
273 m_weight
= wxFONTWEIGHT_BOLD
;
277 if (m_faceName
== wxT("monospace"))
279 m_family
= wxFONTFAMILY_TELETYPE
;
281 else if (m_faceName
== wxT("sans"))
283 m_family
= wxFONTFAMILY_SWISS
;
287 m_family
= wxFONTFAMILY_UNKNOWN
;
290 // Pango description are never underlined (?)
291 m_underlined
= false;
293 // Cannot we choose that
294 m_encoding
= wxFONTENCODING_SYSTEM
;
296 // get the font parameters from the XLFD
297 // -------------------------------------
299 m_faceName
= m_nativeFontInfo
.GetXFontComponent(wxXLFD_FAMILY
);
301 m_weight
= wxFONTWEIGHT_NORMAL
;
303 wxString w
= m_nativeFontInfo
.GetXFontComponent(wxXLFD_WEIGHT
).Upper();
304 if ( !w
.empty() && w
!= wxT('*') )
306 // the test below catches all of BOLD, EXTRABOLD, DEMIBOLD, ULTRABOLD
308 if ( ((w
[0u] == wxT('B') && (!wxStrcmp(w
.c_str() + 1, wxT("OLD")) ||
309 !wxStrcmp(w
.c_str() + 1, wxT("LACK"))))) ||
310 wxStrstr(w
.c_str() + 1, wxT("BOLD")) )
312 m_weight
= wxFONTWEIGHT_BOLD
;
314 else if ( w
== wxT("LIGHT") || w
== wxT("THIN") )
316 m_weight
= wxFONTWEIGHT_LIGHT
;
320 switch ( wxToupper( m_nativeFontInfo
.
321 GetXFontComponent(wxXLFD_SLANT
)[0u]).GetValue() )
323 case wxT('I'): // italique
324 m_style
= wxFONTSTYLE_ITALIC
;
327 case wxT('O'): // oblique
328 m_style
= wxFONTSTYLE_SLANT
;
332 m_style
= wxFONTSTYLE_NORMAL
;
336 if ( m_nativeFontInfo
.GetXFontComponent(wxXLFD_POINTSIZE
).ToLong(&ptSize
) )
338 // size in XLFD is in 10 point units
339 m_pointSize
= (int)(ptSize
/ 10);
343 m_pointSize
= wxDEFAULT_FONT_SIZE
;
346 // examine the spacing: if the font is monospaced, assume wxTELETYPE
347 // family for compatibility with the old code which used it instead of
349 if ( m_nativeFontInfo
.GetXFontComponent(wxXLFD_SPACING
).Upper() == wxT('M') )
351 m_family
= wxFONTFAMILY_TELETYPE
;
353 else // not monospaceed
355 // don't even try guessing it, it doesn't work for too many fonts
357 m_family
= wxFONTFAMILY_UNKNOWN
;
360 // X fonts are never underlined...
361 m_underlined
= false;
363 // deal with font encoding
365 registry
= m_nativeFontInfo
.GetXFontComponent(wxXLFD_REGISTRY
).Upper(),
366 encoding
= m_nativeFontInfo
.GetXFontComponent(wxXLFD_ENCODING
).Upper();
368 if ( registry
== wxT("ISO8859") )
371 if ( wxSscanf(encoding
, wxT("%d"), &cp
) == 1 )
373 m_encoding
= (wxFontEncoding
)(wxFONTENCODING_ISO8859_1
+ cp
- 1);
376 else if ( registry
== wxT("MICROSOFT") )
379 if ( wxSscanf(encoding
, wxT("cp125%d"), &cp
) == 1 )
381 m_encoding
= (wxFontEncoding
)(wxFONTENCODING_CP1250
+ cp
);
384 else if ( registry
== wxT("KOI8") )
386 m_encoding
= wxFONTENCODING_KOI8
;
388 else // unknown encoding
390 // may be give a warning here? or use wxFontMapper?
391 m_encoding
= wxFONTENCODING_SYSTEM
;
396 wxFontRefData::wxFontRefData( const wxFontRefData
& data
)
399 m_pointSize
= data
.m_pointSize
;
400 m_family
= data
.m_family
;
401 m_style
= data
.m_style
;
402 m_weight
= data
.m_weight
;
404 m_underlined
= data
.m_underlined
;
406 m_faceName
= data
.m_faceName
;
407 m_encoding
= data
.m_encoding
;
409 m_nativeFontInfo
= data
.m_nativeFontInfo
;
412 wxFontRefData::wxFontRefData(int size
, wxFontFamily family
, wxFontStyle style
,
413 wxFontWeight weight
, bool underlined
,
414 const wxString
& faceName
,
415 wxFontEncoding encoding
)
417 Init(size
, family
, style
, weight
, underlined
, faceName
, encoding
);
420 wxFontRefData::wxFontRefData(const wxString
& fontname
)
422 // VZ: FromString() should really work in both cases, doesn't it?
424 m_nativeFontInfo
.FromString( fontname
);
426 m_nativeFontInfo
.SetXFontName(fontname
);
432 void wxFontRefData::ClearX11Fonts()
436 wxList::compatibility_iterator node
= m_fonts
.GetFirst();
439 wxXFont
* f
= (wxXFont
*) node
->GetData();
441 node
= node
->GetNext();
447 wxFontRefData::~wxFontRefData()
452 // ----------------------------------------------------------------------------
453 // wxFontRefData SetXXX()
454 // ----------------------------------------------------------------------------
456 void wxFontRefData::SetPointSize(int pointSize
)
458 // NB: Pango doesn't support point sizes less than 1
459 m_pointSize
= pointSize
== wxDEFAULT
|| pointSize
< 1 ? wxDEFAULT_FONT_SIZE
463 m_nativeFontInfo
.SetPointSize(m_pointSize
);
467 void wxFontRefData::SetFamily(wxFontFamily family
)
471 // TODO: what are we supposed to do with m_nativeFontInfo here?
474 void wxFontRefData::SetStyle(wxFontStyle style
)
480 PangoFontDescription
*desc
= m_nativeFontInfo
.description
;
484 case wxFONTSTYLE_ITALIC
:
485 pango_font_description_set_style( desc
, PANGO_STYLE_ITALIC
);
487 case wxFONTSTYLE_SLANT
:
488 pango_font_description_set_style( desc
, PANGO_STYLE_OBLIQUE
);
491 wxFAIL_MSG( wxT("unknown font style") );
493 case wxFONTSTYLE_NORMAL
:
494 pango_font_description_set_style( desc
, PANGO_STYLE_NORMAL
);
500 void wxFontRefData::SetWeight(wxFontWeight weight
)
505 void wxFontRefData::SetUnderlined(bool underlined
)
507 m_underlined
= underlined
;
509 // the XLFD doesn't have "underlined" field anyhow
512 bool wxFontRefData::SetFaceName(const wxString
& facename
)
514 m_faceName
= facename
;
518 void wxFontRefData::SetEncoding(wxFontEncoding encoding
)
520 m_encoding
= encoding
;
523 void wxFontRefData::SetNativeFontInfo(const wxNativeFontInfo
& info
)
525 // previously cached fonts shouldn't be used
528 m_nativeFontInfo
= info
;
530 // set all the other font parameters from the native font info
534 // ----------------------------------------------------------------------------
536 // ----------------------------------------------------------------------------
538 wxFont::wxFont(const wxNativeFontInfo
& info
)
541 Create( info
.GetPointSize(),
545 info
.GetUnderlined(),
547 info
.GetEncoding() );
549 (void) Create(info
.GetXFontName());
553 bool wxFont::Create(int pointSize
,
558 const wxString
& faceName
,
559 wxFontEncoding encoding
)
563 m_refData
= new wxFontRefData(pointSize
, family
, style
, weight
,
564 underlined
, faceName
, encoding
);
571 bool wxFont::Create(const wxString
& fontname
, wxFontEncoding enc
)
575 *this = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT
);
579 m_refData
= new wxFontRefData();
581 M_FONTDATA
->m_nativeFontInfo
.SetXFontName(fontname
); // X font name
585 wxStringTokenizer
tn( fontname
, wxT("-") );
587 tn
.GetNextToken(); // skip initial empty token
588 tn
.GetNextToken(); // foundry
591 M_FONTDATA
->m_faceName
= tn
.GetNextToken(); // family
593 tmp
= tn
.GetNextToken().MakeUpper(); // weight
594 if (tmp
== wxT("BOLD")) M_FONTDATA
->m_weight
= wxFONTWEIGHT_BOLD
;
595 if (tmp
== wxT("BLACK")) M_FONTDATA
->m_weight
= wxFONTWEIGHT_BOLD
;
596 if (tmp
== wxT("EXTRABOLD")) M_FONTDATA
->m_weight
= wxFONTWEIGHT_BOLD
;
597 if (tmp
== wxT("DEMIBOLD")) M_FONTDATA
->m_weight
= wxFONTWEIGHT_BOLD
;
598 if (tmp
== wxT("ULTRABOLD")) M_FONTDATA
->m_weight
= wxFONTWEIGHT_BOLD
;
600 if (tmp
== wxT("LIGHT")) M_FONTDATA
->m_weight
= wxFONTWEIGHT_LIGHT
;
601 if (tmp
== wxT("THIN")) M_FONTDATA
->m_weight
= wxFONTWEIGHT_LIGHT
;
603 tmp
= tn
.GetNextToken().MakeUpper(); // slant
604 if (tmp
== wxT("I")) M_FONTDATA
->m_style
= wxFONTSTYLE_ITALIC
;
605 if (tmp
== wxT("O")) M_FONTDATA
->m_style
= wxFONTSTYLE_ITALIC
;
607 tn
.GetNextToken(); // set width
608 tn
.GetNextToken(); // add. style
609 tn
.GetNextToken(); // pixel size
611 tmp
= tn
.GetNextToken(); // pointsize
614 long num
= wxStrtol (tmp
.c_str(), (wxChar
**) NULL
, 10);
615 M_FONTDATA
->m_pointSize
= (int)(num
/ 10);
618 tn
.GetNextToken(); // x-res
619 tn
.GetNextToken(); // y-res
621 tmp
= tn
.GetNextToken().MakeUpper(); // spacing
624 M_FONTDATA
->m_family
= wxFONTFAMILY_MODERN
;
625 else if (M_FONTDATA
->m_faceName
== wxT("TIMES"))
626 M_FONTDATA
->m_family
= wxFONTFAMILY_ROMAN
;
627 else if (M_FONTDATA
->m_faceName
== wxT("HELVETICA"))
628 M_FONTDATA
->m_family
= wxFONTFAMILY_SWISS
;
629 else if (M_FONTDATA
->m_faceName
== wxT("LUCIDATYPEWRITER"))
630 M_FONTDATA
->m_family
= wxFONTFAMILY_TELETYPE
;
631 else if (M_FONTDATA
->m_faceName
== wxT("LUCIDA"))
632 M_FONTDATA
->m_family
= wxFONTFAMILY_DECORATIVE
;
633 else if (M_FONTDATA
->m_faceName
== wxT("UTOPIA"))
634 M_FONTDATA
->m_family
= wxFONTFAMILY_SCRIPT
;
636 tn
.GetNextToken(); // avg width
638 // deal with font encoding
639 M_FONTDATA
->m_encoding
= enc
;
640 if ( M_FONTDATA
->m_encoding
== wxFONTENCODING_SYSTEM
)
642 wxString registry
= tn
.GetNextToken().MakeUpper(),
643 encoding
= tn
.GetNextToken().MakeUpper();
645 if ( registry
== wxT("ISO8859") )
648 if ( wxSscanf(encoding
, wxT("%d"), &cp
) == 1 )
650 M_FONTDATA
->m_encoding
=
651 (wxFontEncoding
)(wxFONTENCODING_ISO8859_1
+ cp
- 1);
654 else if ( registry
== wxT("MICROSOFT") )
657 if ( wxSscanf(encoding
, wxT("cp125%d"), &cp
) == 1 )
659 M_FONTDATA
->m_encoding
=
660 (wxFontEncoding
)(wxFONTENCODING_CP1250
+ cp
);
663 else if ( registry
== wxT("KOI8") )
665 M_FONTDATA
->m_encoding
= wxFONTENCODING_KOI8
;
667 //else: unknown encoding - may be give a warning here?
673 #endif // !wxUSE_UNICODE
679 wxGDIRefData
*wxFont::CreateGDIRefData() const
681 return new wxFontRefData
;
684 wxGDIRefData
*wxFont::CloneGDIRefData(const wxGDIRefData
*data
) const
686 return new wxFontRefData(*static_cast<const wxFontRefData
*>(data
));
689 // ----------------------------------------------------------------------------
690 // change the font attributes
691 // ----------------------------------------------------------------------------
693 void wxFont::Unshare()
695 // Don't change shared data
698 m_refData
= new wxFontRefData();
702 wxFontRefData
* ref
= new wxFontRefData(*(wxFontRefData
*)m_refData
);
708 // ----------------------------------------------------------------------------
710 // ----------------------------------------------------------------------------
712 int wxFont::GetPointSize() const
714 wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
716 return M_FONTDATA
->m_pointSize
;
719 wxString
wxFont::GetFaceName() const
721 wxCHECK_MSG( IsOk(), wxEmptyString
, wxT("invalid font") );
723 return M_FONTDATA
->m_faceName
;
726 wxFontFamily
wxFont::DoGetFamily() const
728 return M_FONTDATA
->m_family
;
731 wxFontStyle
wxFont::GetStyle() const
733 wxCHECK_MSG( IsOk(), wxFONTSTYLE_MAX
, wxT("invalid font") );
735 return M_FONTDATA
->m_style
;
738 wxFontWeight
wxFont::GetWeight() const
740 wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX
, wxT("invalid font") );
742 return M_FONTDATA
->m_weight
;
745 bool wxFont::GetUnderlined() const
747 wxCHECK_MSG( IsOk(), false, wxT("invalid font") );
749 return M_FONTDATA
->m_underlined
;
752 wxFontEncoding
wxFont::GetEncoding() const
754 wxCHECK_MSG( IsOk(), wxFONTENCODING_DEFAULT
, wxT("invalid font") );
756 return M_FONTDATA
->m_encoding
;
759 const wxNativeFontInfo
*wxFont::GetNativeFontInfo() const
761 wxCHECK_MSG( IsOk(), NULL
, wxT("invalid font") );
765 if ( M_FONTDATA
->m_nativeFontInfo
.GetXFontName().empty() )
769 return &(M_FONTDATA
->m_nativeFontInfo
);
772 bool wxFont::IsFixedWidth() const
774 wxCHECK_MSG( IsOk(), false, wxT("invalid font") );
777 return wxFontBase::IsFixedWidth();
779 // Robert, is this right? HasNativeFont doesn't exist.
781 // if ( M_FONTDATA->HasNativeFont() )
783 // the monospace fonts are supposed to have "M" in the spacing field
784 wxString spacing
= M_FONTDATA
->
785 m_nativeFontInfo
.GetXFontComponent(wxXLFD_SPACING
);
787 return spacing
.Upper() == wxT('M');
789 // Unreaceable code for now
790 // return wxFontBase::IsFixedWidth();
795 // ----------------------------------------------------------------------------
796 // change font attributes
797 // ----------------------------------------------------------------------------
799 void wxFont::SetPointSize(int pointSize
)
803 M_FONTDATA
->SetPointSize(pointSize
);
806 void wxFont::SetFamily(wxFontFamily family
)
810 M_FONTDATA
->SetFamily(family
);
813 void wxFont::SetStyle(wxFontStyle style
)
817 M_FONTDATA
->SetStyle(style
);
820 void wxFont::SetWeight(wxFontWeight weight
)
824 M_FONTDATA
->SetWeight(weight
);
827 bool wxFont::SetFaceName(const wxString
& faceName
)
831 return M_FONTDATA
->SetFaceName(faceName
) &&
832 wxFontBase::SetFaceName(faceName
);
835 void wxFont::SetUnderlined(bool underlined
)
839 M_FONTDATA
->SetUnderlined(underlined
);
842 void wxFont::SetEncoding(wxFontEncoding encoding
)
846 M_FONTDATA
->SetEncoding(encoding
);
849 void wxFont::DoSetNativeFontInfo( const wxNativeFontInfo
& info
)
853 M_FONTDATA
->SetNativeFontInfo( info
);
858 // ----------------------------------------------------------------------------
859 // X11 implementation
860 // ----------------------------------------------------------------------------
862 // Find an existing, or create a new, XFontStruct
863 // based on this wxFont and the given scale. Append the
864 // font to list in the private data for future reference.
865 wxXFont
* wxFont::GetInternalFont(double scale
, WXDisplay
* display
) const
870 long intScale
= long(scale
* 100.0 + 0.5); // key for wxXFont
871 int pointSize
= (M_FONTDATA
->m_pointSize
* 10 * intScale
) / 100;
873 // search existing fonts first
874 wxList::compatibility_iterator node
= M_FONTDATA
->m_fonts
.GetFirst();
877 wxXFont
* f
= (wxXFont
*) node
->GetData();
878 if ((!display
|| (f
->m_display
== display
)) && (f
->m_scale
== intScale
))
880 node
= node
->GetNext();
883 wxString xFontName
= M_FONTDATA
->m_nativeFontInfo
.GetXFontName();
884 if (xFontName
== "-*-*-*-*-*--*-*-*-*-*-*-*-*")
885 // wxFont constructor not called with native font info parameter => take M_FONTDATA values
888 // not found, create a new one
889 XFontStruct
*font
= (XFontStruct
*)
890 wxLoadQueryNearestFont(pointSize
,
891 M_FONTDATA
->m_family
,
893 M_FONTDATA
->m_weight
,
894 M_FONTDATA
->m_underlined
,
896 M_FONTDATA
->m_encoding
,
901 wxFAIL_MSG( wxT("Could not allocate even a default font -- something is wrong.") );
906 wxXFont
* f
= new wxXFont
;
907 f
->m_fontStruct
= (WXFontStructPtr
)font
;
908 f
->m_display
= ( display
? display
: wxGetDisplay() );
909 f
->m_scale
= intScale
;
910 M_FONTDATA
->m_fonts
.Append(f
);
915 WXFontStructPtr
wxFont::GetFontStruct(double scale
, WXDisplay
* display
) const
917 wxXFont
* f
= GetInternalFont(scale
, display
);
919 return (f
? f
->m_fontStruct
: (WXFontStructPtr
) 0);
922 #endif // !wxUSE_UNICODE