1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/os2/font.cpp
3 // Purpose: wxFont class
4 // Author: David Webster
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
15 // ============================================================================
17 // ============================================================================
19 // ----------------------------------------------------------------------------
21 // ----------------------------------------------------------------------------
33 #include "wx/os2/private.h"
35 #include "wx/fontutil.h"
36 #include "wx/fontmap.h"
37 #include "wx/encinfo.h"
39 #include "wx/tokenzr.h"
43 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
)
45 // ----------------------------------------------------------------------------
46 // wxFontRefData - the internal description of the font
47 // ----------------------------------------------------------------------------
49 class WXDLLEXPORT wxFontRefData
: public wxGDIRefData
54 Init(-1, wxFONTFAMILY_DEFAULT
, wxFONTSTYLE_NORMAL
, wxFONTWEIGHT_NORMAL
, FALSE
,
55 wxEmptyString
, wxFONTENCODING_DEFAULT
);
58 wxFontRefData( int nSize
63 ,const wxString
& sFaceName
64 ,wxFontEncoding vEncoding
77 wxFontRefData( const wxNativeFontInfo
& rInfo
88 wxFontRefData(const wxFontRefData
& rData
)
90 Init( rData
.m_nPointSize
98 m_nFontId
= rData
.m_nFontId
;
101 virtual ~wxFontRefData();
106 bool Alloc(wxFont
* pFont
);
110 // All wxFont accessors
112 inline int GetPointSize(void) const
115 // We don't use the actual native font point size since it is
116 // the chosen physical font, which is usually only and approximation
117 // of the desired outline font. The actual displayable point size
118 // is the one stored in the refData
123 inline int GetFamily(void) const
128 inline int GetStyle(void) const
130 return m_bNativeFontInfoOk
? m_vNativeFontInfo
.GetStyle()
134 inline int GetWeight(void) const
136 return m_bNativeFontInfoOk
? m_vNativeFontInfo
.GetWeight()
140 inline bool GetUnderlined(void) const
142 return m_bNativeFontInfoOk
? m_vNativeFontInfo
.GetUnderlined()
146 inline wxString
GetFaceName(void) const
150 if (m_bNativeFontInfoOk
)
151 sFaceName
= m_vNativeFontInfo
.GetFaceName();
153 sFaceName
= m_sFaceName
;
158 inline wxFontEncoding
GetEncoding(void) const
160 return m_bNativeFontInfoOk
? m_vNativeFontInfo
.GetEncoding()
164 inline WXHFONT
GetHFONT(void) const { return m_hFont
; }
165 inline HPS
GetPS(void) const { return m_hPS
; }
166 inline PFONTMETRICS
GetFM(void) const { return m_pFM
; }
167 inline int GetNumFonts(void) const { return m_nNumFonts
; }
170 inline void SetPointSize(int nPointSize
)
172 if (m_bNativeFontInfoOk
)
173 m_vNativeFontInfo
.SetPointSize(nPointSize
);
175 m_nPointSize
= nPointSize
;
178 inline void SetFamily(int nFamily
)
183 inline void SetStyle(int nStyle
)
185 if (m_bNativeFontInfoOk
)
186 m_vNativeFontInfo
.SetStyle((wxFontStyle
)nStyle
);
191 inline void SetWeight(int nWeight
)
193 if (m_bNativeFontInfoOk
)
194 m_vNativeFontInfo
.SetWeight((wxFontWeight
)nWeight
);
199 inline bool SetFaceName(const wxString
& sFaceName
)
201 if (m_bNativeFontInfoOk
)
202 return m_vNativeFontInfo
.SetFaceName(sFaceName
);
204 m_sFaceName
= sFaceName
;
208 inline void SetUnderlined(bool bUnderlined
)
210 if (m_bNativeFontInfoOk
)
211 m_vNativeFontInfo
.SetUnderlined(bUnderlined
);
213 m_bUnderlined
= bUnderlined
;
216 inline void SetEncoding(wxFontEncoding vEncoding
)
218 if (m_bNativeFontInfoOk
)
219 m_vNativeFontInfo
.SetEncoding(vEncoding
);
221 m_vEncoding
= vEncoding
;
224 inline void SetPS(HPS hPS
)
229 inline void SetFM(PFONTMETRICS pFM
)
234 inline void SetNumFonts(int nNumFonts
)
236 m_nNumFonts
= nNumFonts
;
240 // Native font info tests
242 bool HasNativeFontInfo() const { return m_bNativeFontInfoOk
; }
244 const wxNativeFontInfo
& GetNativeFontInfo() const
245 { return m_vNativeFontInfo
; }
249 // Common part of all ctors
256 ,const wxString
& rsFaceName
257 ,wxFontEncoding vEncoding
260 void Init( const wxNativeFontInfo
& rInfo
265 // If true, the pointer to the actual font is temporary and SHOULD NOT BE
266 // DELETED by destructor
272 // Font characterstics
279 wxString m_sFaceName
;
280 wxFontEncoding m_vEncoding
;
286 wxNativeFontInfo m_vNativeFontInfo
;
287 bool m_bNativeFontInfoOk
;
290 // Some PM specific stuff
292 PFONTMETRICS m_pFM
; // array of FONTMETRICS structs
293 int m_nNumFonts
; // number of fonts in array
294 HPS m_hPS
; // PS handle this font belongs to
295 FATTRS m_vFattrs
; // Current fattrs struct
296 FACENAMEDESC m_vFname
; // Current facename struct
297 bool m_bInternalPS
; // Internally generated PS?
298 }; // end of CLASS wxFontRefData
300 // ============================================================================
302 // ============================================================================
304 // ----------------------------------------------------------------------------
306 // ----------------------------------------------------------------------------
308 void wxFontRefData::Init(
314 , const wxString
& rsFaceName
315 , wxFontEncoding vEncoding
319 m_nPointSize
= nPointSize
;
323 m_bUnderlined
= bUnderlined
;
324 m_sFaceName
= rsFaceName
;
325 m_vEncoding
= vEncoding
;
328 m_bNativeFontInfoOk
= false;
331 m_bTemporary
= false;
332 m_pFM
= (PFONTMETRICS
)NULL
;
335 } // end of wxFontRefData::Init
337 void wxFontRefData::Init(
338 const wxNativeFontInfo
& rInfo
339 , WXHFONT hFont
//this is the FontId -- functions as the hFont for OS/2
340 , WXHANDLE hPS
// Presentation Space we are using
344 // hFont may be zero, or it be passed in case we really want to
345 // use the exact font created in the underlying system
346 // (for example where we can't guarantee conversion from HFONT
347 // to LOGFONT back to HFONT)
350 m_nFontId
= (int)hFont
;
352 m_bNativeFontInfoOk
= true;
353 m_vNativeFontInfo
= rInfo
;
355 if (hPS
== NULLHANDLE
)
357 m_hPS
= ::WinGetPS(HWND_DESKTOP
);
358 m_bInternalPS
= true;
364 m_bTemporary
= false;
365 m_pFM
= (PFONTMETRICS
)NULL
;
367 } // end of wxFontRefData::Init
369 wxFontRefData::~wxFontRefData()
374 bool wxFontRefData::Alloc( wxFont
* pFont
)
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(wxT("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
, "Helvetica") == 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
= wxMODERN
;
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)
462 else if (strcmp(m_vNativeFontInfo
.fm
.szFamilyname
, "Swiss") == 0)
467 if (m_vNativeFontInfo
.fa
.fsSelection
& FATTR_SEL_ITALIC
)
468 m_nStyle
= wxFONTSTYLE_ITALIC
;
470 m_nStyle
= wxFONTSTYLE_NORMAL
;
471 switch(m_vNativeFontInfo
.fn
.usWeightClass
)
473 case FWEIGHT_DONT_CARE
:
474 m_nWeight
= wxFONTWEIGHT_NORMAL
;
478 m_nWeight
= wxFONTWEIGHT_NORMAL
;
482 m_nWeight
= wxFONTWEIGHT_LIGHT
;
486 m_nWeight
= wxFONTWEIGHT_BOLD
;
489 case FWEIGHT_ULTRA_BOLD
:
490 m_nWeight
= wxFONTWEIGHT_MAX
;
494 m_nWeight
= wxFONTWEIGHT_NORMAL
;
496 m_bUnderlined
= ((m_vNativeFontInfo
.fa
.fsSelection
& FATTR_SEL_UNDERSCORE
) != 0);
497 m_sFaceName
= (wxChar
*)m_vNativeFontInfo
.fa
.szFacename
;
498 m_vEncoding
= wxGetFontEncFromCharSet(m_vNativeFontInfo
.fa
.usCodePage
);
501 // We don't actuall keep the font around if using a temporary PS
506 ::GpiDeleteSetId( m_hPS
510 ::WinReleasePS(m_hPS
);
514 // Select the font into the Presentation space
516 ::GpiSetCharSet(m_hPS
, flId
); // sets font for presentation space
518 } // end of wxFontRefData::Alloc
520 void wxFontRefData::Free()
524 m_pFM
= (PFONTMETRICS
)NULL
;
528 ::GpiDeleteSetId(m_hPS
, 1L); /* delete the logical font */
533 ::WinReleasePS(m_hPS
);
535 } // end of wxFontRefData::Free
537 // ----------------------------------------------------------------------------
539 // ----------------------------------------------------------------------------
541 void wxNativeFontInfo::Init()
543 memset(&fa
, '\0', sizeof(FATTRS
));
544 } // end of wxNativeFontInfo::Init
546 int wxNativeFontInfo::GetPointSize() const
549 } // end of wxNativeFontInfo::GetPointSize
551 wxFontStyle
wxNativeFontInfo::GetStyle() const
553 return fa
.fsSelection
& FATTR_SEL_ITALIC
? wxFONTSTYLE_ITALIC
: wxFONTSTYLE_NORMAL
;
554 } // end of wxNativeFontInfo::GetStyle
556 wxFontWeight
wxNativeFontInfo::GetWeight() const
558 switch(fn
.usWeightClass
)
560 case FWEIGHT_DONT_CARE
:
561 return wxFONTWEIGHT_NORMAL
;
564 return wxFONTWEIGHT_NORMAL
;
567 return wxFONTWEIGHT_LIGHT
;
570 return wxFONTWEIGHT_BOLD
;
572 case FWEIGHT_ULTRA_BOLD
:
573 return wxFONTWEIGHT_MAX
;
575 return wxFONTWEIGHT_NORMAL
;
576 } // end of wxNativeFontInfo::GetWeight
578 bool wxNativeFontInfo::GetUnderlined() const
580 return ((fa
.fsSelection
& FATTR_SEL_UNDERSCORE
) != 0);
581 } // end of wxNativeFontInfo::GetUnderlined
583 wxString
wxNativeFontInfo::GetFaceName() const
585 return (wxChar
*)fm
.szFacename
;
586 } // end of wxNativeFontInfo::GetFaceName
588 wxFontFamily
wxNativeFontInfo::GetFamily() const
593 // Extract family from facename
595 if (strcmp(fm
.szFamilyname
, "Times New Roman") == 0)
597 else if (strcmp(fm
.szFamilyname
, "Times New Roman MT 30") == 0)
599 else if (strcmp(fm
.szFamilyname
, "@Times New Roman MT 30") == 0)
601 else if (strcmp(fm
.szFamilyname
, "Tms Rmn") == 0)
603 else if (strcmp(fm
.szFamilyname
, "WarpSans") == 0)
604 nFamily
= wxDECORATIVE
;
605 else if (strcmp(fm
.szFamilyname
, "Helvetica") == 0)
607 else if (strcmp(fm
.szFamilyname
, "Helv") == 0)
609 else if (strcmp(fm
.szFamilyname
, "Script") == 0)
611 else if (strcmp(fm
.szFamilyname
, "Courier New") == 0)
612 nFamily
= wxTELETYPE
;
613 else if (strcmp(fm
.szFamilyname
, "Courier") == 0)
614 nFamily
= wxTELETYPE
;
615 else if (strcmp(fm
.szFamilyname
, "System Monospaced") == 0)
616 nFamily
= wxTELETYPE
;
617 else if (strcmp(fm
.szFamilyname
, "System VIO") == 0)
619 else if (strcmp(fm
.szFamilyname
, "System Proportional") == 0)
621 else if (strcmp(fm
.szFamilyname
, "Arial") == 0)
623 else if (strcmp(fm
.szFamilyname
, "Swiss") == 0)
627 return (wxFontFamily
)nFamily
;
628 } // end of wxNativeFontInfo::GetFamily
630 wxFontEncoding
wxNativeFontInfo::GetEncoding() const
632 return wxGetFontEncFromCharSet(fa
.usCodePage
);
633 } // end of wxNativeFontInfo::GetEncoding
635 void wxNativeFontInfo::SetPointSize(
639 fm
.lEmHeight
= (LONG
)nPointsize
;
640 } // end of wxNativeFontInfo::SetPointSize
642 void wxNativeFontInfo::SetStyle(
649 wxFAIL_MSG( _T("unknown font style") );
652 case wxFONTSTYLE_NORMAL
:
655 case wxFONTSTYLE_ITALIC
:
656 case wxFONTSTYLE_SLANT
:
657 fa
.fsSelection
|= FATTR_SEL_ITALIC
;
660 } // end of wxNativeFontInfo::SetStyle
662 void wxNativeFontInfo::SetWeight(
669 wxFAIL_MSG( _T("unknown font weight") );
672 case wxFONTWEIGHT_NORMAL
:
673 fn
.usWeightClass
= FWEIGHT_NORMAL
;
676 case wxFONTWEIGHT_LIGHT
:
677 fn
.usWeightClass
= FWEIGHT_LIGHT
;
680 case wxFONTWEIGHT_BOLD
:
681 fn
.usWeightClass
= FWEIGHT_BOLD
;
684 } // end of wxNativeFontInfo::SetWeight
686 void wxNativeFontInfo::SetUnderlined(
691 fa
.fsSelection
|= FATTR_SEL_UNDERSCORE
;
692 } // end of wxNativeFontInfo::SetUnderlined
694 bool wxNativeFontInfo::SetFaceName(
695 const wxString
& sFacename
698 wxStrncpy((wxChar
*)fa
.szFacename
, sFacename
, WXSIZEOF(fa
.szFacename
));
700 } // end of wxNativeFontInfo::SetFaceName
702 void wxNativeFontInfo::SetFamily(
711 sFacename
= wxT("Tms Rmn");
715 sFacename
= wxT("WarpSans");
719 sFacename
= wxT("Tms Rmn");
723 sFacename
= wxT("Courier") ;
727 sFacename
= wxT("System VIO") ;
731 sFacename
= wxT("Helv") ;
736 sFacename
= wxT("System VIO") ;
739 if (!wxStrlen((wxChar
*)fa
.szFacename
) )
741 SetFaceName(sFacename
);
743 } // end of wxNativeFontInfo::SetFamily
745 void wxNativeFontInfo::SetEncoding( wxFontEncoding eEncoding
)
747 wxNativeEncodingInfo vInfo
;
749 if ( !wxGetNativeFontEncoding( eEncoding
753 if (wxFontMapper::Get()->GetAltForEncoding( eEncoding
757 if (!vInfo
.facename
.empty())
760 // If we have this encoding only in some particular facename, use
761 // the facename - it is better to show the correct characters in a
762 // wrong facename than unreadable text in a correct one
764 SetFaceName(vInfo
.facename
);
769 // unsupported encoding, replace with the default
773 fa
.usCodePage
= (USHORT
)vInfo
.charset
;
774 } // end of wxNativeFontInfo::SetFaceName
776 bool wxNativeFontInfo::FromString( const wxString
& rsStr
)
780 wxStringTokenizer
vTokenizer(rsStr
, _T(";"));
785 wxString sToken
= vTokenizer
.GetNextToken();
787 if (sToken
!= _T('0'))
790 sToken
= vTokenizer
.GetNextToken();
791 if (!sToken
.ToLong(&lVal
))
795 sToken
= vTokenizer
.GetNextToken();
796 if (!sToken
.ToLong(&lVal
))
798 fa
.lAveCharWidth
= lVal
;
800 sToken
= vTokenizer
.GetNextToken();
801 if (!sToken
.ToLong(&lVal
))
803 fa
.fsSelection
= (USHORT
)lVal
;
805 sToken
= vTokenizer
.GetNextToken();
806 if (!sToken
.ToLong(&lVal
))
808 fa
.fsType
= (USHORT
)lVal
;
810 sToken
= vTokenizer
.GetNextToken();
811 if (!sToken
.ToLong(&lVal
))
813 fa
.fsFontUse
= (USHORT
)lVal
;
815 sToken
= vTokenizer
.GetNextToken();
816 if (!sToken
.ToLong(&lVal
))
818 fa
.idRegistry
= (USHORT
)lVal
;
820 sToken
= vTokenizer
.GetNextToken();
821 if (!sToken
.ToLong(&lVal
))
823 fa
.usCodePage
= (USHORT
)lVal
;
825 sToken
= vTokenizer
.GetNextToken();
826 if (!sToken
.ToLong(&lVal
))
830 sToken
= vTokenizer
.GetNextToken();
831 if (!sToken
.ToLong(&lVal
))
833 fn
.usWeightClass
= (USHORT
)lVal
;
835 sToken
= vTokenizer
.GetNextToken();
838 wxStrcpy((wxChar
*)fa
.szFacename
, sToken
.c_str());
840 } // end of wxNativeFontInfo::FromString
842 wxString
wxNativeFontInfo::ToString() const
846 sStr
.Printf(_T("%d;%ld;%ld;%ld;%d;%d;%d;%d;%d;%ld;%d;%s"),
847 0, // version, in case we want to change the format later
860 } // end of wxNativeFontInfo::ToString
862 // ----------------------------------------------------------------------------
864 // ----------------------------------------------------------------------------
866 bool wxFont::Create( 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 // ----------------------------------------------------------------------------
891 bool wxFont::Create( int nPointSize
,
896 const wxString
& rsFaceName
,
897 wxFontEncoding vEncoding
)
902 // wxDEFAULT is a valid value for the font size too so we must treat it
903 // specially here (otherwise the size would be 70 == wxDEFAULT value)
905 if (nPointSize
== wxDEFAULT
)
907 nPointSize
= wxNORMAL_FONT
->GetPointSize();
909 m_refData
= new wxFontRefData( nPointSize
919 } // end of wxFont::Create
923 } // end of wxFont::~wxFont
925 // ----------------------------------------------------------------------------
926 // real implementation
927 // Boris' Kovalenko comments:
928 // Because OS/2 fonts are associated with PS we can not create the font
929 // here, but we may check that font definition is true
930 // ----------------------------------------------------------------------------
932 bool wxFont::RealizeResource()
934 if ( GetResourceHandle() )
938 return M_FONTDATA
->Alloc(this);
939 } // end of wxFont::RealizeResource
941 bool wxFont::FreeResource( bool WXUNUSED(bForce
) )
943 if (GetResourceHandle())
949 } // end of wxFont::FreeResource
951 WXHANDLE
wxFont::GetResourceHandle()
954 } // end of wxFont::GetResourceHandle
956 WXHFONT
wxFont::GetHFONT() const
958 return M_FONTDATA
? M_FONTDATA
->GetHFONT() : 0;
959 } // end of wxFont::GetHFONT
961 bool wxFont::IsFree() const
963 return M_FONTDATA
&& (M_FONTDATA
->GetHFONT() == 0);
964 } // end of wxFont::IsFree
966 void wxFont::Unshare()
968 // Don't change shared data
971 m_refData
= new wxFontRefData();
975 wxFontRefData
* ref
= new wxFontRefData(*M_FONTDATA
);
979 } // end of wxFont::Unshare
981 // ----------------------------------------------------------------------------
982 // change font attribute: we recreate font when doing it
983 // ----------------------------------------------------------------------------
985 void wxFont::SetPointSize(
991 M_FONTDATA
->SetPointSize(nPointSize
);
994 } // end of wxFont::SetPointSize
996 void wxFont::SetFamily(
1002 M_FONTDATA
->SetFamily(nFamily
);
1005 } // end of wxFont::SetFamily
1007 void wxFont::SetStyle(
1013 M_FONTDATA
->SetStyle(nStyle
);
1016 } // end of wxFont::SetStyle
1018 void wxFont::SetWeight(
1024 M_FONTDATA
->SetWeight(nWeight
);
1027 } // end of wxFont::SetWeight
1029 bool wxFont::SetFaceName(
1030 const wxString
& rsFaceName
1035 bool refdataok
= M_FONTDATA
->SetFaceName(rsFaceName
);
1039 return refdataok
&& wxFontBase::SetFaceName(rsFaceName
);
1040 } // end of wxFont::SetFaceName
1042 void wxFont::SetUnderlined(
1048 M_FONTDATA
->SetUnderlined(bUnderlined
);
1051 } // end of wxFont::SetUnderlined
1053 void wxFont::SetEncoding(
1054 wxFontEncoding vEncoding
1059 M_FONTDATA
->SetEncoding(vEncoding
);
1062 } // end of wxFont::SetEncoding
1064 void wxFont::DoSetNativeFontInfo(
1065 const wxNativeFontInfo
& rInfo
1072 *M_FONTDATA
= wxFontRefData(rInfo
);
1077 // ----------------------------------------------------------------------------
1079 // ----------------------------------------------------------------------------
1081 int wxFont::GetPointSize() const
1083 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
1085 return M_FONTDATA
->GetPointSize();
1086 } // end of wxFont::GetPointSize
1088 int wxFont::GetFamily() const
1090 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
1092 return M_FONTDATA
->GetFamily();
1093 } // end of wxFont::GetFamily
1095 int wxFont::GetStyle() const
1097 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
1099 return M_FONTDATA
->GetStyle();
1100 } // end of wxFont::GetStyle
1102 int wxFont::GetWeight() const
1104 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
1106 return M_FONTDATA
->GetWeight();
1109 bool wxFont::GetUnderlined() const
1111 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
1113 return M_FONTDATA
->GetUnderlined();
1114 } // end of wxFont::GetUnderlined
1116 wxString
wxFont::GetFaceName() const
1118 wxCHECK_MSG( Ok(), wxEmptyString
, wxT("invalid font") );
1120 return M_FONTDATA
->GetFaceName();
1121 } // end of wxFont::GetFaceName
1123 wxFontEncoding
wxFont::GetEncoding() const
1125 wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT
, wxT("invalid font") );
1127 return M_FONTDATA
->GetEncoding();
1128 } // end of wxFont::GetEncoding
1130 const wxNativeFontInfo
* wxFont::GetNativeFontInfo() const
1132 return M_FONTDATA
->HasNativeFontInfo() ? &(M_FONTDATA
->GetNativeFontInfo())
1134 } // end of wxFont::GetNativeFontInfo
1137 // Internal use only method to set the FONTMETRICS array
1139 void wxFont::SetFM( PFONTMETRICS pFM
, int nNumFonts
)
1141 M_FONTDATA
->SetFM(pFM
);
1142 M_FONTDATA
->SetNumFonts(nNumFonts
);
1143 } // end of wxFont::SetFM
1146 void wxFont::SetPS( HPS hPS
)
1150 M_FONTDATA
->SetPS(hPS
);
1153 } // end of wxFont::SetPS