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 (hPS
== NULLHANDLE
)
353 m_hPS
= ::WinGetPS(HWND_DESKTOP
);
354 m_bInternalPS
= TRUE
;
360 m_bTemporary
= FALSE
;
361 m_pFM
= (PFONTMETRICS
)NULL
;
363 } // end of wxFontRefData::Init
365 wxFontRefData::~wxFontRefData()
370 bool wxFontRefData::Alloc(
378 PFONTMETRICS pFM
= NULL
;
382 if (!m_bNativeFontInfoOk
)
384 wxFillLogFont( &m_vNativeFontInfo
.fa
385 ,&m_vNativeFontInfo
.fn
392 m_bNativeFontInfoOk
= TRUE
;
403 if((lRc
= ::GpiCreateLogFont( m_hPS
406 ,&m_vNativeFontInfo
.fa
409 m_hFont
= (WXHFONT
)flId
;
414 vError
= ::WinGetLastError(vHabmain
);
415 sError
= wxPMErrorToStr(vError
);
416 wxLogLastError("CreateFont");
419 ::GpiSetCharSet(m_hPS
, flId
); // sets font for presentation space
420 ::GpiQueryFontMetrics(m_hPS
, sizeof(FONTMETRICS
), &m_vNativeFontInfo
.fm
);
423 // Set refData members with the results
425 memcpy(&m_vFattrs
, &m_vNativeFontInfo
.fa
, sizeof(m_vFattrs
));
426 memcpy(&m_vFname
, &m_vNativeFontInfo
.fn
, sizeof(m_vFname
));
428 // Going to leave the point size alone. Mostly we use outline fonts
429 // that can be set to any point size inside of Presentation Parameters,
430 // regardless of whether or not the actual font is registered in the system.
431 // The GpiCreateLogFont will do enough by selecting the right family,
434 if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Times New Roman") == 0)
436 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Times New Roman MT 30") == 0)
438 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "@Times New Roman MT 30") == 0)
440 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Tms Rmn") == 0)
442 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "WarpSans") == 0)
443 m_nFamily
= wxDECORATIVE
;
444 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Helvitica") == 0)
446 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Helv") == 0)
448 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Script") == 0)
449 m_nFamily
= wxSCRIPT
;
450 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Courier New") == 0)
451 m_nFamily
= wxTELETYPE
;
452 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Courier") == 0)
453 m_nFamily
= wxTELETYPE
;
454 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "System Monospaced") == 0)
455 m_nFamily
= wxTELETYPE
;
456 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "System VIO") == 0)
457 m_nFamily
= wxDEFAULT
;
458 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "System Proportional") == 0)
459 m_nFamily
= wxMODERN
;
460 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Arial") == 0)
465 if (m_vNativeFontInfo
.fa
.fsSelection
& FATTR_SEL_ITALIC
)
466 m_nStyle
= wxFONTSTYLE_ITALIC
;
468 m_nStyle
= wxFONTSTYLE_NORMAL
;
469 switch(m_vNativeFontInfo
.fn
.usWeightClass
)
471 case FWEIGHT_DONT_CARE
:
472 m_nWeight
= wxFONTWEIGHT_NORMAL
;
476 m_nWeight
= wxFONTWEIGHT_NORMAL
;
480 m_nWeight
= wxFONTWEIGHT_LIGHT
;
484 m_nWeight
= wxFONTWEIGHT_BOLD
;
487 case FWEIGHT_ULTRA_BOLD
:
488 m_nWeight
= wxFONTWEIGHT_MAX
;
492 m_nWeight
= wxFONTWEIGHT_NORMAL
;
494 m_bUnderlined
= ((m_vNativeFontInfo
.fa
.fsSelection
& FATTR_SEL_UNDERSCORE
) != 0);
495 m_sFaceName
= m_vNativeFontInfo
.fa
.szFacename
;
496 m_vEncoding
= wxGetFontEncFromCharSet(m_vNativeFontInfo
.fa
.usCodePage
);
499 // We don't actuall keep the font around if using a temporary PS
504 ::GpiDeleteSetId( m_hPS
508 ::WinReleasePS(m_hPS
);
512 // Select the font into the Presentation space
514 ::GpiSetCharSet(m_hPS
, flId
); // sets font for presentation space
516 } // end of wxFontRefData::Alloc
518 void wxFontRefData::Free()
522 m_pFM
= (PFONTMETRICS
)NULL
;
526 ::GpiDeleteSetId(m_hPS
, 1L); /* delete the logical font */
531 ::WinReleasePS(m_hPS
);
533 } // end of wxFontRefData::Free
535 // ----------------------------------------------------------------------------
537 // ----------------------------------------------------------------------------
539 void wxNativeFontInfo::Init()
541 memset(&fa
, '\0', sizeof(FATTRS
));
542 } // end of wxNativeFontInfo::Init
544 int wxNativeFontInfo::GetPointSize() const
547 } // end of wxNativeFontInfo::GetPointSize
549 wxFontStyle
wxNativeFontInfo::GetStyle() const
551 return fa
.fsSelection
& FATTR_SEL_ITALIC
? wxFONTSTYLE_ITALIC
: wxFONTSTYLE_NORMAL
;
552 } // end of wxNativeFontInfo::GetStyle
554 wxFontWeight
wxNativeFontInfo::GetWeight() const
556 switch(fn
.usWeightClass
)
558 case FWEIGHT_DONT_CARE
:
559 return wxFONTWEIGHT_NORMAL
;
562 return wxFONTWEIGHT_NORMAL
;
565 return wxFONTWEIGHT_LIGHT
;
568 return wxFONTWEIGHT_BOLD
;
570 case FWEIGHT_ULTRA_BOLD
:
571 return wxFONTWEIGHT_MAX
;
573 return wxFONTWEIGHT_NORMAL
;
574 } // end of wxNativeFontInfo::GetWeight
576 bool wxNativeFontInfo::GetUnderlined() const
578 return ((fa
.fsSelection
& FATTR_SEL_UNDERSCORE
) != 0);
579 } // end of wxNativeFontInfo::GetUnderlined
581 wxString
wxNativeFontInfo::GetFaceName() const
583 return fm
.szFacename
;
584 } // end of wxNativeFontInfo::GetFaceName
586 wxFontFamily
wxNativeFontInfo::GetFamily() const
591 // Extract family from facename
593 if (strcmp(fm
.szFamilyname
, "Times New Roman") == 0)
595 else if (strcmp(fm
.szFamilyname
, "Times New Roman MT 30") == 0)
597 else if (strcmp(fm
.szFamilyname
, "@Times New Roman MT 30") == 0)
599 else if (strcmp(fm
.szFamilyname
, "Tms Rmn") == 0)
601 else if (strcmp(fm
.szFamilyname
, "WarpSans") == 0)
602 nFamily
= wxDECORATIVE
;
603 else if (strcmp(fm
.szFamilyname
, "Helvitica") == 0)
605 else if (strcmp(fm
.szFamilyname
, "Helv") == 0)
607 else if (strcmp(fm
.szFamilyname
, "Script") == 0)
609 else if (strcmp(fm
.szFamilyname
, "Courier New") == 0)
610 nFamily
= wxTELETYPE
;
611 else if (strcmp(fm
.szFamilyname
, "Courier") == 0)
612 nFamily
= wxTELETYPE
;
613 else if (strcmp(fm
.szFamilyname
, "System Monospaced") == 0)
614 nFamily
= wxTELETYPE
;
615 else if (strcmp(fm
.szFamilyname
, "System VIO") == 0)
617 else if (strcmp(fm
.szFamilyname
, "System Proportional") == 0)
619 else if (strcmp(fm
.szFamilyname
, "Arial") == 0)
623 return (wxFontFamily
)nFamily
;
624 } // end of wxNativeFontInfo::GetFamily
626 wxFontEncoding
wxNativeFontInfo::GetEncoding() const
628 return wxGetFontEncFromCharSet(fa
.usCodePage
);
629 } // end of wxNativeFontInfo::GetEncoding
631 void wxNativeFontInfo::SetPointSize(
635 fm
.lEmHeight
= (LONG
)nPointsize
;
636 } // end of wxNativeFontInfo::SetPointSize
638 void wxNativeFontInfo::SetStyle(
645 wxFAIL_MSG( _T("unknown font style") );
648 case wxFONTSTYLE_NORMAL
:
651 case wxFONTSTYLE_ITALIC
:
652 case wxFONTSTYLE_SLANT
:
653 fa
.fsSelection
|= FATTR_SEL_ITALIC
;
656 } // end of wxNativeFontInfo::SetStyle
658 void wxNativeFontInfo::SetWeight(
665 wxFAIL_MSG( _T("unknown font weight") );
668 case wxFONTWEIGHT_NORMAL
:
669 fn
.usWeightClass
= FWEIGHT_NORMAL
;
672 case wxFONTWEIGHT_LIGHT
:
673 fn
.usWeightClass
= FWEIGHT_LIGHT
;
676 case wxFONTWEIGHT_BOLD
:
677 fn
.usWeightClass
= FWEIGHT_BOLD
;
680 } // end of wxNativeFontInfo::SetWeight
682 void wxNativeFontInfo::SetUnderlined(
687 fa
.fsSelection
|= FATTR_SEL_UNDERSCORE
;
688 } // end of wxNativeFontInfo::SetUnderlined
690 void wxNativeFontInfo::SetFaceName(
694 wxStrncpy(fa
.szFacename
, sFacename
, WXSIZEOF(fa
.szFacename
));
695 } // end of wxNativeFontInfo::SetFaceName
697 void wxNativeFontInfo::SetFamily(
706 sFacename
= wxT("Script");
710 sFacename
= wxT("WarpSans");
714 sFacename
= wxT("Times New Roman");
718 sFacename
= wxT("Courier New") ;
722 sFacename
= wxT("Courier New") ;
726 sFacename
= wxT("Helv") ;
731 sFacename
= wxT("System VIO") ;
734 if (!wxStrlen(fa
.szFacename
) )
736 SetFaceName(sFacename
);
738 } // end of wxNativeFontInfo::SetFamily
740 void wxNativeFontInfo::SetEncoding(
741 wxFontEncoding eEncoding
744 wxNativeEncodingInfo vInfo
;
746 if ( !wxGetNativeFontEncoding( eEncoding
750 if (wxFontMapper::Get()->GetAltForEncoding( eEncoding
754 if (!vInfo
.facename
.empty())
757 // If we have this encoding only in some particular facename, use
758 // the facename - it is better to show the correct characters in a
759 // wrong facename than unreadable text in a correct one
761 SetFaceName(vInfo
.facename
);
766 // unsupported encoding, replace with the default
770 fa
.usCodePage
= vInfo
.charset
;
771 } // end of wxNativeFontInfo::SetFaceName
773 bool wxNativeFontInfo::FromString(
774 const wxString
& rsStr
779 wxStringTokenizer
vTokenizer(rsStr
, _T(";"));
784 wxString sToken
= vTokenizer
.GetNextToken();
786 if (sToken
!= _T('0'))
789 sToken
= vTokenizer
.GetNextToken();
790 if (!sToken
.ToLong(&lVal
))
794 sToken
= vTokenizer
.GetNextToken();
795 if (!sToken
.ToLong(&lVal
))
797 fa
.lAveCharWidth
= lVal
;
799 sToken
= vTokenizer
.GetNextToken();
800 if (!sToken
.ToLong(&lVal
))
802 fa
.fsSelection
= (USHORT
)lVal
;
804 sToken
= vTokenizer
.GetNextToken();
805 if (!sToken
.ToLong(&lVal
))
807 fa
.fsType
= (USHORT
)lVal
;
809 sToken
= vTokenizer
.GetNextToken();
810 if (!sToken
.ToLong(&lVal
))
812 fa
.fsFontUse
= (USHORT
)lVal
;
814 sToken
= vTokenizer
.GetNextToken();
815 if (!sToken
.ToLong(&lVal
))
817 fa
.idRegistry
= (USHORT
)lVal
;
819 sToken
= vTokenizer
.GetNextToken();
820 if (!sToken
.ToLong(&lVal
))
822 fa
.usCodePage
= (USHORT
)lVal
;
824 sToken
= vTokenizer
.GetNextToken();
825 if (!sToken
.ToLong(&lVal
))
829 sToken
= vTokenizer
.GetNextToken();
830 if (!sToken
.ToLong(&lVal
))
832 fn
.usWeightClass
= (USHORT
)lVal
;
834 sToken
= vTokenizer
.GetNextToken();
837 wxStrcpy(fa
.szFacename
, sToken
.c_str());
839 } // end of wxNativeFontInfo::FromString
841 wxString
wxNativeFontInfo::ToString() const
845 sStr
.Printf(_T("%d;%ld;%ld;%ld;%d;%d;%d;%d;%d;%ld;%d;%s"),
846 0, // version, in case we want to change the format later
859 } // end of wxNativeFontInfo::ToString
861 // ----------------------------------------------------------------------------
863 // ----------------------------------------------------------------------------
867 } // end of wxFont::Init
870 const wxNativeFontInfo
& rInfo
875 m_refData
= new wxFontRefData( rInfo
880 } // end of wxFont::Create
883 const wxString
& rsFontdesc
886 wxNativeFontInfo vInfo
;
888 if (vInfo
.FromString(rsFontdesc
))
890 } // end of wxFont::wxFont
892 // ----------------------------------------------------------------------------
893 // Constructor for a font. Note that the real construction is done
894 // in wxDC::SetFont, when information is available about scaling etc.
895 // ----------------------------------------------------------------------------
902 , const wxString
& rsFaceName
903 , wxFontEncoding vEncoding
909 // wxDEFAULT is a valid value for the font size too so we must treat it
910 // specially here (otherwise the size would be 70 == wxDEFAULT value)
912 if (nPointSize
== wxDEFAULT
)
914 nPointSize
= wxNORMAL_FONT
->GetPointSize();
916 m_refData
= new wxFontRefData( nPointSize
926 } // end of wxFont::Create
930 } // end of wxFont::~wxFont
932 // ----------------------------------------------------------------------------
933 // real implementation
934 // Boris' Kovalenko comments:
935 // Because OS/2 fonts are associated with PS we can not create the font
936 // here, but we may check that font definition is true
937 // ----------------------------------------------------------------------------
939 bool wxFont::RealizeResource()
941 if ( GetResourceHandle() )
945 return M_FONTDATA
->Alloc(this);
946 } // end of wxFont::RealizeResource
948 bool wxFont::FreeResource(
952 if (GetResourceHandle())
958 } // end of wxFont::FreeResource
960 WXHANDLE
wxFont::GetResourceHandle()
963 } // end of wxFont::GetResourceHandle
965 WXHFONT
wxFont::GetHFONT() const
967 return M_FONTDATA
? M_FONTDATA
->GetHFONT() : 0;
968 } // end of wxFont::GetHFONT
970 bool wxFont::IsFree() const
972 return M_FONTDATA
&& (M_FONTDATA
->GetHFONT() == 0);
973 } // end of wxFont::IsFree
975 void wxFont::Unshare()
977 // Don't change shared data
980 m_refData
= new wxFontRefData();
984 wxFontRefData
* ref
= new wxFontRefData(*M_FONTDATA
);
988 } // end of wxFont::Unshare
990 // ----------------------------------------------------------------------------
991 // change font attribute: we recreate font when doing it
992 // ----------------------------------------------------------------------------
994 void wxFont::SetPointSize(
1000 M_FONTDATA
->SetPointSize(nPointSize
);
1003 } // end of wxFont::SetPointSize
1005 void wxFont::SetFamily(
1011 M_FONTDATA
->SetFamily(nFamily
);
1014 } // end of wxFont::SetFamily
1016 void wxFont::SetStyle(
1022 M_FONTDATA
->SetStyle(nStyle
);
1025 } // end of wxFont::SetStyle
1027 void wxFont::SetWeight(
1033 M_FONTDATA
->SetWeight(nWeight
);
1036 } // end of wxFont::SetWeight
1038 void wxFont::SetFaceName(
1039 const wxString
& rsFaceName
1044 M_FONTDATA
->SetFaceName(rsFaceName
);
1047 } // end of wxFont::SetFaceName
1049 void wxFont::SetUnderlined(
1055 M_FONTDATA
->SetUnderlined(bUnderlined
);
1058 } // end of wxFont::SetUnderlined
1060 void wxFont::SetEncoding(
1061 wxFontEncoding vEncoding
1066 M_FONTDATA
->SetEncoding(vEncoding
);
1069 } // end of wxFont::SetEncoding
1071 void wxFont::SetNativeFontInfo(
1072 const wxNativeFontInfo
& rInfo
1079 *M_FONTDATA
= wxFontRefData(rInfo
);
1084 // ----------------------------------------------------------------------------
1086 // ----------------------------------------------------------------------------
1088 int wxFont::GetPointSize() const
1090 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
1092 return M_FONTDATA
->GetPointSize();
1093 } // end of wxFont::GetPointSize
1095 int wxFont::GetFamily() const
1097 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
1099 return M_FONTDATA
->GetFamily();
1100 } // end of wxFont::GetFamily
1102 int wxFont::GetStyle() const
1104 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
1106 return M_FONTDATA
->GetStyle();
1107 } // end of wxFont::GetStyle
1109 int wxFont::GetWeight() const
1111 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
1113 return M_FONTDATA
->GetWeight();
1116 bool wxFont::GetUnderlined() const
1118 wxCHECK_MSG( Ok(), FALSE
, wxT("invalid font") );
1120 return M_FONTDATA
->GetUnderlined();
1121 } // end of wxFont::GetUnderlined
1123 wxString
wxFont::GetFaceName() const
1125 wxCHECK_MSG( Ok(), wxT(""), wxT("invalid font") );
1127 return M_FONTDATA
->GetFaceName();
1128 } // end of wxFont::GetFaceName
1130 wxFontEncoding
wxFont::GetEncoding() const
1132 wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT
, wxT("invalid font") );
1134 return M_FONTDATA
->GetEncoding();
1135 } // end of wxFont::GetEncoding
1137 wxNativeFontInfo
* wxFont::GetNativeFontInfo() const
1139 if (M_FONTDATA
->HasNativeFontInfo())
1140 return new wxNativeFontInfo(M_FONTDATA
->GetNativeFontInfo());
1142 } // end of wxFont::GetNativeFontInfo
1145 // Internal use only method to set the FONTMETRICS array
1152 M_FONTDATA
->SetFM(pFM
);
1153 M_FONTDATA
->SetNumFonts(nNumFonts
);
1154 } // end of wxFont::SetFM
1163 M_FONTDATA
->SetPS(hPS
);
1166 } // end of wxFont::SetPS