don't return whatever encoding was set in SetEncoding(); always return wxFONTENCODING_UTF8 instead since that's the real encoding always used by wxFont under wxGTK

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@60158 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Francesco Montorsi
2009-04-14 23:18:50 +00:00
parent d9d551f6a2
commit 7ce58684a4
2 changed files with 28 additions and 19 deletions

View File

@@ -111,6 +111,8 @@ enum wxFontFlag
/** /**
Font encodings. Font encodings.
See wxFont::SetEncoding().
*/ */
enum wxFontEncoding enum wxFontEncoding
{ {
@@ -406,6 +408,15 @@ public:
*/ */
static wxFontEncoding GetDefaultEncoding(); static wxFontEncoding GetDefaultEncoding();
/**
Returns the encoding of this font.
Note that under wxGTK the returned value is always @c wxFONTENCODING_UTF8.
@see SetEncoding()
*/
virtual wxFontEncoding GetEncoding() const;
/** /**
Returns the face name associated with the font, or the empty string if Returns the face name associated with the font, or the empty string if
there is no face information. there is no face information.
@@ -542,6 +553,16 @@ public:
*/ */
static void SetDefaultEncoding(wxFontEncoding encoding); static void SetDefaultEncoding(wxFontEncoding encoding);
/**
Sets the encoding for this font.
Note that under wxGTK this function has no effect (because the underlying
Pango library always uses @c wxFONTENCODING_UTF8).
@see GetEncoding()
*/
virtual void SetEncoding(wxFontEncoding encoding);
/** /**
Sets the facename for the font. Sets the facename for the font.
Returns @true if the given face name exists; @false otherwise. Returns @true if the given face name exists; @false otherwise.

View File

@@ -93,7 +93,6 @@ protected:
void InitFromNative(); void InitFromNative();
private: private:
wxFontEncoding m_encoding;
bool m_underlined; bool m_underlined;
bool m_noAA; // No anti-aliasing bool m_noAA; // No anti-aliasing
@@ -115,16 +114,12 @@ void wxFontRefData::Init(int pointSize,
wxFontWeight weight, wxFontWeight weight,
bool underlined, bool underlined,
const wxString& faceName, const wxString& faceName,
wxFontEncoding encoding) wxFontEncoding WXUNUSED(encoding))
{ {
if (family == wxFONTFAMILY_DEFAULT) if (family == wxFONTFAMILY_DEFAULT)
family = wxFONTFAMILY_SWISS; family = wxFONTFAMILY_SWISS;
m_underlined = underlined; m_underlined = underlined;
m_encoding = encoding;
if ( m_encoding == wxFONTENCODING_DEFAULT )
m_encoding = wxFont::GetDefaultEncoding();
m_noAA = false; m_noAA = false;
// Create native font info // Create native font info
@@ -162,16 +157,12 @@ void wxFontRefData::InitFromNative()
// Pango description are never underlined // Pango description are never underlined
m_underlined = false; m_underlined = false;
// always with GTK+ 2
m_encoding = wxFONTENCODING_UTF8;
} }
wxFontRefData::wxFontRefData( const wxFontRefData& data ) wxFontRefData::wxFontRefData( const wxFontRefData& data )
: wxGDIRefData() : wxGDIRefData()
{ {
m_underlined = data.m_underlined; m_underlined = data.m_underlined;
m_encoding = data.m_encoding;
m_noAA = data.m_noAA; m_noAA = data.m_noAA;
// Forces a copy of the internal data. wxNativeFontInfo should probably // Forces a copy of the internal data. wxNativeFontInfo should probably
@@ -267,13 +258,9 @@ bool wxFontRefData::SetFaceName(const wxString& facename)
return m_nativeFontInfo.SetFaceName(facename); return m_nativeFontInfo.SetFaceName(facename);
} }
void wxFontRefData::SetEncoding(wxFontEncoding encoding) void wxFontRefData::SetEncoding(wxFontEncoding WXUNUSED(encoding))
{ {
m_encoding = encoding; // with GTK+ 2 Pango always uses UTF8 internally, we cannot change it
// the internal Pango encoding is always UTF8; here we save the
// encoding just to make it possible to return it from GetEncoding()
// FIXME: this seems wrong; shouldn't GetEncoding() always return wxFONTENCODING_UTF8?
} }
void wxFontRefData::SetNativeFontInfo(const wxNativeFontInfo& info) void wxFontRefData::SetNativeFontInfo(const wxNativeFontInfo& info)
@@ -386,7 +373,8 @@ wxFontEncoding wxFont::GetEncoding() const
{ {
wxCHECK_MSG( IsOk(), wxFONTENCODING_SYSTEM, wxT("invalid font") ); wxCHECK_MSG( IsOk(), wxFONTENCODING_SYSTEM, wxT("invalid font") );
return M_FONTDATA->m_encoding; return wxFONTENCODING_UTF8;
// Pango always uses UTF8... see also SetEncoding()
} }
bool wxFont::GetNoAntiAliasing() const bool wxFont::GetNoAntiAliasing() const