1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/font.cpp
3 // Purpose: wxFont class
4 // Author: Julian Smart
8 // Copyright: (c) wxWidgets team
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
20 // For compilers that support precompilation, includes "wx.h".
21 #include "wx/wxprec.h"
34 #include "wx/encinfo.h"
37 #include "wx/msw/private.h"
39 #include "wx/fontutil.h"
40 #include "wx/fontmap.h"
42 #include "wx/tokenzr.h"
44 #if wxUSE_EXTENDED_RTTI
46 wxBEGIN_ENUM( wxFontFamily
)
47 wxENUM_MEMBER( wxDEFAULT
)
48 wxENUM_MEMBER( wxDECORATIVE
)
49 wxENUM_MEMBER( wxROMAN
)
50 wxENUM_MEMBER( wxSCRIPT
)
51 wxENUM_MEMBER( wxSWISS
)
52 wxENUM_MEMBER( wxMODERN
)
53 wxENUM_MEMBER( wxTELETYPE
)
54 wxEND_ENUM( wxFontFamily
)
56 wxBEGIN_ENUM( wxFontStyle
)
57 wxENUM_MEMBER( wxNORMAL
)
58 wxENUM_MEMBER( wxITALIC
)
59 wxENUM_MEMBER( wxSLANT
)
60 wxEND_ENUM( wxFontStyle
)
62 wxBEGIN_ENUM( wxFontWeight
)
63 wxENUM_MEMBER( wxNORMAL
)
64 wxENUM_MEMBER( wxLIGHT
)
65 wxENUM_MEMBER( wxBOLD
)
66 wxEND_ENUM( wxFontWeight
)
68 IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_XTI(wxFont
, wxGDIObject
,"wx/font.h")
70 wxBEGIN_PROPERTIES_TABLE(wxFont
)
71 wxPROPERTY( Size
,int, SetPointSize
, GetPointSize
, 12 , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
72 wxPROPERTY( Family
, int , SetFamily
, GetFamily
, (int)wxDEFAULT
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // wxFontFamily
73 wxPROPERTY( Style
, int , SetStyle
, GetStyle
, (int)wxNORMAL
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // wxFontStyle
74 wxPROPERTY( Weight
, int , SetWeight
, GetWeight
, (int)wxNORMAL
, 0 /*flags*/ , wxT("Helpstring") , wxT("group")) // wxFontWeight
75 wxPROPERTY( Underlined
, bool , SetUnderlined
, GetUnderlined
, false , 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
76 wxPROPERTY( Face
, wxString
, SetFaceName
, GetFaceName
, EMPTY_MACROVALUE
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
77 wxPROPERTY( Encoding
, wxFontEncoding
, SetEncoding
, GetEncoding
, wxFONTENCODING_DEFAULT
, 0 /*flags*/ , wxT("Helpstring") , wxT("group"))
78 wxEND_PROPERTIES_TABLE()
80 wxCONSTRUCTOR_6( wxFont
, int , Size
, int , Family
, int , Style
, int , Weight
, bool , Underlined
, wxString
, Face
)
82 wxBEGIN_HANDLERS_TABLE(wxFont
)
83 wxEND_HANDLERS_TABLE()
86 IMPLEMENT_DYNAMIC_CLASS(wxFont
, wxGDIObject
)
90 // ----------------------------------------------------------------------------
92 // ----------------------------------------------------------------------------
94 // the mask used to extract the pitch from LOGFONT::lfPitchAndFamily field
95 static const int PITCH_MASK
= FIXED_PITCH
| VARIABLE_PITCH
;
97 // ----------------------------------------------------------------------------
98 // wxFontRefData - the internal description of the font
99 // ----------------------------------------------------------------------------
101 class WXDLLEXPORT wxFontRefData
: public wxGDIRefData
107 Init(-1, wxSize(0,0), false, wxFONTFAMILY_DEFAULT
, wxFONTSTYLE_NORMAL
,
108 wxFONTWEIGHT_NORMAL
, false, wxEmptyString
,
109 wxFONTENCODING_DEFAULT
);
112 wxFontRefData(int size
,
113 const wxSize
& pixelSize
,
114 bool sizeUsingPixels
,
119 const wxString
& faceName
,
120 wxFontEncoding encoding
)
122 Init(size
, pixelSize
, sizeUsingPixels
, family
, style
, weight
,
123 underlined
, faceName
, encoding
);
126 wxFontRefData(const wxNativeFontInfo
& info
, WXHFONT hFont
= 0)
131 wxFontRefData(const wxFontRefData
& data
) : wxGDIRefData()
133 if ( data
.m_nativeFontInfoOk
)
135 Init(data
.m_nativeFontInfo
);
139 Init(data
.m_pointSize
, data
.m_pixelSize
, data
.m_sizeUsingPixels
,
140 data
.m_family
, data
.m_style
, data
.m_weight
,
141 data
.m_underlined
, data
.m_faceName
, data
.m_encoding
);
145 virtual ~wxFontRefData();
148 bool Alloc(wxFont
*font
);
152 // all wxFont accessors
153 int GetPointSize() const
155 return m_nativeFontInfoOk
? m_nativeFontInfo
.GetPointSize()
159 wxSize
GetPixelSize() const
161 return m_nativeFontInfoOk
? m_nativeFontInfo
.GetPixelSize()
165 bool IsUsingSizeInPixels() const
167 return m_nativeFontInfoOk
? true : m_sizeUsingPixels
;
170 int GetFamily() const
177 return m_nativeFontInfoOk
? m_nativeFontInfo
.GetStyle()
181 int GetWeight() const
183 return m_nativeFontInfoOk
? m_nativeFontInfo
.GetWeight()
187 bool GetUnderlined() const
189 return m_nativeFontInfoOk
? m_nativeFontInfo
.GetUnderlined()
193 wxString
GetFaceName() const
196 if ( m_nativeFontInfoOk
)
197 s
= m_nativeFontInfo
.GetFaceName();
204 wxFontEncoding
GetEncoding() const
206 return m_nativeFontInfoOk
? m_nativeFontInfo
.GetEncoding()
210 WXHFONT
GetHFONT() const { return m_hFont
; }
213 void SetPointSize(int pointSize
)
215 if ( m_nativeFontInfoOk
)
217 m_nativeFontInfo
.SetPointSize(pointSize
);
221 m_pointSize
= pointSize
;
222 m_sizeUsingPixels
= false;
226 void SetPixelSize(const wxSize
& pixelSize
)
228 if ( m_nativeFontInfoOk
)
230 m_nativeFontInfo
.SetPixelSize(pixelSize
);
234 m_pixelSize
= pixelSize
;
235 m_sizeUsingPixels
= true;
239 void SetFamily(int family
)
244 void SetStyle(int style
)
246 if ( m_nativeFontInfoOk
)
247 m_nativeFontInfo
.SetStyle((wxFontStyle
)style
);
252 void SetWeight(int weight
)
254 if ( m_nativeFontInfoOk
)
255 m_nativeFontInfo
.SetWeight((wxFontWeight
)weight
);
260 bool SetFaceName(const wxString
& faceName
)
262 if ( m_nativeFontInfoOk
)
263 return m_nativeFontInfo
.SetFaceName(faceName
);
265 m_faceName
= faceName
;
269 void SetUnderlined(bool underlined
)
271 if ( m_nativeFontInfoOk
)
272 m_nativeFontInfo
.SetUnderlined(underlined
);
274 m_underlined
= underlined
;
277 void SetEncoding(wxFontEncoding encoding
)
279 if ( m_nativeFontInfoOk
)
280 m_nativeFontInfo
.SetEncoding(encoding
);
282 m_encoding
= encoding
;
285 // native font info tests
286 bool HasNativeFontInfo() const { return m_nativeFontInfoOk
; }
288 const wxNativeFontInfo
& GetNativeFontInfo() const
289 { return m_nativeFontInfo
; }
292 // common part of all ctors
294 const wxSize
& pixelSize
,
295 bool sizeUsingPixels
,
300 const wxString
& faceName
,
301 wxFontEncoding encoding
);
303 void Init(const wxNativeFontInfo
& info
, WXHFONT hFont
= 0);
305 // font characterstics
308 bool m_sizeUsingPixels
;
314 wxFontEncoding m_encoding
;
316 // Windows font handle
320 wxNativeFontInfo m_nativeFontInfo
;
321 bool m_nativeFontInfoOk
;
324 // ============================================================================
326 // ============================================================================
328 // ----------------------------------------------------------------------------
330 // ----------------------------------------------------------------------------
332 void wxFontRefData::Init(int pointSize
,
333 const wxSize
& pixelSize
,
334 bool sizeUsingPixels
,
339 const wxString
& faceName
,
340 wxFontEncoding encoding
)
343 m_pointSize
= pointSize
== -1 ? wxNORMAL_FONT
->GetPointSize() : pointSize
;
344 m_pixelSize
= pixelSize
;
345 m_sizeUsingPixels
= sizeUsingPixels
;
349 m_underlined
= underlined
;
350 m_faceName
= faceName
;
351 m_encoding
= encoding
;
355 m_nativeFontInfoOk
= false;
358 void wxFontRefData::Init(const wxNativeFontInfo
& info
, WXHFONT hFont
)
360 // hFont may be zero, or it be passed in case we really want to
361 // use the exact font created in the underlying system
362 // (for example where we can't guarantee conversion from HFONT
363 // to LOGFONT back to HFONT)
366 m_nativeFontInfoOk
= true;
367 m_nativeFontInfo
= info
;
368 // This is the best we can do since we don't have the
369 // correct information at this point.
373 wxFontRefData::~wxFontRefData()
378 bool wxFontRefData::Alloc(wxFont
*font
)
380 if ( !m_nativeFontInfoOk
)
382 wxFillLogFont(&m_nativeFontInfo
.lf
, font
);
383 m_nativeFontInfoOk
= true;
386 HFONT hfont
= ::CreateFontIndirect(&m_nativeFontInfo
.lf
);
389 wxLogLastError(wxT("CreateFont"));
393 m_hFont
= (WXHFONT
)hfont
;
397 void wxFontRefData::Free()
401 if ( !::DeleteObject((HFONT
) m_hFont
) )
403 wxLogLastError(wxT("DeleteObject(font)"));
410 // ----------------------------------------------------------------------------
412 // ----------------------------------------------------------------------------
414 void wxNativeFontInfo::Init()
418 // we get better font quality if we use this instead of DEFAULT_QUALITY
419 // apparently without any drawbacks
420 lf
.lfQuality
= PROOF_QUALITY
;
423 int wxNativeFontInfo::GetPointSize() const
425 // FIXME: using the screen here results in incorrect font size calculation
427 const int ppInch
= ::GetDeviceCaps(ScreenHDC(), LOGPIXELSY
);
429 return (int) (((72.0*(double)abs(lf
.lfHeight
)) / (double) ppInch
) + 0.5);
432 wxSize
wxNativeFontInfo::GetPixelSize() const
435 ret
.SetHeight(lf
.lfHeight
);
436 ret
.SetWidth(lf
.lfWidth
);
440 wxFontStyle
wxNativeFontInfo::GetStyle() const
442 return lf
.lfItalic
? wxFONTSTYLE_ITALIC
: wxFONTSTYLE_NORMAL
;
445 wxFontWeight
wxNativeFontInfo::GetWeight() const
447 if ( lf
.lfWeight
<= 300 )
448 return wxFONTWEIGHT_LIGHT
;
450 if ( lf
.lfWeight
>= 600 )
451 return wxFONTWEIGHT_BOLD
;
453 return wxFONTWEIGHT_NORMAL
;
456 bool wxNativeFontInfo::GetUnderlined() const
458 return lf
.lfUnderline
!= 0;
461 wxString
wxNativeFontInfo::GetFaceName() const
463 return lf
.lfFaceName
;
466 wxFontFamily
wxNativeFontInfo::GetFamily() const
470 // extract family from pitch-and-family
471 switch ( lf
.lfPitchAndFamily
& ~PITCH_MASK
)
474 family
= wxFONTFAMILY_ROMAN
;
478 wxFAIL_MSG( _T("unknown LOGFONT::lfFamily value") );
482 family
= wxFONTFAMILY_SWISS
;
486 family
= wxFONTFAMILY_SCRIPT
;
490 family
= wxFONTFAMILY_MODERN
;
494 family
= wxFONTFAMILY_DECORATIVE
;
501 wxFontEncoding
wxNativeFontInfo::GetEncoding() const
503 return wxGetFontEncFromCharSet(lf
.lfCharSet
);
506 void wxNativeFontInfo::SetPointSize(int pointsize
)
508 // FIXME: using the screen here results in incorrect font size calculation
510 const int ppInch
= ::GetDeviceCaps(ScreenHDC(), LOGPIXELSY
);
512 lf
.lfHeight
= -(int)((pointsize
*((double)ppInch
)/72.0) + 0.5);
515 void wxNativeFontInfo::SetPixelSize(const wxSize
& pixelSize
)
517 lf
.lfHeight
= pixelSize
.GetHeight();
518 lf
.lfWidth
= pixelSize
.GetWidth();
522 void wxNativeFontInfo::SetStyle(wxFontStyle style
)
527 wxFAIL_MSG( _T("unknown font style") );
530 case wxFONTSTYLE_NORMAL
:
534 case wxFONTSTYLE_ITALIC
:
535 case wxFONTSTYLE_SLANT
:
541 void wxNativeFontInfo::SetWeight(wxFontWeight weight
)
546 wxFAIL_MSG( _T("unknown font weight") );
549 case wxFONTWEIGHT_NORMAL
:
550 lf
.lfWeight
= FW_NORMAL
;
553 case wxFONTWEIGHT_LIGHT
:
554 lf
.lfWeight
= FW_LIGHT
;
557 case wxFONTWEIGHT_BOLD
:
558 lf
.lfWeight
= FW_BOLD
;
563 void wxNativeFontInfo::SetUnderlined(bool underlined
)
565 lf
.lfUnderline
= underlined
;
568 bool wxNativeFontInfo::SetFaceName(const wxString
& facename
)
570 size_t len
= WXSIZEOF(lf
.lfFaceName
);
571 wxStrncpy(lf
.lfFaceName
, facename
, len
);
572 lf
.lfFaceName
[len
- 1] = '\0'; // truncate the face name
576 void wxNativeFontInfo::SetFamily(wxFontFamily family
)
579 wxArrayString facename
;
581 // the list of fonts associated with a family was partially
582 // taken from http://www.codestyle.org/css/font-family
587 ff_family
= FF_SCRIPT
;
588 facename
.Add(_T("Script"));
589 facename
.Add(_T("Brush Script MT"));
590 facename
.Add(_T("Comic Sans MS"));
591 facename
.Add(_T("Lucida Handwriting"));
595 ff_family
= FF_DECORATIVE
;
596 facename
.Add(_T("Old English Text MT"));
597 facename
.Add(_T("Comic Sans MS"));
598 facename
.Add(_T("Lucida Handwriting"));
602 ff_family
= FF_ROMAN
;
603 facename
.Add(_T("Times New Roman"));
604 facename
.Add(_T("Georgia"));
605 facename
.Add(_T("Garamond"));
606 facename
.Add(_T("Bookman Old Style"));
607 facename
.Add(_T("Book Antiqua"));
612 ff_family
= FF_MODERN
;
613 facename
.Add(_T("Courier New"));
614 facename
.Add(_T("Lucida Console"));
615 facename
.Add(_T("Andale Mono"));
616 facename
.Add(_T("OCR A Extended"));
617 facename
.Add(_T("Terminal"));
621 ff_family
= FF_SWISS
;
622 facename
.Add(_T("Arial"));
623 facename
.Add(_T("Century Gothic"));
624 facename
.Add(_T("Lucida Sans Unicode"));
625 facename
.Add(_T("Tahoma"));
626 facename
.Add(_T("Trebuchet MS"));
627 facename
.Add(_T("Verdana"));
633 // We want Windows 2000 or later to have new fonts even MS Shell Dlg
634 // is returned as default GUI font for compatibility
636 ff_family
= FF_SWISS
;
637 if(wxGetOsVersion(&verMaj
) == wxWINDOWS_NT
&& verMaj
>= 5)
638 facename
.Add(_T("MS Shell Dlg 2"));
640 facename
.Add(_T("MS Shell Dlg"));
643 // "MS Shell Dlg is a mapping mechanism that enables
644 // U.S. English Microsoft Windows NT, and Microsoft Windows 2000 to
645 // support locales that have characters that are not contained in code
646 // page 1252. It is not a font but a face name for a nonexistent font."
650 lf
.lfPitchAndFamily
= (BYTE
)(DEFAULT_PITCH
) | ff_family
;
652 if ( !wxStrlen(lf
.lfFaceName
) )
654 SetFaceName(facename
);
658 void wxNativeFontInfo::SetEncoding(wxFontEncoding encoding
)
660 wxNativeEncodingInfo info
;
661 if ( !wxGetNativeFontEncoding(encoding
, &info
) )
664 if ( wxFontMapper::Get()->GetAltForEncoding(encoding
, &info
) )
666 if ( !info
.facename
.empty() )
668 // if we have this encoding only in some particular facename, use
669 // the facename - it is better to show the correct characters in a
670 // wrong facename than unreadable text in a correct one
671 SetFaceName(info
.facename
);
675 #endif // wxUSE_FONTMAP
677 // unsupported encoding, replace with the default
678 info
.charset
= DEFAULT_CHARSET
;
682 lf
.lfCharSet
= (BYTE
)info
.charset
;
685 bool wxNativeFontInfo::FromString(const wxString
& s
)
689 wxStringTokenizer
tokenizer(s
, _T(";"));
692 wxString token
= tokenizer
.GetNextToken();
693 if ( token
!= _T('0') )
696 token
= tokenizer
.GetNextToken();
697 if ( !token
.ToLong(&l
) )
701 token
= tokenizer
.GetNextToken();
702 if ( !token
.ToLong(&l
) )
706 token
= tokenizer
.GetNextToken();
707 if ( !token
.ToLong(&l
) )
711 token
= tokenizer
.GetNextToken();
712 if ( !token
.ToLong(&l
) )
714 lf
.lfOrientation
= l
;
716 token
= tokenizer
.GetNextToken();
717 if ( !token
.ToLong(&l
) )
721 token
= tokenizer
.GetNextToken();
722 if ( !token
.ToLong(&l
) )
724 lf
.lfItalic
= (BYTE
)l
;
726 token
= tokenizer
.GetNextToken();
727 if ( !token
.ToLong(&l
) )
729 lf
.lfUnderline
= (BYTE
)l
;
731 token
= tokenizer
.GetNextToken();
732 if ( !token
.ToLong(&l
) )
734 lf
.lfStrikeOut
= (BYTE
)l
;
736 token
= tokenizer
.GetNextToken();
737 if ( !token
.ToLong(&l
) )
739 lf
.lfCharSet
= (BYTE
)l
;
741 token
= tokenizer
.GetNextToken();
742 if ( !token
.ToLong(&l
) )
744 lf
.lfOutPrecision
= (BYTE
)l
;
746 token
= tokenizer
.GetNextToken();
747 if ( !token
.ToLong(&l
) )
749 lf
.lfClipPrecision
= (BYTE
)l
;
751 token
= tokenizer
.GetNextToken();
752 if ( !token
.ToLong(&l
) )
754 lf
.lfQuality
= (BYTE
)l
;
756 token
= tokenizer
.GetNextToken();
757 if ( !token
.ToLong(&l
) )
759 lf
.lfPitchAndFamily
= (BYTE
)l
;
761 token
= tokenizer
.GetNextToken();
764 wxStrcpy(lf
.lfFaceName
, token
.c_str());
769 wxString
wxNativeFontInfo::ToString() const
773 s
.Printf(_T("%d;%ld;%ld;%ld;%ld;%ld;%d;%d;%d;%d;%d;%d;%d;%d;%s"),
774 0, // version, in case we want to change the format later
793 // ----------------------------------------------------------------------------
795 // ----------------------------------------------------------------------------
797 bool wxFont::Create(const wxNativeFontInfo
& info
, WXHFONT hFont
)
801 m_refData
= new wxFontRefData(info
, hFont
);
808 wxFont::wxFont(const wxString
& fontdesc
)
810 wxNativeFontInfo info
;
811 if ( info
.FromString(fontdesc
) )
815 /* Constructor for a font. Note that the real construction is done
816 * in wxDC::SetFont, when information is available about scaling etc.
818 bool wxFont::DoCreate(int pointSize
,
819 const wxSize
& pixelSize
,
820 bool sizeUsingPixels
,
825 const wxString
& faceName
,
826 wxFontEncoding encoding
)
830 // wxDEFAULT is a valid value for the font size too so we must treat it
831 // specially here (otherwise the size would be 70 == wxDEFAULT value)
832 if ( pointSize
== wxDEFAULT
)
834 pointSize
= wxNORMAL_FONT
->GetPointSize();
837 m_refData
= new wxFontRefData(pointSize
, pixelSize
, sizeUsingPixels
,
838 family
, style
, weight
,
839 underlined
, faceName
, encoding
);
850 // ----------------------------------------------------------------------------
851 // real implementation
852 // ----------------------------------------------------------------------------
854 bool wxFont::RealizeResource()
856 if ( GetResourceHandle() )
858 // VZ: the old code returned false in this case, but it doesn't seem
859 // to make sense because the font _was_ created
863 return M_FONTDATA
->Alloc(this);
866 bool wxFont::FreeResource(bool WXUNUSED(force
))
868 if ( GetResourceHandle() )
878 WXHANDLE
wxFont::GetResourceHandle() const
880 return (WXHANDLE
)GetHFONT();
883 WXHFONT
wxFont::GetHFONT() const
885 return M_FONTDATA
? M_FONTDATA
->GetHFONT() : 0;
888 bool wxFont::IsFree() const
890 return M_FONTDATA
&& (M_FONTDATA
->GetHFONT() == 0);
893 void wxFont::Unshare()
895 // Don't change shared data
898 m_refData
= new wxFontRefData();
902 wxFontRefData
* ref
= new wxFontRefData(*M_FONTDATA
);
908 // ----------------------------------------------------------------------------
909 // change font attribute: we recreate font when doing it
910 // ----------------------------------------------------------------------------
912 void wxFont::SetPointSize(int pointSize
)
916 M_FONTDATA
->SetPointSize(pointSize
);
921 void wxFont::SetPixelSize(const wxSize
& pixelSize
)
925 M_FONTDATA
->SetPixelSize(pixelSize
);
930 void wxFont::SetFamily(int family
)
934 M_FONTDATA
->SetFamily(family
);
939 void wxFont::SetStyle(int style
)
943 M_FONTDATA
->SetStyle(style
);
948 void wxFont::SetWeight(int weight
)
952 M_FONTDATA
->SetWeight(weight
);
957 bool wxFont::SetFaceName(const wxString
& faceName
)
961 bool refdataok
= M_FONTDATA
->SetFaceName(faceName
);
965 // NB: using win32's GetObject() API on M_FONTDATA->GetHFONT()
966 // to retrieve a LOGFONT and then compare lf.lfFaceName
967 // with given facename is not reliable at all:
968 // Windows copies the facename given to ::CreateFontIndirect()
969 // without any validity check.
970 // Thus we use wxFontBase::SetFaceName to check if facename
972 return refdataok
&& wxFontBase::SetFaceName(faceName
);
975 void wxFont::SetUnderlined(bool underlined
)
979 M_FONTDATA
->SetUnderlined(underlined
);
984 void wxFont::SetEncoding(wxFontEncoding encoding
)
988 M_FONTDATA
->SetEncoding(encoding
);
993 void wxFont::DoSetNativeFontInfo(const wxNativeFontInfo
& info
)
999 *M_FONTDATA
= wxFontRefData(info
);
1004 // ----------------------------------------------------------------------------
1006 // ----------------------------------------------------------------------------
1008 int wxFont::GetPointSize() const
1010 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
1012 return M_FONTDATA
->GetPointSize();
1015 wxSize
wxFont::GetPixelSize() const
1017 return M_FONTDATA
->GetPixelSize();
1020 bool wxFont::IsUsingSizeInPixels() const
1022 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
1024 return M_FONTDATA
->IsUsingSizeInPixels();
1027 int wxFont::GetFamily() const
1029 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
1031 return M_FONTDATA
->GetFamily();
1034 int wxFont::GetStyle() const
1036 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
1038 return M_FONTDATA
->GetStyle();
1041 int wxFont::GetWeight() const
1043 wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
1045 return M_FONTDATA
->GetWeight();
1048 bool wxFont::GetUnderlined() const
1050 wxCHECK_MSG( Ok(), false, wxT("invalid font") );
1052 return M_FONTDATA
->GetUnderlined();
1055 wxString
wxFont::GetFaceName() const
1057 wxCHECK_MSG( Ok(), wxEmptyString
, wxT("invalid font") );
1059 return M_FONTDATA
->GetFaceName();
1062 wxFontEncoding
wxFont::GetEncoding() const
1064 wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT
, wxT("invalid font") );
1066 return M_FONTDATA
->GetEncoding();
1069 const wxNativeFontInfo
*wxFont::GetNativeFontInfo() const
1071 return M_FONTDATA
->HasNativeFontInfo() ? &(M_FONTDATA
->GetNativeFontInfo())
1075 wxString
wxFont::GetNativeFontInfoDesc() const
1077 // be sure we have an HFONT associated...
1078 wxConstCast(this, wxFont
)->RealizeResource();
1079 return wxFontBase::GetNativeFontInfoDesc();
1082 wxString
wxFont::GetNativeFontInfoUserDesc() const
1084 // be sure we have an HFONT associated...
1085 wxConstCast(this, wxFont
)->RealizeResource();
1086 return wxFontBase::GetNativeFontInfoUserDesc();
1089 bool wxFont::IsFixedWidth() const
1091 if ( M_FONTDATA
->HasNativeFontInfo() )
1093 // the two low-order bits specify the pitch of the font, the rest is
1096 (BYTE
)(M_FONTDATA
->GetNativeFontInfo().lf
.lfPitchAndFamily
& PITCH_MASK
);
1098 return pitch
== FIXED_PITCH
;
1101 return wxFontBase::IsFixedWidth();