X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/e7e52b6d2fa1021a0fcf1a507ed8742c71b0da50..878711c01c1b9ad5b97d35f379a048b8ce1bfb49:/src/common/fontcmn.cpp diff --git a/src/common/fontcmn.cpp b/src/common/fontcmn.cpp index 94b9bab49b..d448cd6238 100644 --- a/src/common/fontcmn.cpp +++ b/src/common/fontcmn.cpp @@ -6,7 +6,7 @@ // Created: 20.09.99 // RCS-ID: $Id$ // Copyright: (c) wxWindows team -// Licence: wxWindows license +// Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// // ============================================================================ @@ -49,6 +49,22 @@ wxFontEncoding wxFontBase::ms_encodingDefault = wxFONTENCODING_SYSTEM; +/* static */ +void wxFontBase::SetDefaultEncoding(wxFontEncoding encoding) +{ + // GetDefaultEncoding() should return something != wxFONTENCODING_DEFAULT + // and, besides, using this value here doesn't make any sense + wxCHECK_RET( encoding != wxFONTENCODING_DEFAULT, + _T("can't set default encoding to wxFONTENCODING_DEFAULT") ); + + ms_encodingDefault = encoding; +} + +wxFontBase::~wxFontBase() +{ + // this destructor is required for Darwin +} + /* static */ wxFont *wxFontBase::New(int size, int family, @@ -61,6 +77,33 @@ wxFont *wxFontBase::New(int size, return new wxFont(size, family, style, weight, underlined, face, encoding); } +/* static */ +wxFont *wxFontBase::New(int pointSize, + wxFontFamily family, + int flags, + const wxString& face, + wxFontEncoding encoding) +{ + return New + ( + pointSize, + family, + flags & wxFONTFLAG_ITALIC + ? wxFONTSTYLE_ITALIC + : flags & wxFONTFLAG_SLANT + ? wxFONTSTYLE_SLANT + : wxFONTSTYLE_NORMAL, + flags & wxFONTFLAG_LIGHT + ? wxFONTWEIGHT_LIGHT + : flags & wxFONTFLAG_BOLD + ? wxFONTWEIGHT_BOLD + : wxFONTWEIGHT_NORMAL, + (flags & wxFONTFLAG_UNDERLINED) != 0, + face, + encoding + ); +} + /* static */ wxFont *wxFontBase::New(const wxNativeFontInfo& info) { @@ -77,6 +120,11 @@ wxFont *wxFontBase::New(const wxString& strNativeFontDesc) return New(fontInfo); } +bool wxFontBase::IsFixedWidth() const +{ + return GetFamily() == wxFONTFAMILY_TELETYPE; +} + wxNativeFontInfo *wxFontBase::GetNativeFontInfo() const { #ifdef wxNO_NATIVE_FONTINFO @@ -96,7 +144,7 @@ wxNativeFontInfo *wxFontBase::GetNativeFontInfo() const #endif } -void wxFontBase::SetNativeFontInfo(const wxNativeFontInfo& info) +void wxFontBase::DoSetNativeFontInfo(const wxNativeFontInfo& info) { #ifdef wxNO_NATIVE_FONTINFO SetPointSize(info.pointSize); @@ -275,8 +323,11 @@ bool wxNativeFontInfo::FromString(const wxString& s) underlined = l != 0; faceName = tokenizer.GetNextToken(); + +#ifndef __WXMAC__ if( !faceName ) return FALSE; +#endif token = tokenizer.GetNextToken(); if ( !token.ToLong(&l) ) @@ -391,7 +442,7 @@ void wxNativeFontInfo::SetEncoding(wxFontEncoding encoding_) // format there anyhow (but there is a well-defined standard for X11 fonts used // by wxGTK and wxMotif) -#if defined(wxNO_NATIVE_FONTINFO) || defined(__WXMSW__) +#if defined(wxNO_NATIVE_FONTINFO) || defined(__WXMSW__) || defined (__WXPM__) wxString wxNativeFontInfo::ToUserString() const { @@ -454,7 +505,7 @@ wxString wxNativeFontInfo::ToUserString() const wxFontEncoding enc = GetEncoding(); if ( enc != wxFONTENCODING_DEFAULT && enc != wxFONTENCODING_SYSTEM ) { - desc << _T(' ') << wxTheFontMapper->GetEncodingName(enc); + desc << _T(' ') << wxFontMapper::Get()->GetEncodingName(enc); } #endif // wxUSE_FONTMAP @@ -507,7 +558,7 @@ bool wxNativeFontInfo::FromUserString(const wxString& s) SetPointSize(size); } #if wxUSE_FONTMAP - else if ( (encoding = wxTheFontMapper->CharsetToEncoding(token, FALSE)) + else if ( (encoding = wxFontMapper::Get()->CharsetToEncoding(token, FALSE)) != wxFONTENCODING_DEFAULT ) { SetEncoding(encoding); @@ -545,5 +596,5 @@ bool wxNativeFontInfo::FromUserString(const wxString& s) return TRUE; } -#endif // generic or wxMSW +#endif // generic or wxMSW or wxOS2