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 // and this one also modifies all the other font data fields
129 void SetNativeFontInfo(const wxNativeFontInfo
& info
);
132 // common part of all ctors
138 const wxString
& faceName
,
139 wxFontEncoding encoding
);
141 // set all fields from (already initialized and valid) m_nativeFontInfo
142 void InitFromNative();
146 wxFontFamily m_family
;
148 wxFontWeight m_weight
;
151 wxFontEncoding m_encoding
; // Unused in Unicode mode
153 wxNativeFontInfo m_nativeFontInfo
;
155 void ClearX11Fonts();
159 // A list of wxXFonts
164 #define M_FONTDATA ((wxFontRefData*)m_refData)
166 // ----------------------------------------------------------------------------
168 // ----------------------------------------------------------------------------
170 void wxFontRefData::Init(int pointSize
,
175 const wxString
& faceName
,
176 wxFontEncoding encoding
)
178 m_family
= family
== wxFONTFAMILY_DEFAULT
? wxFONTFAMILY_SWISS
: family
;
180 m_faceName
= faceName
;
182 // we accept both wxDEFAULT and wxNORMAL here - should we?
183 m_style
= style
== wxDEFAULT
? wxFONTSTYLE_NORMAL
: style
;
184 m_weight
= weight
== wxDEFAULT
? wxFONTWEIGHT_NORMAL
: weight
;
186 m_underlined
= underlined
;
187 m_encoding
= encoding
;
190 if ( m_nativeFontInfo
.description
)
191 pango_font_description_free(m_nativeFontInfo
.description
);
193 // Create native font info
194 m_nativeFontInfo
.description
= pango_font_description_new();
196 // if a face name is specified, use it if it's available, otherwise use
198 if ( faceName
.empty() || !wxFontEnumerator::IsValidFacename(faceName
) )
200 // TODO: scan system for valid fonts matching the given family instead
201 // of hardcoding them here
204 case wxFONTFAMILY_TELETYPE
:
205 m_faceName
= wxT("monospace");
208 case wxFONTFAMILY_ROMAN
:
209 m_faceName
= wxT("serif");
213 m_faceName
= wxT("sans");
216 else // specified face name is available, use it
218 m_faceName
= faceName
;
221 m_nativeFontInfo
.SetFaceName(m_faceName
);
222 m_nativeFontInfo
.SetWeight((wxFontWeight
)m_weight
);
223 m_nativeFontInfo
.SetStyle((wxFontStyle
)m_style
);
224 #endif // wxUSE_UNICODE
226 SetPointSize(pointSize
);
229 void wxFontRefData::InitFromNative()
233 PangoFontDescription
*desc
= m_nativeFontInfo
.description
;
236 m_faceName
= wxGTK_CONV_BACK( pango_font_description_get_family( desc
) );
238 m_pointSize
= pango_font_description_get_size( desc
) / PANGO_SCALE
;
240 switch (pango_font_description_get_style( desc
))
242 case PANGO_STYLE_NORMAL
:
243 m_style
= wxFONTSTYLE_NORMAL
;
245 case PANGO_STYLE_ITALIC
:
246 m_style
= wxFONTSTYLE_ITALIC
;
248 case PANGO_STYLE_OBLIQUE
:
249 m_style
= wxFONTSTYLE_SLANT
;
253 // Not defined in some Pango versions
254 #define wxPANGO_WEIGHT_SEMIBOLD 600
256 switch (pango_font_description_get_weight( desc
))
258 case PANGO_WEIGHT_ULTRALIGHT
:
259 case PANGO_WEIGHT_LIGHT
:
260 m_weight
= wxFONTWEIGHT_LIGHT
;
264 wxFAIL_MSG(wxT("unknown Pango font weight"));
267 case PANGO_WEIGHT_NORMAL
:
268 m_weight
= wxFONTWEIGHT_NORMAL
;
271 case wxPANGO_WEIGHT_SEMIBOLD
:
272 case PANGO_WEIGHT_BOLD
:
273 case PANGO_WEIGHT_ULTRABOLD
:
274 case PANGO_WEIGHT_HEAVY
:
275 m_weight
= wxFONTWEIGHT_BOLD
;
279 if (m_faceName
== wxT("monospace"))
281 m_family
= wxFONTFAMILY_TELETYPE
;
283 else if (m_faceName
== wxT("sans"))
285 m_family
= wxFONTFAMILY_SWISS
;
289 m_family
= wxFONTFAMILY_UNKNOWN
;
292 // Pango description are never underlined (?)
293 m_underlined
= false;
295 // Cannot we choose that
296 m_encoding
= wxFONTENCODING_SYSTEM
;
298 // get the font parameters from the XLFD
299 // -------------------------------------
301 m_faceName
= m_nativeFontInfo
.GetXFontComponent(wxXLFD_FAMILY
);
303 m_weight
= wxFONTWEIGHT_NORMAL
;
305 wxString w
= m_nativeFontInfo
.GetXFontComponent(wxXLFD_WEIGHT
).Upper();
306 if ( !w
.empty() && w
!= wxT('*') )
308 // the test below catches all of BOLD, EXTRABOLD, DEMIBOLD, ULTRABOLD
310 if ( ((w
[0u] == wxT('B') && (!wxStrcmp(w
.c_str() + 1, wxT("OLD")) ||
311 !wxStrcmp(w
.c_str() + 1, wxT("LACK"))))) ||
312 wxStrstr(w
.c_str() + 1, wxT("BOLD")) )
314 m_weight
= wxFONTWEIGHT_BOLD
;
316 else if ( w
== wxT("LIGHT") || w
== wxT("THIN") )
318 m_weight
= wxFONTWEIGHT_LIGHT
;
322 switch ( wxToupper( m_nativeFontInfo
.
323 GetXFontComponent(wxXLFD_SLANT
)[0u]).GetValue() )
325 case wxT('I'): // italique
326 m_style
= wxFONTSTYLE_ITALIC
;
329 case wxT('O'): // oblique
330 m_style
= wxFONTSTYLE_SLANT
;
334 m_style
= wxFONTSTYLE_NORMAL
;
338 if ( m_nativeFontInfo
.GetXFontComponent(wxXLFD_POINTSIZE
).ToLong(&ptSize
) )
340 // size in XLFD is in 10 point units
341 m_pointSize
= (int)(ptSize
/ 10);
345 m_pointSize
= wxDEFAULT_FONT_SIZE
;
348 // examine the spacing: if the font is monospaced, assume wxTELETYPE
349 // family for compatibility with the old code which used it instead of
351 if ( m_nativeFontInfo
.GetXFontComponent(wxXLFD_SPACING
).Upper() == wxT('M') )
353 m_family
= wxFONTFAMILY_TELETYPE
;
355 else // not monospaceed
357 // don't even try guessing it, it doesn't work for too many fonts
359 m_family
= wxFONTFAMILY_UNKNOWN
;
362 // X fonts are never underlined...
363 m_underlined
= false;
365 // deal with font encoding
367 registry
= m_nativeFontInfo
.GetXFontComponent(wxXLFD_REGISTRY
).Upper(),
368 encoding
= m_nativeFontInfo
.GetXFontComponent(wxXLFD_ENCODING
).Upper();
370 if ( registry
== wxT("ISO8859") )
373 if ( wxSscanf(encoding
, wxT("%d"), &cp
) == 1 )
375 m_encoding
= (wxFontEncoding
)(wxFONTENCODING_ISO8859_1
+ cp
- 1);
378 else if ( registry
== wxT("MICROSOFT") )
381 if ( wxSscanf(encoding
, wxT("cp125%d"), &cp
) == 1 )
383 m_encoding
= (wxFontEncoding
)(wxFONTENCODING_CP1250
+ cp
);
386 else if ( registry
== wxT("KOI8") )
388 m_encoding
= wxFONTENCODING_KOI8
;
390 else // unknown encoding
392 // may be give a warning here? or use wxFontMapper?
393 m_encoding
= wxFONTENCODING_SYSTEM
;
398 wxFontRefData::wxFontRefData( const wxFontRefData
& data
)
401 m_pointSize
= data
.m_pointSize
;
402 m_family
= data
.m_family
;
403 m_style
= data
.m_style
;
404 m_weight
= data
.m_weight
;
406 m_underlined
= data
.m_underlined
;
408 m_faceName
= data
.m_faceName
;
409 m_encoding
= data
.m_encoding
;
411 m_nativeFontInfo
= data
.m_nativeFontInfo
;
414 wxFontRefData::wxFontRefData(int size
, wxFontFamily family
, wxFontStyle style
,
415 wxFontWeight weight
, bool underlined
,
416 const wxString
& faceName
,
417 wxFontEncoding encoding
)
419 Init(size
, family
, style
, weight
, underlined
, faceName
, encoding
);
422 wxFontRefData::wxFontRefData(const wxString
& fontname
)
424 // VZ: FromString() should really work in both cases, doesn't it?
426 m_nativeFontInfo
.FromString( fontname
);
428 m_nativeFontInfo
.SetXFontName(fontname
);
434 void wxFontRefData::ClearX11Fonts()
438 wxList::compatibility_iterator node
= m_fonts
.GetFirst();
441 wxXFont
* f
= (wxXFont
*) node
->GetData();
443 node
= node
->GetNext();
449 wxFontRefData::~wxFontRefData()
454 // ----------------------------------------------------------------------------
455 // wxFontRefData SetXXX()
456 // ----------------------------------------------------------------------------
458 void wxFontRefData::SetPointSize(int pointSize
)
460 // NB: Pango doesn't support point sizes less than 1
461 m_pointSize
= pointSize
== wxDEFAULT
|| pointSize
< 1 ? wxDEFAULT_FONT_SIZE
465 m_nativeFontInfo
.SetPointSize(m_pointSize
);
469 void wxFontRefData::SetFamily(wxFontFamily family
)
473 // TODO: what are we supposed to do with m_nativeFontInfo here?
476 void wxFontRefData::SetStyle(wxFontStyle style
)
482 PangoFontDescription
*desc
= m_nativeFontInfo
.description
;
486 case wxFONTSTYLE_ITALIC
:
487 pango_font_description_set_style( desc
, PANGO_STYLE_ITALIC
);
489 case wxFONTSTYLE_SLANT
:
490 pango_font_description_set_style( desc
, PANGO_STYLE_OBLIQUE
);
493 wxFAIL_MSG( wxT("unknown font style") );
495 case wxFONTSTYLE_NORMAL
:
496 pango_font_description_set_style( desc
, PANGO_STYLE_NORMAL
);
502 void wxFontRefData::SetWeight(wxFontWeight weight
)
507 void wxFontRefData::SetUnderlined(bool underlined
)
509 m_underlined
= underlined
;
511 // the XLFD doesn't have "underlined" field anyhow
514 bool wxFontRefData::SetFaceName(const wxString
& facename
)
516 m_faceName
= facename
;
520 void wxFontRefData::SetEncoding(wxFontEncoding encoding
)
522 m_encoding
= encoding
;
525 void wxFontRefData::SetNativeFontInfo(const wxNativeFontInfo
& info
)
527 // previously cached fonts shouldn't be used
530 m_nativeFontInfo
= info
;
532 // set all the other font parameters from the native font info
536 // ----------------------------------------------------------------------------
538 // ----------------------------------------------------------------------------
540 wxFont::wxFont(const wxNativeFontInfo
& info
)
543 Create( info
.GetPointSize(),
547 info
.GetUnderlined(),
549 info
.GetEncoding() );
551 (void) Create(info
.GetXFontName());
555 bool wxFont::Create(int pointSize
,
560 const wxString
& faceName
,
561 wxFontEncoding encoding
)
565 m_refData
= new wxFontRefData(pointSize
, family
, style
, weight
,
566 underlined
, faceName
, encoding
);
573 bool wxFont::Create(const wxString
& fontname
, wxFontEncoding enc
)
577 *this = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT
);
581 m_refData
= new wxFontRefData();
583 M_FONTDATA
->m_nativeFontInfo
.SetXFontName(fontname
); // X font name
587 wxStringTokenizer
tn( fontname
, wxT("-") );
589 tn
.GetNextToken(); // skip initial empty token
590 tn
.GetNextToken(); // foundry
593 M_FONTDATA
->m_faceName
= tn
.GetNextToken(); // family
595 tmp
= tn
.GetNextToken().MakeUpper(); // weight
596 if (tmp
== wxT("BOLD")) M_FONTDATA
->m_weight
= wxFONTWEIGHT_BOLD
;
597 if (tmp
== wxT("BLACK")) M_FONTDATA
->m_weight
= wxFONTWEIGHT_BOLD
;
598 if (tmp
== wxT("EXTRABOLD")) M_FONTDATA
->m_weight
= wxFONTWEIGHT_BOLD
;
599 if (tmp
== wxT("DEMIBOLD")) M_FONTDATA
->m_weight
= wxFONTWEIGHT_BOLD
;
600 if (tmp
== wxT("ULTRABOLD")) M_FONTDATA
->m_weight
= wxFONTWEIGHT_BOLD
;
602 if (tmp
== wxT("LIGHT")) M_FONTDATA
->m_weight
= wxFONTWEIGHT_LIGHT
;
603 if (tmp
== wxT("THIN")) M_FONTDATA
->m_weight
= wxFONTWEIGHT_LIGHT
;
605 tmp
= tn
.GetNextToken().MakeUpper(); // slant
606 if (tmp
== wxT("I")) M_FONTDATA
->m_style
= wxFONTSTYLE_ITALIC
;
607 if (tmp
== wxT("O")) M_FONTDATA
->m_style
= wxFONTSTYLE_ITALIC
;
609 tn
.GetNextToken(); // set width
610 tn
.GetNextToken(); // add. style
611 tn
.GetNextToken(); // pixel size
613 tmp
= tn
.GetNextToken(); // pointsize
616 long num
= wxStrtol (tmp
.c_str(), (wxChar
**) NULL
, 10);
617 M_FONTDATA
->m_pointSize
= (int)(num
/ 10);
620 tn
.GetNextToken(); // x-res
621 tn
.GetNextToken(); // y-res
623 tmp
= tn
.GetNextToken().MakeUpper(); // spacing
626 M_FONTDATA
->m_family
= wxFONTFAMILY_MODERN
;
627 else if (M_FONTDATA
->m_faceName
== wxT("TIMES"))
628 M_FONTDATA
->m_family
= wxFONTFAMILY_ROMAN
;
629 else if (M_FONTDATA
->m_faceName
== wxT("HELVETICA"))
630 M_FONTDATA
->m_family
= wxFONTFAMILY_SWISS
;
631 else if (M_FONTDATA
->m_faceName
== wxT("LUCIDATYPEWRITER"))
632 M_FONTDATA
->m_family
= wxFONTFAMILY_TELETYPE
;
633 else if (M_FONTDATA
->m_faceName
== wxT("LUCIDA"))
634 M_FONTDATA
->m_family
= wxFONTFAMILY_DECORATIVE
;
635 else if (M_FONTDATA
->m_faceName
== wxT("UTOPIA"))
636 M_FONTDATA
->m_family
= wxFONTFAMILY_SCRIPT
;
638 tn
.GetNextToken(); // avg width
640 // deal with font encoding
641 M_FONTDATA
->m_encoding
= enc
;
642 if ( M_FONTDATA
->m_encoding
== wxFONTENCODING_SYSTEM
)
644 wxString registry
= tn
.GetNextToken().MakeUpper(),
645 encoding
= tn
.GetNextToken().MakeUpper();
647 if ( registry
== wxT("ISO8859") )
650 if ( wxSscanf(encoding
, wxT("%d"), &cp
) == 1 )
652 M_FONTDATA
->m_encoding
=
653 (wxFontEncoding
)(wxFONTENCODING_ISO8859_1
+ cp
- 1);
656 else if ( registry
== wxT("MICROSOFT") )
659 if ( wxSscanf(encoding
, wxT("cp125%d"), &cp
) == 1 )
661 M_FONTDATA
->m_encoding
=
662 (wxFontEncoding
)(wxFONTENCODING_CP1250
+ cp
);
665 else if ( registry
== wxT("KOI8") )
667 M_FONTDATA
->m_encoding
= wxFONTENCODING_KOI8
;
669 //else: unknown encoding - may be give a warning here?
675 #endif // !wxUSE_UNICODE
681 wxGDIRefData
*wxFont::CreateGDIRefData() const
683 return new wxFontRefData
;
686 wxGDIRefData
*wxFont::CloneGDIRefData(const wxGDIRefData
*data
) const
688 return new wxFontRefData(*static_cast<const wxFontRefData
*>(data
));
691 // ----------------------------------------------------------------------------
692 // change the font attributes
693 // ----------------------------------------------------------------------------
695 void wxFont::Unshare()
697 // Don't change shared data
700 m_refData
= new wxFontRefData();
704 wxFontRefData
* ref
= new wxFontRefData(*(wxFontRefData
*)m_refData
);
710 // ----------------------------------------------------------------------------
712 // ----------------------------------------------------------------------------
714 int wxFont::GetPointSize() const
716 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
718 return M_FONTDATA
->m_pointSize
;
721 wxString
wxFont::GetFaceName() const
723 wxCHECK_MSG( Ok(), wxEmptyString
, wxT("invalid font") );
725 return M_FONTDATA
->m_faceName
;
728 wxFontFamily
wxFont::DoGetFamily() const
730 return M_FONTDATA
->m_family
;
733 wxFontStyle
wxFont::GetStyle() const
735 wxCHECK_MSG( Ok(), wxFONTSTYLE_MAX
, wxT("invalid font") );
737 return M_FONTDATA
->m_style
;
740 wxFontWeight
wxFont::GetWeight() const
742 wxCHECK_MSG( Ok(), wxFONTWEIGHT_MAX
, wxT("invalid font") );
744 return M_FONTDATA
->m_weight
;
747 bool wxFont::GetUnderlined() const
749 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
751 return M_FONTDATA
->m_underlined
;
754 wxFontEncoding
wxFont::GetEncoding() const
756 wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT
, wxT("invalid font") );
758 return M_FONTDATA
->m_encoding
;
761 const wxNativeFontInfo
*wxFont::GetNativeFontInfo() const
763 wxCHECK_MSG( Ok(), NULL
, wxT("invalid font") );
767 if ( M_FONTDATA
->m_nativeFontInfo
.GetXFontName().empty() )
771 return &(M_FONTDATA
->m_nativeFontInfo
);
774 bool wxFont::IsFixedWidth() const
776 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
779 return wxFontBase::IsFixedWidth();
781 // Robert, is this right? HasNativeFont doesn't exist.
783 // if ( M_FONTDATA->HasNativeFont() )
785 // the monospace fonts are supposed to have "M" in the spacing field
786 wxString spacing
= M_FONTDATA
->
787 m_nativeFontInfo
.GetXFontComponent(wxXLFD_SPACING
);
789 return spacing
.Upper() == wxT('M');
791 // Unreaceable code for now
792 // return wxFontBase::IsFixedWidth();
797 // ----------------------------------------------------------------------------
798 // change font attributes
799 // ----------------------------------------------------------------------------
801 void wxFont::SetPointSize(int pointSize
)
805 M_FONTDATA
->SetPointSize(pointSize
);
808 void wxFont::SetFamily(wxFontFamily family
)
812 M_FONTDATA
->SetFamily(family
);
815 void wxFont::SetStyle(wxFontStyle style
)
819 M_FONTDATA
->SetStyle(style
);
822 void wxFont::SetWeight(wxFontWeight weight
)
826 M_FONTDATA
->SetWeight(weight
);
829 bool wxFont::SetFaceName(const wxString
& faceName
)
833 return M_FONTDATA
->SetFaceName(faceName
) &&
834 wxFontBase::SetFaceName(faceName
);
837 void wxFont::SetUnderlined(bool underlined
)
841 M_FONTDATA
->SetUnderlined(underlined
);
844 void wxFont::SetEncoding(wxFontEncoding encoding
)
848 M_FONTDATA
->SetEncoding(encoding
);
851 void wxFont::DoSetNativeFontInfo( const wxNativeFontInfo
& info
)
855 M_FONTDATA
->SetNativeFontInfo( info
);
860 // ----------------------------------------------------------------------------
861 // X11 implementation
862 // ----------------------------------------------------------------------------
864 // Find an existing, or create a new, XFontStruct
865 // based on this wxFont and the given scale. Append the
866 // font to list in the private data for future reference.
867 wxXFont
* wxFont::GetInternalFont(double scale
, WXDisplay
* display
) const
872 long intScale
= long(scale
* 100.0 + 0.5); // key for wxXFont
873 int pointSize
= (M_FONTDATA
->m_pointSize
* 10 * intScale
) / 100;
875 // search existing fonts first
876 wxList::compatibility_iterator node
= M_FONTDATA
->m_fonts
.GetFirst();
879 wxXFont
* f
= (wxXFont
*) node
->GetData();
880 if ((!display
|| (f
->m_display
== display
)) && (f
->m_scale
== intScale
))
882 node
= node
->GetNext();
885 wxString xFontName
= M_FONTDATA
->m_nativeFontInfo
.GetXFontName();
886 if (xFontName
== "-*-*-*-*-*--*-*-*-*-*-*-*-*")
887 // wxFont constructor not called with native font info parameter => take M_FONTDATA values
890 // not found, create a new one
891 XFontStruct
*font
= (XFontStruct
*)
892 wxLoadQueryNearestFont(pointSize
,
893 M_FONTDATA
->m_family
,
895 M_FONTDATA
->m_weight
,
896 M_FONTDATA
->m_underlined
,
898 M_FONTDATA
->m_encoding
,
903 wxFAIL_MSG( wxT("Could not allocate even a default font -- something is wrong.") );
908 wxXFont
* f
= new wxXFont
;
909 f
->m_fontStruct
= (WXFontStructPtr
)font
;
910 f
->m_display
= ( display
? display
: wxGetDisplay() );
911 f
->m_scale
= intScale
;
912 M_FONTDATA
->m_fonts
.Append(f
);
917 WXFontStructPtr
wxFont::GetFontStruct(double scale
, WXDisplay
* display
) const
919 wxXFont
* f
= GetInternalFont(scale
, display
);
921 return (f
? f
->m_fontStruct
: (WXFontStructPtr
) 0);
924 #endif // !wxUSE_UNICODE