the font data have to stroe in m_nativeFontInfo, otherwise the constructor that use wxNavtiveFontInfo as parameter could not retrive the data in it.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@77814 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2014-09-23 17:41:51 +00:00
parent d2573ed255
commit c973dd7be5

View File

@@ -224,6 +224,7 @@ void wxFontRefData::Init(int pointSize,
m_nativeFontInfo.SetFaceName(m_faceName); m_nativeFontInfo.SetFaceName(m_faceName);
m_nativeFontInfo.SetWeight((wxFontWeight)m_weight); m_nativeFontInfo.SetWeight((wxFontWeight)m_weight);
m_nativeFontInfo.SetStyle((wxFontStyle)m_style); m_nativeFontInfo.SetStyle((wxFontStyle)m_style);
m_nativeFontInfo.SetUnderlined(underlined);
#endif // wxUSE_UNICODE #endif // wxUSE_UNICODE
SetPointSize(pointSize); SetPointSize(pointSize);
@@ -279,24 +280,6 @@ void wxFontRefData::InitFromNative()
break; break;
} }
if (m_faceName == wxT("monospace"))
{
m_family = wxFONTFAMILY_TELETYPE;
}
else if (m_faceName == wxT("sans"))
{
m_family = wxFONTFAMILY_SWISS;
}
else
{
m_family = wxFONTFAMILY_UNKNOWN;
}
// Pango description are never underlined (?)
m_underlined = false;
// Cannot we choose that
m_encoding = wxFONTENCODING_SYSTEM;
#else // X11 #else // X11
// get the font parameters from the XLFD // get the font parameters from the XLFD
// ------------------------------------- // -------------------------------------
@@ -509,14 +492,13 @@ void wxFontRefData::SetWeight(wxFontWeight weight)
void wxFontRefData::SetUnderlined(bool underlined) void wxFontRefData::SetUnderlined(bool underlined)
{ {
m_underlined = underlined; m_nativeFontInfo.SetUnderlined(underlined);
// the XLFD doesn't have "underlined" field anyhow // the XLFD doesn't have "underlined" field anyhow
} }
void wxFontRefData::SetStrikethrough(bool strikethrough) void wxFontRefData::SetStrikethrough(bool strikethrough)
{ {
m_strikethrough = strikethrough; m_nativeFontInfo.SetStrikethrough(strikethrough);
} }
bool wxFontRefData::SetFaceName(const wxString& facename) bool wxFontRefData::SetFaceName(const wxString& facename)
@@ -537,6 +519,8 @@ void wxFontRefData::SetNativeFontInfo(const wxNativeFontInfo& info)
m_nativeFontInfo = info; m_nativeFontInfo = info;
m_family = info.GetFamily();
// set all the other font parameters from the native font info // set all the other font parameters from the native font info
InitFromNative(); InitFromNative();
} }
@@ -579,7 +563,7 @@ bool wxFont::Create(int pointSize,
return true; return true;
} }
bool wxFont::Create(const wxString& fontname, wxFontEncoding enc) bool wxFont::Create(const wxString& fontname, wxFontEncoding WXUNUSED(enc))
{ {
if( !fontname ) if( !fontname )
{ {
@@ -650,6 +634,8 @@ bool wxFont::Create(const wxString& fontname, wxFontEncoding enc)
tn.GetNextToken(); // avg width tn.GetNextToken(); // avg width
// Note: font encoding is not used in unicode
#if !wxUSE_UNICODE
// deal with font encoding // deal with font encoding
M_FONTDATA->m_encoding = enc; M_FONTDATA->m_encoding = enc;
if ( M_FONTDATA->m_encoding == wxFONTENCODING_SYSTEM ) if ( M_FONTDATA->m_encoding == wxFONTENCODING_SYSTEM )
@@ -683,6 +669,8 @@ bool wxFont::Create(const wxString& fontname, wxFontEncoding enc)
else else
return false; return false;
} }
#endif
return true; return true;
} }
@@ -727,14 +715,14 @@ int wxFont::GetPointSize() const
{ {
wxCHECK_MSG( IsOk(), 0, wxT("invalid font") ); wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
return M_FONTDATA->m_pointSize; return M_FONTDATA->m_nativeFontInfo.GetPointSize();
} }
wxString wxFont::GetFaceName() const wxString wxFont::GetFaceName() const
{ {
wxCHECK_MSG( IsOk(), wxEmptyString, wxT("invalid font") ); wxCHECK_MSG( IsOk(), wxEmptyString, wxT("invalid font") );
return M_FONTDATA->m_faceName; return M_FONTDATA->m_nativeFontInfo.GetFaceName();
} }
wxFontFamily wxFont::DoGetFamily() const wxFontFamily wxFont::DoGetFamily() const
@@ -760,21 +748,27 @@ bool wxFont::GetUnderlined() const
{ {
wxCHECK_MSG( IsOk(), false, wxT("invalid font") ); wxCHECK_MSG( IsOk(), false, wxT("invalid font") );
return M_FONTDATA->m_underlined; return M_FONTDATA->m_nativeFontInfo.GetUnderlined();
} }
bool wxFont::GetStrikethrough() const bool wxFont::GetStrikethrough() const
{ {
wxCHECK_MSG( IsOk(), false, wxT("invalid font") ); wxCHECK_MSG( IsOk(), false, wxT("invalid font") );
return M_FONTDATA->m_strikethrough; return M_FONTDATA->m_nativeFontInfo.GetStrikethrough();
} }
wxFontEncoding wxFont::GetEncoding() const wxFontEncoding wxFont::GetEncoding() const
{ {
wxCHECK_MSG( IsOk(), wxFONTENCODING_DEFAULT, wxT("invalid font") ); wxCHECK_MSG( IsOk(), wxFONTENCODING_DEFAULT, wxT("invalid font") );
#if wxUSE_UNICODE
// unicode didn't use font encoding
return wxFONTENCODING_DEFAULT;
#else
return M_FONTDATA->m_encoding; return M_FONTDATA->m_encoding;
#endif
} }
const wxNativeFontInfo *wxFont::GetNativeFontInfo() const const wxNativeFontInfo *wxFont::GetNativeFontInfo() const