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 wxObjectRefData
101 wxFontRefData(int size
= wxDEFAULT
,
102 int family
= wxDEFAULT
,
103 int style
= wxDEFAULT
,
104 int weight
= wxDEFAULT
,
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(int family
);
122 void SetStyle(int style
);
123 void SetWeight(int 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();
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 // and here, do we really want to forbid creation of the font of the size
191 // 90 (the value of wxDEFAULT)??
192 m_pointSize
= pointSize
== wxDEFAULT
|| pointSize
== -1
193 ? wxDEFAULT_FONT_SIZE
196 m_underlined
= underlined
;
197 m_encoding
= encoding
;
200 if ( m_nativeFontInfo
.description
)
201 pango_font_description_free(m_nativeFontInfo
.description
);
203 // Create native font info
204 m_nativeFontInfo
.description
= pango_font_description_new();
206 // if a face name is specified, use it if it's available, otherwise use
208 if ( faceName
.empty() || !wxFontEnumerator
::IsValidFacename(faceName
) )
210 // TODO: scan system for valid fonts matching the given family instead
211 // of hardcoding them here
214 case wxFONTFAMILY_TELETYPE
:
215 m_faceName
= wxT("monospace");
218 case wxFONTFAMILY_ROMAN
:
219 m_faceName
= wxT("serif");
223 m_faceName
= wxT("sans");
226 else // specified face name is available, use it
228 m_faceName
= faceName
;
231 m_nativeFontInfo
.SetFaceName(m_faceName
);
232 m_nativeFontInfo
.SetPointSize(m_pointSize
);
233 m_nativeFontInfo
.SetWeight((wxFontWeight
)m_weight
);
234 m_nativeFontInfo
.SetStyle((wxFontStyle
)m_style
);
235 #endif // wxUSE_UNICODE
238 void wxFontRefData
::InitFromNative()
244 PangoFontDescription
*desc
= m_nativeFontInfo
.description
;
247 m_faceName
= wxGTK_CONV_BACK( pango_font_description_get_family( desc
) );
249 m_pointSize
= pango_font_description_get_size( desc
) / PANGO_SCALE
;
251 switch (pango_font_description_get_style( desc
))
253 case PANGO_STYLE_NORMAL
:
254 m_style
= wxFONTSTYLE_NORMAL
;
256 case PANGO_STYLE_ITALIC
:
257 m_style
= wxFONTSTYLE_ITALIC
;
259 case PANGO_STYLE_OBLIQUE
:
260 m_style
= wxFONTSTYLE_SLANT
;
264 // Not defined in some Pango versions
265 #define wxPANGO_WEIGHT_SEMIBOLD 600
267 switch (pango_font_description_get_weight( desc
))
269 case PANGO_WEIGHT_ULTRALIGHT
:
270 case PANGO_WEIGHT_LIGHT
:
271 m_weight
= wxFONTWEIGHT_LIGHT
;
275 wxFAIL_MSG(_T("unknown Pango font weight"));
278 case PANGO_WEIGHT_NORMAL
:
279 m_weight
= wxFONTWEIGHT_NORMAL
;
282 case wxPANGO_WEIGHT_SEMIBOLD
:
283 case PANGO_WEIGHT_BOLD
:
284 case PANGO_WEIGHT_ULTRABOLD
:
285 case PANGO_WEIGHT_HEAVY
:
286 m_weight
= wxFONTWEIGHT_BOLD
;
290 if (m_faceName
== wxT("monospace"))
292 m_family
= wxFONTFAMILY_TELETYPE
;
294 else if (m_faceName
== wxT("sans"))
296 m_family
= wxFONTFAMILY_SWISS
;
300 m_family
= wxFONTFAMILY_UNKNOWN
;
303 // Pango description are never underlined (?)
304 m_underlined
= false;
306 // Cannot we choose that
307 m_encoding
= wxFONTENCODING_SYSTEM
;
309 // get the font parameters from the XLFD
310 // -------------------------------------
312 m_faceName
= m_nativeFontInfo
.GetXFontComponent(wxXLFD_FAMILY
);
314 m_weight
= wxFONTWEIGHT_NORMAL
;
316 wxString w
= m_nativeFontInfo
.GetXFontComponent(wxXLFD_WEIGHT
).Upper();
317 if ( !w
.empty() && w
!= _T('*') )
319 // the test below catches all of BOLD, EXTRABOLD, DEMIBOLD, ULTRABOLD
321 if ( ((w
[0u] == _T('B') && (!wxStrcmp(w
.c_str() + 1, wxT("OLD")) ||
322 !wxStrcmp(w
.c_str() + 1, wxT("LACK"))))) ||
323 wxStrstr(w
.c_str() + 1, _T("BOLD")) )
325 m_weight
= wxFONTWEIGHT_BOLD
;
327 else if ( w
== _T("LIGHT") || w
== _T("THIN") )
329 m_weight
= wxFONTWEIGHT_LIGHT
;
333 switch ( wxToupper(*m_nativeFontInfo
.
334 GetXFontComponent(wxXLFD_SLANT
).c_str()) )
336 case _T('I'): // italique
337 m_style
= wxFONTSTYLE_ITALIC
;
340 case _T('O'): // oblique
341 m_style
= wxFONTSTYLE_SLANT
;
345 m_style
= wxFONTSTYLE_NORMAL
;
349 if ( m_nativeFontInfo
.GetXFontComponent(wxXLFD_POINTSIZE
).ToLong(&ptSize
) )
351 // size in XLFD is in 10 point units
352 m_pointSize
= (int)(ptSize
/ 10);
356 m_pointSize
= wxDEFAULT_FONT_SIZE
;
359 // examine the spacing: if the font is monospaced, assume wxTELETYPE
360 // family for compatibility with the old code which used it instead of
362 if ( m_nativeFontInfo
.GetXFontComponent(wxXLFD_SPACING
).Upper() == _T('M') )
364 m_family
= wxFONTFAMILY_TELETYPE
;
366 else // not monospaceed
368 // don't even try guessing it, it doesn't work for too many fonts
370 m_family
= wxFONTFAMILY_UNKNOWN
;
373 // X fonts are never underlined...
374 m_underlined
= false;
376 // deal with font encoding
378 registry
= m_nativeFontInfo
.GetXFontComponent(wxXLFD_REGISTRY
).Upper(),
379 encoding
= m_nativeFontInfo
.GetXFontComponent(wxXLFD_ENCODING
).Upper();
381 if ( registry
== _T("ISO8859") )
384 if ( wxSscanf(encoding
, wxT("%d"), &cp
) == 1 )
386 m_encoding
= (wxFontEncoding
)(wxFONTENCODING_ISO8859_1
+ cp
- 1);
389 else if ( registry
== _T("MICROSOFT") )
392 if ( wxSscanf(encoding
, wxT("cp125%d"), &cp
) == 1 )
394 m_encoding
= (wxFontEncoding
)(wxFONTENCODING_CP1250
+ cp
);
397 else if ( registry
== _T("KOI8") )
399 m_encoding
= wxFONTENCODING_KOI8
;
401 else // unknown encoding
403 // may be give a warning here? or use wxFontMapper?
404 m_encoding
= wxFONTENCODING_SYSTEM
;
409 wxFontRefData
::wxFontRefData( const wxFontRefData
& data
)
412 m_pointSize
= data
.m_pointSize
;
413 m_family
= data
.m_family
;
414 m_style
= data
.m_style
;
415 m_weight
= data
.m_weight
;
417 m_underlined
= data
.m_underlined
;
419 m_faceName
= data
.m_faceName
;
420 m_encoding
= data
.m_encoding
;
422 m_noAA
= data
.m_noAA
;
424 m_nativeFontInfo
= data
.m_nativeFontInfo
;
427 wxFontRefData
::wxFontRefData(int size
, int family
, int style
,
428 int weight
, bool underlined
,
429 const wxString
& faceName
,
430 wxFontEncoding encoding
)
432 Init(size
, family
, style
, weight
, underlined
, faceName
, encoding
);
435 wxFontRefData
::wxFontRefData(const wxString
& fontname
)
437 // VZ: FromString() should really work in both cases, doesn't it?
439 m_nativeFontInfo
.FromString( fontname
);
441 m_nativeFontInfo
.SetXFontName(fontname
);
447 void wxFontRefData
::ClearX11Fonts()
451 wxList
::compatibility_iterator node
= m_fonts
.GetFirst();
454 wxXFont
* f
= (wxXFont
*) node
->GetData();
456 node
= node
->GetNext();
462 wxFontRefData
::~wxFontRefData()
467 // ----------------------------------------------------------------------------
468 // wxFontRefData SetXXX()
469 // ----------------------------------------------------------------------------
471 void wxFontRefData
::SetPointSize(int pointSize
)
473 m_pointSize
= pointSize
;
477 PangoFontDescription
*desc
= m_nativeFontInfo
.description
;
479 pango_font_description_set_size( desc
, m_pointSize
* PANGO_SCALE
);
483 void wxFontRefData
::SetFamily(int family
)
487 // TODO: what are we supposed to do with m_nativeFontInfo here?
490 void wxFontRefData
::SetStyle(int style
)
496 PangoFontDescription
*desc
= m_nativeFontInfo
.description
;
500 case wxFONTSTYLE_ITALIC
:
501 pango_font_description_set_style( desc
, PANGO_STYLE_ITALIC
);
503 case wxFONTSTYLE_SLANT
:
504 pango_font_description_set_style( desc
, PANGO_STYLE_OBLIQUE
);
507 wxFAIL_MSG( _T("unknown font style") );
509 case wxFONTSTYLE_NORMAL
:
510 pango_font_description_set_style( desc
, PANGO_STYLE_NORMAL
);
516 void wxFontRefData
::SetWeight(int weight
)
521 void wxFontRefData
::SetUnderlined(bool underlined
)
523 m_underlined
= underlined
;
525 // the XLFD doesn't have "underlined" field anyhow
528 bool wxFontRefData
::SetFaceName(const wxString
& facename
)
530 m_faceName
= facename
;
534 void wxFontRefData
::SetEncoding(wxFontEncoding encoding
)
536 m_encoding
= encoding
;
539 void wxFontRefData
::SetNativeFontInfo(const wxNativeFontInfo
& info
)
541 // previously cached fonts shouldn't be used
544 m_nativeFontInfo
= info
;
546 // set all the other font parameters from the native font info
550 // ----------------------------------------------------------------------------
552 // ----------------------------------------------------------------------------
554 wxFont
::wxFont(const wxNativeFontInfo
& info
)
557 Create( info
.GetPointSize(),
561 info
.GetUnderlined(),
563 info
.GetEncoding() );
565 (void) Create(info
.GetXFontName());
569 bool wxFont
::Create(int pointSize
,
574 const wxString
& faceName
,
575 wxFontEncoding encoding
)
579 m_refData
= new wxFontRefData(pointSize
, family
, style
, weight
,
580 underlined
, faceName
, encoding
);
587 bool wxFont
::Create(const wxString
& fontname
, wxFontEncoding enc
)
591 *this = wxSystemSettings
::GetFont( wxSYS_DEFAULT_GUI_FONT
);
595 m_refData
= new wxFontRefData();
597 M_FONTDATA
->m_nativeFontInfo
.SetXFontName(fontname
); // X font name
601 wxStringTokenizer
tn( fontname
, wxT("-") );
603 tn
.GetNextToken(); // skip initial empty token
604 tn
.GetNextToken(); // foundry
607 M_FONTDATA
->m_faceName
= tn
.GetNextToken(); // family
609 tmp
= tn
.GetNextToken().MakeUpper(); // weight
610 if (tmp
== wxT("BOLD")) M_FONTDATA
->m_weight
= wxBOLD
;
611 if (tmp
== wxT("BLACK")) M_FONTDATA
->m_weight
= wxBOLD
;
612 if (tmp
== wxT("EXTRABOLD")) M_FONTDATA
->m_weight
= wxBOLD
;
613 if (tmp
== wxT("DEMIBOLD")) M_FONTDATA
->m_weight
= wxBOLD
;
614 if (tmp
== wxT("ULTRABOLD")) M_FONTDATA
->m_weight
= wxBOLD
;
616 if (tmp
== wxT("LIGHT")) M_FONTDATA
->m_weight
= wxLIGHT
;
617 if (tmp
== wxT("THIN")) M_FONTDATA
->m_weight
= wxLIGHT
;
619 tmp
= tn
.GetNextToken().MakeUpper(); // slant
620 if (tmp
== wxT("I")) M_FONTDATA
->m_style
= wxITALIC
;
621 if (tmp
== wxT("O")) M_FONTDATA
->m_style
= wxITALIC
;
623 tn
.GetNextToken(); // set width
624 tn
.GetNextToken(); // add. style
625 tn
.GetNextToken(); // pixel size
627 tmp
= tn
.GetNextToken(); // pointsize
630 long num
= wxStrtol (tmp
.c_str(), (wxChar
**) NULL
, 10);
631 M_FONTDATA
->m_pointSize
= (int)(num
/ 10);
634 tn
.GetNextToken(); // x-res
635 tn
.GetNextToken(); // y-res
637 tmp
= tn
.GetNextToken().MakeUpper(); // spacing
640 M_FONTDATA
->m_family
= wxMODERN
;
641 else if (M_FONTDATA
->m_faceName
== wxT("TIMES"))
642 M_FONTDATA
->m_family
= wxROMAN
;
643 else if (M_FONTDATA
->m_faceName
== wxT("HELVETICA"))
644 M_FONTDATA
->m_family
= wxSWISS
;
645 else if (M_FONTDATA
->m_faceName
== wxT("LUCIDATYPEWRITER"))
646 M_FONTDATA
->m_family
= wxTELETYPE
;
647 else if (M_FONTDATA
->m_faceName
== wxT("LUCIDA"))
648 M_FONTDATA
->m_family
= wxDECORATIVE
;
649 else if (M_FONTDATA
->m_faceName
== wxT("UTOPIA"))
650 M_FONTDATA
->m_family
= wxSCRIPT
;
652 tn
.GetNextToken(); // avg width
654 // deal with font encoding
655 M_FONTDATA
->m_encoding
= enc
;
656 if ( M_FONTDATA
->m_encoding
== wxFONTENCODING_SYSTEM
)
658 wxString registry
= tn
.GetNextToken().MakeUpper(),
659 encoding
= tn
.GetNextToken().MakeUpper();
661 if ( registry
== _T("ISO8859") )
664 if ( wxSscanf(encoding
, wxT("%d"), &cp
) == 1 )
666 M_FONTDATA
->m_encoding
=
667 (wxFontEncoding
)(wxFONTENCODING_ISO8859_1
+ cp
- 1);
670 else if ( registry
== _T("MICROSOFT") )
673 if ( wxSscanf(encoding
, wxT("cp125%d"), &cp
) == 1 )
675 M_FONTDATA
->m_encoding
=
676 (wxFontEncoding
)(wxFONTENCODING_CP1250
+ cp
);
679 else if ( registry
== _T("KOI8") )
681 M_FONTDATA
->m_encoding
= wxFONTENCODING_KOI8
;
683 //else: unknown encoding - may be give a warning here?
689 #endif // !wxUSE_UNICODE
695 // ----------------------------------------------------------------------------
696 // change the font attributes
697 // ----------------------------------------------------------------------------
699 void wxFont
::Unshare()
701 // Don't change shared data
704 m_refData
= new wxFontRefData();
708 wxFontRefData
* ref
= new wxFontRefData(*(wxFontRefData
*)m_refData
);
714 // ----------------------------------------------------------------------------
716 // ----------------------------------------------------------------------------
718 int wxFont
::GetPointSize() const
720 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
722 return M_FONTDATA
->m_pointSize
;
725 wxString wxFont
::GetFaceName() const
727 wxCHECK_MSG( Ok(), wxEmptyString
, wxT("invalid font") );
729 return M_FONTDATA
->m_faceName
;
732 int wxFont
::GetFamily() const
734 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
736 return M_FONTDATA
->m_family
;
739 int wxFont
::GetStyle() const
741 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
743 return M_FONTDATA
->m_style
;
746 int wxFont
::GetWeight() const
748 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
750 return M_FONTDATA
->m_weight
;
753 bool wxFont
::GetUnderlined() const
755 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
757 return M_FONTDATA
->m_underlined
;
760 wxFontEncoding wxFont
::GetEncoding() const
762 wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT
, wxT("invalid font") );
764 return M_FONTDATA
->m_encoding
;
767 bool wxFont
::GetNoAntiAliasing() const
769 wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT
, wxT("invalid font") );
771 return M_FONTDATA
->m_noAA
;
774 const wxNativeFontInfo
*wxFont
::GetNativeFontInfo() const
776 wxCHECK_MSG( Ok(), (wxNativeFontInfo
*)NULL
, wxT("invalid font") );
780 if ( M_FONTDATA
->m_nativeFontInfo
.GetXFontName().empty() )
784 return &(M_FONTDATA
->m_nativeFontInfo
);
787 bool wxFont
::IsFixedWidth() const
789 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
792 return wxFontBase
::IsFixedWidth();
794 // Robert, is this right? HasNativeFont doesn't exist.
796 // if ( M_FONTDATA->HasNativeFont() )
798 // the monospace fonts are supposed to have "M" in the spacing field
799 wxString spacing
= M_FONTDATA
->
800 m_nativeFontInfo
.GetXFontComponent(wxXLFD_SPACING
);
802 return spacing
.Upper() == _T('M');
804 // Unreaceable code for now
805 // return wxFontBase::IsFixedWidth();
810 // ----------------------------------------------------------------------------
811 // change font attributes
812 // ----------------------------------------------------------------------------
814 void wxFont
::SetPointSize(int pointSize
)
818 M_FONTDATA
->SetPointSize(pointSize
);
821 void wxFont
::SetFamily(int family
)
825 M_FONTDATA
->SetFamily(family
);
828 void wxFont
::SetStyle(int style
)
832 M_FONTDATA
->SetStyle(style
);
835 void wxFont
::SetWeight(int weight
)
839 M_FONTDATA
->SetWeight(weight
);
842 bool wxFont
::SetFaceName(const wxString
& faceName
)
846 return M_FONTDATA
->SetFaceName(faceName
) &&
847 wxFontBase
::SetFaceName(faceName
);
850 void wxFont
::SetUnderlined(bool underlined
)
854 M_FONTDATA
->SetUnderlined(underlined
);
857 void wxFont
::SetEncoding(wxFontEncoding encoding
)
861 M_FONTDATA
->SetEncoding(encoding
);
864 void wxFont
::DoSetNativeFontInfo( const wxNativeFontInfo
& info
)
868 M_FONTDATA
->SetNativeFontInfo( info
);
871 void wxFont
::SetNoAntiAliasing( bool no
)
875 M_FONTDATA
->SetNoAntiAliasing( no
);
881 // ----------------------------------------------------------------------------
882 // X11 implementation
883 // ----------------------------------------------------------------------------
885 // Find an existing, or create a new, XFontStruct
886 // based on this wxFont and the given scale. Append the
887 // font to list in the private data for future reference.
888 wxXFont
* wxFont
::GetInternalFont(double scale
, WXDisplay
* display
) const
891 return (wxXFont
*)NULL
;
893 long intScale
= long(scale
* 100.0 + 0.5); // key for wxXFont
894 int pointSize
= (M_FONTDATA
->m_pointSize
* 10 * intScale
) / 100;
896 // search existing fonts first
897 wxList
::compatibility_iterator node
= M_FONTDATA
->m_fonts
.GetFirst();
900 wxXFont
* f
= (wxXFont
*) node
->GetData();
901 if ((!display
|| (f
->m_display
== display
)) && (f
->m_scale
== intScale
))
903 node
= node
->GetNext();
906 wxString xFontName
= M_FONTDATA
->m_nativeFontInfo
.GetXFontName();
907 if (xFontName
== "-*-*-*-*-*--*-*-*-*-*-*-*-*")
908 // wxFont constructor not called with native font info parameter => take M_FONTDATA values
911 // not found, create a new one
912 XFontStruct
*font
= (XFontStruct
*)
913 wxLoadQueryNearestFont(pointSize
,
914 M_FONTDATA
->m_family
,
916 M_FONTDATA
->m_weight
,
917 M_FONTDATA
->m_underlined
,
919 M_FONTDATA
->m_encoding
,
924 wxFAIL_MSG( wxT("Could not allocate even a default font -- something is wrong.") );
926 return (wxXFont
*) NULL
;
929 wxXFont
* f
= new wxXFont
;
930 f
->m_fontStruct
= (WXFontStructPtr
)font
;
931 f
->m_display
= ( display ? display
: wxGetDisplay() );
932 f
->m_scale
= intScale
;
933 M_FONTDATA
->m_fonts
.Append(f
);
938 WXFontStructPtr wxFont
::GetFontStruct(double scale
, WXDisplay
* display
) const
940 wxXFont
* f
= GetInternalFont(scale
, display
);
942 return (f ? f
->m_fontStruct
: (WXFontStructPtr
) 0);