Add wxNativeFontInfo::SetSizeOrDefault() and use it in all ports
Reuse the same code for determining the default font size to use if it wasn't specified in all major ports. In particular, make wxGTK behaviour compatible with the rest and use the normal font size in this case instead of the hardcoded value of 12pt.
This commit is contained in:
@@ -285,6 +285,17 @@ public:
|
|||||||
void SetFamily(wxFontFamily family);
|
void SetFamily(wxFontFamily family);
|
||||||
void SetEncoding(wxFontEncoding encoding);
|
void SetEncoding(wxFontEncoding encoding);
|
||||||
|
|
||||||
|
// Helper used in many ports: use the normal font size if the input is
|
||||||
|
// negative, as we handle -1 as meaning this for compatibility.
|
||||||
|
void SetSizeOrDefault(float size)
|
||||||
|
{
|
||||||
|
SetFractionalPointSize
|
||||||
|
(
|
||||||
|
size < 0 ? wxNORMAL_FONT->GetFractionalPointSize()
|
||||||
|
: size
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// sets the first facename in the given array which is found
|
// sets the first facename in the given array which is found
|
||||||
// to be valid. If no valid facename is given, sets the
|
// to be valid. If no valid facename is given, sets the
|
||||||
// first valid facename returned by wxFontEnumerator::GetFacenames().
|
// first valid facename returned by wxFontEnumerator::GetFacenames().
|
||||||
|
@@ -133,11 +133,7 @@ void wxFontRefData::Init(float pointSize,
|
|||||||
}
|
}
|
||||||
|
|
||||||
SetStyle( style );
|
SetStyle( style );
|
||||||
m_nativeFontInfo.SetFractionalPointSize
|
m_nativeFontInfo.SetSizeOrDefault(pointSize);
|
||||||
(
|
|
||||||
pointSize < 0 ? static_cast<float>(wxDEFAULT_FONT_SIZE)
|
|
||||||
: pointSize
|
|
||||||
);
|
|
||||||
SetNumericWeight( weight );
|
SetNumericWeight( weight );
|
||||||
SetUnderlined( underlined );
|
SetUnderlined( underlined );
|
||||||
SetStrikethrough( strikethrough );
|
SetStrikethrough( strikethrough );
|
||||||
|
@@ -362,12 +362,7 @@ void wxFontRefData::Init(float pointSize,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_nativeFontInfo.SetFractionalPointSize
|
m_nativeFontInfo.SetSizeOrDefault(pointSize);
|
||||||
(
|
|
||||||
pointSize < 0
|
|
||||||
? wxNORMAL_FONT->GetPointSize()
|
|
||||||
: pointSize
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SetStyle(style);
|
SetStyle(style);
|
||||||
|
@@ -301,7 +301,7 @@ void wxFontRefData::Init(float size,
|
|||||||
else
|
else
|
||||||
SetFamily(family);
|
SetFamily(family);
|
||||||
|
|
||||||
SetFractionalPointSize(size < 0 ? wxNORMAL_FONT->GetFractionalPointSize() : size);
|
m_info.SetSizeOrDefault(size);
|
||||||
SetNumericWeight(weight);
|
SetNumericWeight(weight);
|
||||||
SetStyle(style);
|
SetStyle(style);
|
||||||
SetUnderlined(underlined);
|
SetUnderlined(underlined);
|
||||||
|
Reference in New Issue
Block a user