Handle underlined and strikethrough attributes in wxGTK native font info.

These attributes were not handled by wxFont::GetNativeFontInfoDesc() as it
only serialized the Pango font description which doesn't support them.

Fix this by handling these attributes explicitly and prepending them to the
Pango font string if necessary.

Closes #14559.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72488 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2012-09-15 23:17:12 +00:00
parent cba4e486a4
commit a349dc1085
5 changed files with 87 additions and 34 deletions

View File

@@ -26,6 +26,8 @@
#include "wx/font.h"
#include "asserthelper.h"
// ----------------------------------------------------------------------------
// test class
// ----------------------------------------------------------------------------
@@ -204,6 +206,12 @@ void FontTestCase::GetSet()
CPPUNIT_ASSERT( test.IsOk() );
CPPUNIT_ASSERT_EQUAL( true, test.GetUnderlined() );
// test Get/SetStrikethrough()
test.SetStrikethrough(true);
CPPUNIT_ASSERT( test.IsOk() );
CPPUNIT_ASSERT_EQUAL( true, test.GetStrikethrough() );
// test Get/SetWeight()
@@ -245,6 +253,26 @@ void FontTestCase::NativeFontInfo()
#if !defined(__WXGTK__) && !defined(__WXX11__)
CPPUNIT_ASSERT( !font.SetNativeFontInfo("bloordyblop") );
#endif
// Pango font description doesn't have 'underlined' and 'strikethrough'
// attributes, so wxNativeFontInfo implements these itself. Test if these
// are properly preserved by wxNativeFontInfo or its string description.
font.SetUnderlined(true);
font.SetStrikethrough(true);
CPPUNIT_ASSERT_EQUAL(font, wxFont(font));
CPPUNIT_ASSERT_EQUAL(font, wxFont(*font.GetNativeFontInfo()));
CPPUNIT_ASSERT_EQUAL(font, wxFont(font.GetNativeFontInfoDesc()));
font.SetUnderlined(false);
CPPUNIT_ASSERT_EQUAL(font, wxFont(font));
CPPUNIT_ASSERT_EQUAL(font, wxFont(*font.GetNativeFontInfo()));
CPPUNIT_ASSERT_EQUAL(font, wxFont(font.GetNativeFontInfoDesc()));
font.SetUnderlined(true);
font.SetStrikethrough(false);
CPPUNIT_ASSERT_EQUAL(font, wxFont(font));
CPPUNIT_ASSERT_EQUAL(font, wxFont(*font.GetNativeFontInfo()));
CPPUNIT_ASSERT_EQUAL(font, wxFont(font.GetNativeFontInfoDesc()));
// note: the GetNativeFontInfoUserDesc() doesn't preserve all attributes
// according to docs, so it is not tested.
}
void FontTestCase::NativeFontInfoUserDesc()