1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxFont class
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 // For compilers that support precompilation, includes "wx.h".
22 #include "wx/wxprec.h"
33 #include "wx/os2/private.h"
35 #include "wx/fontutil.h"
36 #include "wx/fontmap.h"
38 #include "wx/tokenzr.h"
40 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
)
42 // ----------------------------------------------------------------------------
43 // wxFontRefData - the internal description of the font
44 // ----------------------------------------------------------------------------
46 class WXDLLEXPORT wxFontRefData
: public wxGDIRefData
51 Init(-1, wxFONTFAMILY_DEFAULT
, wxFONTSTYLE_NORMAL
, wxFONTWEIGHT_NORMAL
, FALSE
,
52 "", wxFONTENCODING_DEFAULT
);
55 wxFontRefData( int nSize
60 ,const wxString
& sFaceName
61 ,wxFontEncoding vEncoding
74 wxFontRefData( const wxNativeFontInfo
& rInfo
85 wxFontRefData(const wxFontRefData
& rData
)
87 Init( rData
.m_nPointSize
95 m_nFontId
= rData
.m_nFontId
;
98 virtual ~wxFontRefData();
103 bool Alloc(wxFont
* pFont
);
107 // All wxFont accessors
109 inline int GetPointSize(void) const
112 // We don't use the actual native font point size since it is
113 // the chosen physical font, which is usually only and approximation
114 // of the desired outline font. The actual displayable point size
115 // is the one stored in the refData
120 inline int GetFamily(void) const
125 inline int GetStyle(void) const
127 return m_bNativeFontInfoOk
? m_vNativeFontInfo
.GetStyle()
131 inline int GetWeight(void) const
133 return m_bNativeFontInfoOk
? m_vNativeFontInfo
.GetWeight()
137 inline bool GetUnderlined(void) const
139 return m_bNativeFontInfoOk
? m_vNativeFontInfo
.GetUnderlined()
143 inline wxString
GetFaceName(void) const
147 if (m_bNativeFontInfoOk
)
148 sFaceName
= m_vNativeFontInfo
.GetFaceName();
150 sFaceName
= m_sFaceName
;
155 inline wxFontEncoding
GetEncoding(void) const
157 return m_bNativeFontInfoOk
? m_vNativeFontInfo
.GetEncoding()
161 inline WXHFONT
GetHFONT(void) const { return m_hFont
; }
162 inline HPS
GetPS(void) const { return m_hPS
; }
163 inline PFONTMETRICS
GetFM(void) const { return m_pFM
; }
164 inline int GetNumFonts(void) const { return m_nNumFonts
; }
167 inline void SetPointSize(int nPointSize
)
169 if (m_bNativeFontInfoOk
)
170 m_vNativeFontInfo
.SetPointSize(nPointSize
);
172 m_nPointSize
= nPointSize
;
175 inline void SetFamily(int nFamily
)
180 inline void SetStyle(int nStyle
)
182 if (m_bNativeFontInfoOk
)
183 m_vNativeFontInfo
.SetStyle((wxFontStyle
)nStyle
);
188 inline void SetWeight(int nWeight
)
190 if (m_bNativeFontInfoOk
)
191 m_vNativeFontInfo
.SetWeight((wxFontWeight
)nWeight
);
196 inline void SetFaceName(const wxString
& sFaceName
)
198 if (m_bNativeFontInfoOk
)
199 m_vNativeFontInfo
.SetFaceName(sFaceName
);
201 m_sFaceName
= sFaceName
;
204 inline void SetUnderlined(bool bUnderlined
)
206 if (m_bNativeFontInfoOk
)
207 m_vNativeFontInfo
.SetUnderlined(bUnderlined
);
209 m_bUnderlined
= bUnderlined
;
212 inline void SetEncoding(wxFontEncoding vEncoding
)
214 if (m_bNativeFontInfoOk
)
215 m_vNativeFontInfo
.SetEncoding(vEncoding
);
217 m_vEncoding
= vEncoding
;
220 inline void SetPS(HPS hPS
)
225 inline void SetFM(PFONTMETRICS pFM
)
230 inline void SetNumFonts(int nNumFonts
)
232 m_nNumFonts
= nNumFonts
;
236 // Native font info tests
238 bool HasNativeFontInfo() const { return m_bNativeFontInfoOk
; }
240 const wxNativeFontInfo
& GetNativeFontInfo() const
241 { return m_vNativeFontInfo
; }
245 // Common part of all ctors
252 ,const wxString
& rsFaceName
253 ,wxFontEncoding vEncoding
256 void Init( const wxNativeFontInfo
& rInfo
261 // If TRUE, the pointer to the actual font is temporary and SHOULD NOT BE
262 // DELETED by destructor
268 // Font characterstics
275 wxString m_sFaceName
;
276 wxFontEncoding m_vEncoding
;
282 wxNativeFontInfo m_vNativeFontInfo
;
283 bool m_bNativeFontInfoOk
;
286 // Some PM specific stuff
288 PFONTMETRICS m_pFM
; // array of FONTMETRICS structs
289 int m_nNumFonts
; // number of fonts in array
290 HPS m_hPS
; // PS handle this font belongs to
291 FATTRS m_vFattrs
; // Current fattrs struct
292 FACENAMEDESC m_vFname
; // Current facename struct
293 bool m_bInternalPS
; // Internally generated PS?
294 }; // end of CLASS wxFontRefData
296 // ============================================================================
298 // ============================================================================
300 // ----------------------------------------------------------------------------
302 // ----------------------------------------------------------------------------
304 void wxFontRefData::Init(
310 , const wxString
& rsFaceName
311 , wxFontEncoding vEncoding
315 m_nPointSize
= nPointSize
;
319 m_bUnderlined
= bUnderlined
;
320 m_sFaceName
= rsFaceName
;
321 m_vEncoding
= vEncoding
;
324 m_bNativeFontInfoOk
= FALSE
;
327 m_bTemporary
= FALSE
;
328 m_pFM
= (PFONTMETRICS
)NULL
;
331 } // end of wxFontRefData::Init
333 void wxFontRefData::Init(
334 const wxNativeFontInfo
& rInfo
335 , WXHFONT hFont
//this is the FontId -- functions as the hFont for OS/2
336 , WXHANDLE hPS
// Presentation Space we are using
340 // hFont may be zero, or it be passed in case we really want to
341 // use the exact font created in the underlying system
342 // (for example where we can't guarantee conversion from HFONT
343 // to LOGFONT back to HFONT)
346 m_nFontId
= (int)hFont
;
348 m_bNativeFontInfoOk
= TRUE
;
349 m_vNativeFontInfo
= rInfo
;
351 if (m_hPS
== NULLHANDLE
)
353 m_hPS
= ::WinGetPS(HWND_DESKTOP
);
354 m_bInternalPS
= TRUE
;
360 wxFontRefData::~wxFontRefData()
365 bool wxFontRefData::Alloc(
373 PFONTMETRICS pFM
= NULL
;
377 if (!m_bNativeFontInfoOk
)
379 wxFillLogFont( &m_vNativeFontInfo
.fa
380 ,&m_vNativeFontInfo
.fn
387 m_bNativeFontInfoOk
= TRUE
;
398 if((lRc
= ::GpiCreateLogFont( m_hPS
401 ,&m_vNativeFontInfo
.fa
404 m_hFont
= (WXHFONT
)flId
;
409 vError
= ::WinGetLastError(vHabmain
);
410 sError
= wxPMErrorToStr(vError
);
411 wxLogLastError("CreateFont");
414 ::GpiSetCharSet(m_hPS
, flId
); // sets font for presentation space
415 ::GpiQueryFontMetrics(m_hPS
, sizeof(FONTMETRICS
), &m_vNativeFontInfo
.fm
);
418 // Set refData members with the results
420 memcpy(&m_vFattrs
, &m_vNativeFontInfo
.fa
, sizeof(m_vFattrs
));
421 memcpy(&m_vFname
, &m_vNativeFontInfo
.fn
, sizeof(m_vFname
));
423 // Going to leave the point size alone. Mostly we use outline fonts
424 // that can be set to any point size inside of Presentation Parameters,
425 // regardless of whether or not the actual font is registered in the system.
426 // The GpiCreateLogFont will do enough by selecting the right family,
429 if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Times New Roman") == 0)
431 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Times New Roman MT 30") == 0)
433 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "@Times New Roman MT 30") == 0)
435 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Tms Rmn") == 0)
437 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "WarpSans") == 0)
438 m_nFamily
= wxDECORATIVE
;
439 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Helvitica") == 0)
441 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Helv") == 0)
443 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Script") == 0)
444 m_nFamily
= wxSCRIPT
;
445 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Courier New") == 0)
446 m_nFamily
= wxTELETYPE
;
447 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Courier") == 0)
448 m_nFamily
= wxTELETYPE
;
449 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "System Monospaced") == 0)
450 m_nFamily
= wxTELETYPE
;
451 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "System VIO") == 0)
452 m_nFamily
= wxTELETYPE
;
453 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "System Proportional") == 0)
454 m_nFamily
= wxMODERN
;
455 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Arial") == 0)
456 m_nFamily
= wxMODERN
;
460 if (m_vNativeFontInfo
.fa
.fsSelection
& FATTR_SEL_ITALIC
)
461 m_nStyle
= wxFONTSTYLE_ITALIC
;
463 m_nStyle
= wxFONTSTYLE_NORMAL
;
464 switch(m_vNativeFontInfo
.fn
.usWeightClass
)
466 case FWEIGHT_DONT_CARE
:
467 m_nWeight
= wxFONTWEIGHT_NORMAL
;
471 m_nWeight
= wxFONTWEIGHT_NORMAL
;
475 m_nWeight
= wxFONTWEIGHT_LIGHT
;
479 m_nWeight
= wxFONTWEIGHT_BOLD
;
482 case FWEIGHT_ULTRA_BOLD
:
483 m_nWeight
= wxFONTWEIGHT_MAX
;
487 m_nWeight
= wxFONTWEIGHT_NORMAL
;
489 m_bUnderlined
= ((m_vNativeFontInfo
.fa
.fsSelection
& FATTR_SEL_UNDERSCORE
) != 0);
490 m_sFaceName
= m_vNativeFontInfo
.fa
.szFacename
;
491 m_vEncoding
= wxGetFontEncFromCharSet(m_vNativeFontInfo
.fa
.usCodePage
);
494 // We don't actuall keep the font around if using a temporary PS
499 ::GpiDeleteSetId( m_hPS
503 ::WinReleasePS(m_hPS
);
507 // Select the font into the Presentation space
509 ::GpiSetCharSet(m_hPS
, flId
); // sets font for presentation space
511 } // end of wxFontRefData::Alloc
513 void wxFontRefData::Free()
517 m_pFM
= (PFONTMETRICS
)NULL
;
521 ::GpiDeleteSetId(m_hPS
, 1L); /* delete the logical font */
526 ::WinReleasePS(m_hPS
);
528 } // end of wxFontRefData::Free
530 // ----------------------------------------------------------------------------
532 // ----------------------------------------------------------------------------
534 void wxNativeFontInfo::Init()
536 memset(&fa
, '\0', sizeof(FATTRS
));
537 } // end of wxNativeFontInfo::Init
539 int wxNativeFontInfo::GetPointSize() const
542 } // end of wxNativeFontInfo::GetPointSize
544 wxFontStyle
wxNativeFontInfo::GetStyle() const
546 return fa
.fsSelection
& FATTR_SEL_ITALIC
? wxFONTSTYLE_ITALIC
: wxFONTSTYLE_NORMAL
;
547 } // end of wxNativeFontInfo::GetStyle
549 wxFontWeight
wxNativeFontInfo::GetWeight() const
551 switch(fn
.usWeightClass
)
553 case FWEIGHT_DONT_CARE
:
554 return wxFONTWEIGHT_NORMAL
;
557 return wxFONTWEIGHT_NORMAL
;
560 return wxFONTWEIGHT_LIGHT
;
563 return wxFONTWEIGHT_BOLD
;
565 case FWEIGHT_ULTRA_BOLD
:
566 return wxFONTWEIGHT_MAX
;
568 return wxFONTWEIGHT_NORMAL
;
569 } // end of wxNativeFontInfo::GetWeight
571 bool wxNativeFontInfo::GetUnderlined() const
573 return ((fa
.fsSelection
& FATTR_SEL_UNDERSCORE
) != 0);
574 } // end of wxNativeFontInfo::GetUnderlined
576 wxString
wxNativeFontInfo::GetFaceName() const
578 return fm
.szFacename
;
579 } // end of wxNativeFontInfo::GetFaceName
581 wxFontFamily
wxNativeFontInfo::GetFamily() const
586 // Extract family from facename
588 if (strcmp(fm
.szFamilyname
, "Times New Roman") == 0)
590 else if (strcmp(fm
.szFamilyname
, "Times New Roman MT 30") == 0)
592 else if (strcmp(fm
.szFamilyname
, "@Times New Roman MT 30") == 0)
594 else if (strcmp(fm
.szFamilyname
, "Tms Rmn") == 0)
596 else if (strcmp(fm
.szFamilyname
, "WarpSans") == 0)
597 nFamily
= wxDECORATIVE
;
598 else if (strcmp(fm
.szFamilyname
, "Helvitica") == 0)
600 else if (strcmp(fm
.szFamilyname
, "Helv") == 0)
602 else if (strcmp(fm
.szFamilyname
, "Script") == 0)
604 else if (strcmp(fm
.szFamilyname
, "Courier New") == 0)
605 nFamily
= wxTELETYPE
;
606 else if (strcmp(fm
.szFamilyname
, "Courier") == 0)
607 nFamily
= wxTELETYPE
;
608 else if (strcmp(fm
.szFamilyname
, "System Monospaced") == 0)
609 nFamily
= wxTELETYPE
;
610 else if (strcmp(fm
.szFamilyname
, "System VIO") == 0)
611 nFamily
= wxTELETYPE
;
612 else if (strcmp(fm
.szFamilyname
, "System Proportional") == 0)
614 else if (strcmp(fm
.szFamilyname
, "Arial") == 0)
618 return (wxFontFamily
)nFamily
;
619 } // end of wxNativeFontInfo::GetFamily
621 wxFontEncoding
wxNativeFontInfo::GetEncoding() const
623 return wxGetFontEncFromCharSet(fa
.usCodePage
);
624 } // end of wxNativeFontInfo::GetEncoding
626 void wxNativeFontInfo::SetPointSize(
630 fm
.lEmHeight
= (LONG
)nPointsize
;
631 } // end of wxNativeFontInfo::SetPointSize
633 void wxNativeFontInfo::SetStyle(
640 wxFAIL_MSG( _T("unknown font style") );
643 case wxFONTSTYLE_NORMAL
:
646 case wxFONTSTYLE_ITALIC
:
647 case wxFONTSTYLE_SLANT
:
648 fa
.fsSelection
|= FATTR_SEL_ITALIC
;
651 } // end of wxNativeFontInfo::SetStyle
653 void wxNativeFontInfo::SetWeight(
660 wxFAIL_MSG( _T("unknown font weight") );
663 case wxFONTWEIGHT_NORMAL
:
664 fn
.usWeightClass
= FWEIGHT_NORMAL
;
667 case wxFONTWEIGHT_LIGHT
:
668 fn
.usWeightClass
= FWEIGHT_LIGHT
;
671 case wxFONTWEIGHT_BOLD
:
672 fn
.usWeightClass
= FWEIGHT_BOLD
;
675 } // end of wxNativeFontInfo::SetWeight
677 void wxNativeFontInfo::SetUnderlined(
682 fa
.fsSelection
|= FATTR_SEL_UNDERSCORE
;
683 } // end of wxNativeFontInfo::SetUnderlined
685 void wxNativeFontInfo::SetFaceName(
689 wxStrncpy(fa
.szFacename
, sFacename
, WXSIZEOF(fa
.szFacename
));
690 } // end of wxNativeFontInfo::SetFaceName
692 void wxNativeFontInfo::SetFamily(
701 sFacename
= wxT("Script");
705 sFacename
= wxT("WarpSans");
709 sFacename
= wxT("Times New Roman");
713 sFacename
= wxT("Courier New") ;
717 sFacename
= wxT("Arial") ;
721 sFacename
= wxT("Helv") ;
726 sFacename
= wxT("System Proportional") ;
729 if (!wxStrlen(fa
.szFacename
) )
731 SetFaceName(sFacename
);
733 } // end of wxNativeFontInfo::SetFamily
735 void wxNativeFontInfo::SetEncoding(
736 wxFontEncoding eEncoding
739 wxNativeEncodingInfo vInfo
;
741 if ( !wxGetNativeFontEncoding( eEncoding
745 if (wxFontMapper::Get()->GetAltForEncoding( eEncoding
749 if (!vInfo
.facename
.empty())
752 // If we have this encoding only in some particular facename, use
753 // the facename - it is better to show the correct characters in a
754 // wrong facename than unreadable text in a correct one
756 SetFaceName(vInfo
.facename
);
761 // unsupported encoding, replace with the default
765 fa
.usCodePage
= vInfo
.charset
;
766 } // end of wxNativeFontInfo::SetFaceName
768 bool wxNativeFontInfo::FromString(
769 const wxString
& rsStr
774 wxStringTokenizer
vTokenizer(rsStr
, _T(";"));
779 wxString sToken
= vTokenizer
.GetNextToken();
781 if (sToken
!= _T('0'))
784 sToken
= vTokenizer
.GetNextToken();
785 if (!sToken
.ToLong(&lVal
))
789 sToken
= vTokenizer
.GetNextToken();
790 if (!sToken
.ToLong(&lVal
))
792 fa
.lAveCharWidth
= lVal
;
794 sToken
= vTokenizer
.GetNextToken();
795 if (!sToken
.ToLong(&lVal
))
797 fa
.fsSelection
= (USHORT
)lVal
;
799 sToken
= vTokenizer
.GetNextToken();
800 if (!sToken
.ToLong(&lVal
))
802 fa
.fsType
= (USHORT
)lVal
;
804 sToken
= vTokenizer
.GetNextToken();
805 if (!sToken
.ToLong(&lVal
))
807 fa
.fsFontUse
= (USHORT
)lVal
;
809 sToken
= vTokenizer
.GetNextToken();
810 if (!sToken
.ToLong(&lVal
))
812 fa
.idRegistry
= (USHORT
)lVal
;
814 sToken
= vTokenizer
.GetNextToken();
815 if (!sToken
.ToLong(&lVal
))
817 fa
.usCodePage
= (USHORT
)lVal
;
819 sToken
= vTokenizer
.GetNextToken();
820 if (!sToken
.ToLong(&lVal
))
824 sToken
= vTokenizer
.GetNextToken();
825 if (!sToken
.ToLong(&lVal
))
827 fn
.usWeightClass
= (USHORT
)lVal
;
829 sToken
= vTokenizer
.GetNextToken();
832 wxStrcpy(fa
.szFacename
, sToken
.c_str());
834 } // end of wxNativeFontInfo::FromString
836 wxString
wxNativeFontInfo::ToString() const
840 sStr
.Printf(_T("%d;%ld;%ld;%ld;%d;%d;%d;%d;%d;%ld;%d;%s"),
841 0, // version, in case we want to change the format later
854 } // end of wxNativeFontInfo::ToString
856 // ----------------------------------------------------------------------------
858 // ----------------------------------------------------------------------------
862 } // end of wxFont::Init
865 const wxNativeFontInfo
& rInfo
870 m_refData
= new wxFontRefData( rInfo
875 } // end of wxFont::Create
878 const wxString
& rsFontdesc
881 wxNativeFontInfo vInfo
;
883 if (vInfo
.FromString(rsFontdesc
))
885 } // end of wxFont::wxFont
887 // ----------------------------------------------------------------------------
888 // Constructor for a font. Note that the real construction is done
889 // in wxDC::SetFont, when information is available about scaling etc.
890 // ----------------------------------------------------------------------------
897 , const wxString
& rsFaceName
898 , 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(
947 if (GetResourceHandle())
953 } // end of wxFont::FreeResource
955 WXHANDLE
wxFont::GetResourceHandle()
958 } // end of wxFont::GetResourceHandle
960 WXHFONT
wxFont::GetHFONT() const
962 return M_FONTDATA
? M_FONTDATA
->GetHFONT() : 0;
963 } // end of wxFont::GetHFONT
965 bool wxFont::IsFree() const
967 return M_FONTDATA
&& (M_FONTDATA
->GetHFONT() == 0);
968 } // end of wxFont::IsFree
970 void wxFont::Unshare()
972 // Don't change shared data
975 m_refData
= new wxFontRefData();
979 wxFontRefData
* ref
= new wxFontRefData(*M_FONTDATA
);
983 } // end of wxFont::Unshare
985 // ----------------------------------------------------------------------------
986 // change font attribute: we recreate font when doing it
987 // ----------------------------------------------------------------------------
989 void wxFont::SetPointSize(
995 M_FONTDATA
->SetPointSize(nPointSize
);
998 } // end of wxFont::SetPointSize
1000 void wxFont::SetFamily(
1006 M_FONTDATA
->SetFamily(nFamily
);
1009 } // end of wxFont::SetFamily
1011 void wxFont::SetStyle(
1017 M_FONTDATA
->SetStyle(nStyle
);
1020 } // end of wxFont::SetStyle
1022 void wxFont::SetWeight(
1028 M_FONTDATA
->SetWeight(nWeight
);
1031 } // end of wxFont::SetWeight
1033 void wxFont::SetFaceName(
1034 const wxString
& rsFaceName
1039 M_FONTDATA
->SetFaceName(rsFaceName
);
1042 } // end of wxFont::SetFaceName
1044 void wxFont::SetUnderlined(
1050 M_FONTDATA
->SetUnderlined(bUnderlined
);
1053 } // end of wxFont::SetUnderlined
1055 void wxFont::SetEncoding(
1056 wxFontEncoding vEncoding
1061 M_FONTDATA
->SetEncoding(vEncoding
);
1064 } // end of wxFont::SetEncoding
1066 void wxFont::SetNativeFontInfo(
1067 const wxNativeFontInfo
& rInfo
1074 *M_FONTDATA
= wxFontRefData(rInfo
);
1079 // ----------------------------------------------------------------------------
1081 // ----------------------------------------------------------------------------
1083 int wxFont::GetPointSize() const
1085 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
1087 return M_FONTDATA
->GetPointSize();
1088 } // end of wxFont::GetPointSize
1090 int wxFont::GetFamily() const
1092 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
1094 return M_FONTDATA
->GetFamily();
1095 } // end of wxFont::GetFamily
1097 int wxFont::GetStyle() const
1099 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
1101 return M_FONTDATA
->GetStyle();
1102 } // end of wxFont::GetStyle
1104 int wxFont::GetWeight() const
1106 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
1108 return M_FONTDATA
->GetWeight();
1111 bool wxFont::GetUnderlined() const
1113 wxCHECK_MSG( Ok(), FALSE
, wxT("invalid font") );
1115 return M_FONTDATA
->GetUnderlined();
1116 } // end of wxFont::GetUnderlined
1118 wxString
wxFont::GetFaceName() const
1120 wxCHECK_MSG( Ok(), wxT(""), wxT("invalid font") );
1122 return M_FONTDATA
->GetFaceName();
1123 } // end of wxFont::GetFaceName
1125 wxFontEncoding
wxFont::GetEncoding() const
1127 wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT
, wxT("invalid font") );
1129 return M_FONTDATA
->GetEncoding();
1130 } // end of wxFont::GetEncoding
1132 wxNativeFontInfo
* wxFont::GetNativeFontInfo() const
1134 if (M_FONTDATA
->HasNativeFontInfo())
1135 return new wxNativeFontInfo(M_FONTDATA
->GetNativeFontInfo());
1137 } // end of wxFont::GetNativeFontInfo
1140 // Internal use only method to set the FONTMETRICS array
1147 M_FONTDATA
->SetFM(pFM
);
1148 M_FONTDATA
->SetNumFonts(nNumFonts
);
1149 } // end of wxFont::SetFM
1158 M_FONTDATA
->SetPS(hPS
);
1161 } // end of wxFont::SetPS