Add wxFontInfo::HasFaceName() and use it

No real changes, just simplify the code a little by adding this helper.
This commit is contained in:
Vadim Zeitlin 2018-09-14 19:25:31 +02:00
parent 03266b1091
commit 7866c293e8
4 changed files with 8 additions and 7 deletions

View File

@ -208,6 +208,9 @@ public:
float GetFractionalPointSize() const { return m_pointSize; }
int GetPointSize() const { return ToIntPointSize(m_pointSize); }
wxSize GetPixelSize() const { return m_pixelSize; }
// If face name is not empty, it has priority, otherwise use family.
bool HasFaceName() const { return !m_faceName.empty(); }
wxFontFamily GetFamily() const { return m_family; }
const wxString& GetFaceName() const { return m_faceName; }

View File

@ -86,11 +86,10 @@ wxFontRefData::wxFontRefData(const wxFontInfo& info)
m_nativeFontInfo.description = pango_font_description_new();
// And set its values
const wxString& faceName = info.GetFaceName();
if (!faceName.empty())
if ( info.HasFaceName() )
{
pango_font_description_set_family( m_nativeFontInfo.description,
wxGTK_CONV_SYS(faceName) );
wxGTK_CONV_SYS(info.GetFaceName()) );
}
else
{

View File

@ -330,7 +330,7 @@ wxFontRefData::wxFontRefData(const wxFontInfo& info)
// set the family/facename
SetFamily(info.GetFamily());
if ( !info.GetFaceName().empty() )
if ( info.HasFaceName() )
SetFaceName(info.GetFaceName());
// deal with encoding now (it may override the font family and facename

View File

@ -255,9 +255,8 @@ wxFontRefData::wxFontRefData(const wxFontInfo& info)
{
m_info.Init();
const wxString& faceName = info.GetFaceName();
if ( !faceName.empty() )
SetFaceName(faceName);
if ( info.HasFaceName() )
SetFaceName(info.GetFaceName());
else
SetFamily(info.GetFamily());