Add wxFont::SetSymbolicSize() and SetSymbolicSizeRelativeTo().
These methods allow to set the font size using CSS-like absolute size specifications. Notice that the factors used here are incompatible with (but better than) the ones used in wxBuildFontSizes() in src/html/winpars.cpp. In the future it would be nice to reuse the new wxFont functions in wxHTML code. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@67052 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -491,6 +491,29 @@ bool wxFontBase::SetFaceName(const wxString& facename)
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxFontBase::SetSymbolicSize(wxFontSymbolicSize size)
|
||||
{
|
||||
SetSymbolicSizeRelativeTo(size, wxNORMAL_FONT->GetPointSize());
|
||||
}
|
||||
|
||||
/* static */
|
||||
int wxFontBase::AdjustToSymbolicSize(wxFontSymbolicSize size, int base)
|
||||
{
|
||||
// Using a fixed factor (1.2, from CSS2) is a bad idea as explained at
|
||||
// http://www.w3.org/TR/CSS21/fonts.html#font-size-props so use the values
|
||||
// from http://style.cleverchimp.com/font_size_intervals/altintervals.html
|
||||
// instead.
|
||||
static const float factors[] = { 0.60f, 0.75f, 0.89f, 1.f, 1.2f, 1.5f, 2.f };
|
||||
|
||||
wxCOMPILE_TIME_ASSERT
|
||||
(
|
||||
WXSIZEOF(factors) == wxFONTSIZE_XX_LARGE - wxFONTSIZE_XX_SMALL + 1,
|
||||
WrongFontSizeFactorsSize
|
||||
);
|
||||
|
||||
return factors[size - wxFONTSIZE_XX_SMALL]*base;
|
||||
}
|
||||
|
||||
wxFont& wxFont::MakeBold()
|
||||
{
|
||||
SetWeight(wxFONTWEIGHT_BOLD);
|
||||
|
||||
Reference in New Issue
Block a user