Merge branch 'font-fixes'

Complete support for fractional point sizes and font weights other than
light/bold.

Also harmonize wxFont API and implementation among all ports (fixing
compilation of those of them that were broken by recent changes).

See https://github.com/wxWidgets/wxWidgets/pull/919
This commit is contained in:
Vadim Zeitlin
2018-09-17 22:58:56 +02:00
55 changed files with 1730 additions and 1311 deletions

View File

@@ -72,19 +72,19 @@ public:
bool Create(const wxNativeFontInfo& fontinfo);
// implement base class pure virtuals
virtual int GetPointSize() const;
virtual float GetFractionalPointSize() const;
virtual wxFontStyle GetStyle() const;
virtual wxFontWeight GetWeight() const;
virtual int GetNumericWeight() const;
virtual wxString GetFaceName() const;
virtual bool GetUnderlined() const;
virtual wxFontEncoding GetEncoding() const;
virtual bool IsFixedWidth() const;
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
virtual void SetPointSize(int pointSize);
virtual void SetFractionalPointSize(float pointSize);
virtual void SetFamily(wxFontFamily family);
virtual void SetStyle(wxFontStyle style);
virtual void SetWeight(wxFontWeight weight);
virtual void SetNumericWeight(int weight);
virtual bool SetFaceName(const wxString& faceName);
virtual void SetUnderlined(bool underlined);
virtual void SetEncoding(wxFontEncoding encoding);

View File

@@ -19,6 +19,7 @@
#include "wx/fontenc.h" // the font encoding constants
#include "wx/gdiobj.h" // the base class
#include "wx/gdicmn.h" // for wxGDIObjListBase
#include "wx/math.h" // for wxRound()
// ----------------------------------------------------------------------------
// forward declarations
@@ -95,7 +96,7 @@ enum wxFontFlag
wxFONTFLAG_ITALIC = 1 << 0,
wxFONTFLAG_SLANT = 1 << 1,
// weight flags (default: medium)
// weight flags (default: medium):
wxFONTFLAG_LIGHT = 1 << 2,
wxFONTFLAG_BOLD = 1 << 3,
@@ -128,14 +129,23 @@ public:
// Default ctor uses the default font size appropriate for the current
// platform.
wxFontInfo()
{ InitPointSize(-1); }
{ InitPointSize(-1.0f); }
// These ctors specify the font size, either in points or in pixels.
explicit wxFontInfo(int pointSize)
// Point size is a floating point number, however we also accept all
// integer sizes using the simple template ctor below.
explicit wxFontInfo(float pointSize)
{ InitPointSize(pointSize); }
explicit wxFontInfo(const wxSize& pixelSize) : m_pixelSize(pixelSize)
{ Init(); }
// Need to define this one to avoid casting double to int too.
explicit wxFontInfo(double pointSize)
{ InitPointSize(pointSize); }
template <typename T>
explicit wxFontInfo(T pointSize)
{ InitPointSize(ToFloatPointSize(pointSize)); }
// Setters for the various attributes. All of them return the object itself
// so that the calls to them could be chained.
wxFontInfo& Family(wxFontFamily family)
@@ -143,15 +153,27 @@ public:
wxFontInfo& FaceName(const wxString& faceName)
{ m_faceName = faceName; return *this; }
wxFontInfo& Weight(int weight)
{ m_weight = weight; return *this; }
wxFontInfo& Bold(bool bold = true)
{ SetFlag(wxFONTFLAG_BOLD, bold); return *this; }
{ return Weight(bold ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL); }
wxFontInfo& Light(bool light = true)
{ SetFlag(wxFONTFLAG_LIGHT, light); return *this; }
{ return Weight(light ? wxFONTWEIGHT_LIGHT : wxFONTWEIGHT_NORMAL); }
wxFontInfo& Italic(bool italic = true)
{ SetFlag(wxFONTFLAG_ITALIC, italic); return *this; }
wxFontInfo& Slant(bool slant = true)
{ SetFlag(wxFONTFLAG_SLANT, slant); return *this; }
wxFontInfo& Style(wxFontStyle style)
{
if ( style == wxFONTSTYLE_ITALIC )
return Italic();
if ( style == wxFONTSTYLE_SLANT )
return Slant();
return *this;
}
wxFontInfo& AntiAliased(bool antiAliased = true)
{ SetFlag(wxFONTFLAG_ANTIALIASED, antiAliased); return *this; }
@@ -166,15 +188,29 @@ public:
// Set all flags at once.
wxFontInfo& AllFlags(int flags)
{ m_flags = flags; return *this; }
{
m_flags = flags;
m_weight = m_flags & wxFONTFLAG_BOLD
? wxFONTWEIGHT_BOLD
: m_flags & wxFONTFLAG_LIGHT
? wxFONTWEIGHT_LIGHT
: wxFONTWEIGHT_NORMAL;
return *this;
}
// Accessors are mostly meant to be used by wxFont itself to extract the
// various pieces of the font description.
bool IsUsingSizeInPixels() const { return m_pixelSize != wxDefaultSize; }
int GetPointSize() const { return m_pointSize; }
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; }
@@ -187,13 +223,14 @@ public:
: wxFONTSTYLE_NORMAL;
}
int GetNumericWeight() const
{
return m_weight;
}
wxFontWeight GetWeight() const
{
return m_flags & wxFONTFLAG_LIGHT
? wxFONTWEIGHT_LIGHT
: m_flags & wxFONTFLAG_BOLD
? wxFONTWEIGHT_BOLD
: wxFONTWEIGHT_NORMAL;
return GetWeightClosestToNumericValue(m_weight);
}
bool IsAntiAliased() const
@@ -216,16 +253,57 @@ public:
// Default copy ctor, assignment operator and dtor are OK.
// Helper functions for converting between integer and fractional sizes.
static int ToIntPointSize(float pointSize) { return wxRound(pointSize); }
static float ToFloatPointSize(int pointSize)
{
wxCHECK_MSG( pointSize == -1 || pointSize >= 0,
-1, "Invalid font point size" );
// Huge values are not exactly representable as floats, so don't accept
// those neither as they can only be due to a mistake anyhow: nobody
// could possibly need a font of size 16777217pt (which is the first
// value for which this fails).
const float f = static_cast<float>(pointSize);
wxCHECK_MSG( static_cast<int>(f) == pointSize,
-1, "Font point size out of range" );
return f;
}
// Another helper for converting arbitrary numeric weight to the closest
// value of wxFontWeight enum. It should be avoided in the new code (also
// note that the function for the conversion in the other direction is
// trivial and so is not provided, we only have GetNumericWeightOf() which
// contains backwards compatibility hacks, but we don't need it here).
static wxFontWeight GetWeightClosestToNumericValue(int numWeight)
{
wxASSERT(numWeight > 0);
wxASSERT(numWeight <= 1000);
// round to nearest hundredth = wxFONTWEIGHT_ constant
int weight = ((numWeight + 50) / 100) * 100;
if (weight < wxFONTWEIGHT_THIN)
weight = wxFONTWEIGHT_THIN;
if (weight > wxFONTWEIGHT_MAX)
weight = wxFONTWEIGHT_MAX;
return static_cast<wxFontWeight>(weight);
}
private:
void Init()
{
m_pointSize = -1;
m_family = wxFONTFAMILY_DEFAULT;
m_flags = wxFONTFLAG_DEFAULT;
m_weight = wxFONTWEIGHT_NORMAL;
m_encoding = wxFONTENCODING_DEFAULT;
}
void InitPointSize(int pointSize)
void InitPointSize(float pointSize)
{
Init();
@@ -244,15 +322,15 @@ private:
}
// The size information: if m_pixelSize is valid (!= wxDefaultSize), then
// it is used. Otherwise m_pointSize is used, taking into account that if
// it is == -1, it means that the platform dependent font size should be
// used.
int m_pointSize;
// it is used. Otherwise m_pointSize is used, except if it is < 0, which
// means that the platform dependent font size should be used instead.
float m_pointSize;
wxSize m_pixelSize;
wxFontFamily m_family;
wxString m_faceName;
int m_flags;
int m_weight;
wxFontEncoding m_encoding;
};
@@ -352,7 +430,6 @@ public:
virtual bool IsUsingSizeInPixels() const;
wxFontFamily GetFamily() const;
virtual wxFontStyle GetStyle() const = 0;
virtual wxFontWeight GetWeight() const = 0;
virtual int GetNumericWeight() const = 0;
virtual bool GetUnderlined() const = 0;
virtual bool GetStrikethrough() const { return false; }
@@ -360,17 +437,20 @@ public:
virtual wxFontEncoding GetEncoding() const = 0;
virtual const wxNativeFontInfo *GetNativeFontInfo() const = 0;
// Accessors that can be overridden in the platform-specific code but for
// which we provide a reasonable default implementation in the base class.
virtual wxFontWeight GetWeight() const;
virtual bool IsFixedWidth() const;
wxString GetNativeFontInfoDesc() const;
wxString GetNativeFontInfoUserDesc() const;
// change the font characteristics
virtual void SetPointSize( float pointSize ) = 0;
virtual void SetPointSize( int pointSize );
virtual void SetFractionalPointSize( float pointSize ) = 0;
virtual void SetPixelSize( const wxSize& pixelSize );
virtual void SetFamily( wxFontFamily family ) = 0;
virtual void SetStyle( wxFontStyle style ) = 0;
virtual void SetWeight( wxFontWeight weight ) = 0;
virtual void SetNumericWeight( int weight ) = 0;
virtual void SetUnderlined( bool underlined ) = 0;
@@ -380,6 +460,10 @@ public:
void SetNativeFontInfo(const wxNativeFontInfo& info)
{ DoSetNativeFontInfo(info); }
// Similarly to the accessors above, the functions in this group have a
// reasonable default implementation in the base class.
virtual void SetWeight( wxFontWeight weight );
bool SetNativeFontInfo(const wxString& info);
bool SetNativeFontInfoUserDesc(const wxString& info);
@@ -407,12 +491,30 @@ public:
static wxFontEncoding GetDefaultEncoding() { return ms_encodingDefault; }
static void SetDefaultEncoding(wxFontEncoding encoding);
// Account for legacy font weight values: if the argument is one of
// wxNORMAL, wxLIGHT or wxBOLD, return the corresponding wxFONTWEIGHT_XXX
// enum value. Otherwise just return it unchanged.
static int ConvertFromLegacyWeightIfNecessary(int weight);
// Convert between symbolic and numeric font weights. This function uses
// ConvertFromLegacyWeightIfNecessary(), so takes legacy values into
// account as well.
static int GetNumericWeightOf(wxFontWeight weight);
// this doesn't do anything and is kept for compatibility only
#if WXWIN_COMPATIBILITY_2_8
wxDEPRECATED_INLINE(void SetNoAntiAliasing(bool no = true), wxUnusedVar(no);)
wxDEPRECATED_INLINE(bool GetNoAntiAliasing() const, return false;)
#endif // WXWIN_COMPATIBILITY_2_8
wxDEPRECATED_MSG("use wxFONTWEIGHT_XXX constants instead of raw values")
void SetWeight(int weight)
{ SetWeight(static_cast<wxFontWeight>(weight)); }
wxDEPRECATED_MSG("use wxFONTWEIGHT_XXX constants instead of wxLIGHT/wxNORMAL/wxBOLD")
void SetWeight(wxDeprecatedGUIConstants weight)
{ SetWeight(static_cast<wxFontWeight>(weight)); }
// from the font components
wxDEPRECATED_MSG("use wxFONT{FAMILY,STYLE,WEIGHT}_XXX constants")
static wxFont *New(
@@ -479,6 +581,26 @@ protected:
return (flags & wxFONTFLAG_STRIKETHROUGH) != 0;
}
// Create wxFontInfo object from the parameters passed to the legacy wxFont
// ctor/Create() overload. This function implements the compatibility hack
// which interprets wxDEFAULT value of size as meaning -1 and also supports
// specifying wxNORMAL, wxLIGHT and wxBOLD as weight values.
static wxFontInfo InfoFromLegacyParams(int pointSize,
wxFontFamily family,
wxFontStyle style,
wxFontWeight weight,
bool underlined,
const wxString& face,
wxFontEncoding encoding);
static wxFontInfo InfoFromLegacyParams(const wxSize& pixelSize,
wxFontFamily family,
wxFontStyle style,
wxFontWeight weight,
bool underlined,
const wxString& face,
wxFontEncoding encoding);
private:
// the currently default encoding: by default, it's the default system
// encoding, but may be changed by the application using
@@ -500,18 +622,12 @@ WXDLLIMPEXP_CORE bool wxFromString(const wxString& str, wxFontBase* font);
wxDEPRECATED_MSG("use wxFONTSTYLE_XXX constants") \
void SetStyle(int style) \
{ SetStyle((wxFontStyle)style); } \
wxDEPRECATED_MSG("use wxFONTWEIGHT_XXX constants") \
void SetWeight(int weight) \
{ SetWeight((wxFontWeight)weight); } \
wxDEPRECATED_MSG("use wxFONTFAMILY_XXX constants") \
void SetFamily(wxDeprecatedGUIConstants family) \
{ SetFamily((wxFontFamily)family); } \
wxDEPRECATED_MSG("use wxFONTSTYLE_XXX constants") \
void SetStyle(wxDeprecatedGUIConstants style) \
{ SetStyle((wxFontStyle)style); } \
wxDEPRECATED_MSG("use wxFONTWEIGHT_XXX constants") \
void SetWeight(wxDeprecatedGUIConstants weight) \
{ SetWeight((wxFontWeight)weight); } \
\
/* functions for modifying font in place */ \
wxFont& MakeBold(); \

View File

@@ -118,9 +118,14 @@ public:
// set the XFLD
void SetXFontName(const wxString& xFontName);
#elif defined(__WXMSW__)
wxNativeFontInfo(const LOGFONT& lf_) : lf(lf_) { }
wxNativeFontInfo(const LOGFONT& lf_) : lf(lf_), pointSize(0.0f) { }
LOGFONT lf;
// MSW only has limited support for fractional point sizes and we need to
// store the fractional point size separately if it was initially specified
// as we can't losslessly recover it from LOGFONT later.
float pointSize;
#elif defined(__WXOSX__)
public:
wxNativeFontInfo(const wxNativeFontInfo& info) { Init(info); }
@@ -185,10 +190,10 @@ public :
//
#define wxNO_NATIVE_FONTINFO
int pointSize;
float pointSize;
wxFontFamily family;
wxFontStyle style;
wxFontWeight weight;
int weight;
bool underlined;
bool strikethrough;
wxString faceName;
@@ -229,16 +234,16 @@ public:
#else
// translate all font parameters
SetStyle((wxFontStyle)font.GetStyle());
SetWeight((wxFontWeight)font.GetWeight());
SetNumericWeight(font.GetNumericWeight());
SetUnderlined(font.GetUnderlined());
SetStrikethrough(font.GetStrikethrough());
#if defined(__WXMSW__)
if ( font.IsUsingSizeInPixels() )
SetPixelSize(font.GetPixelSize());
else
SetPointSize(font.GetPointSize());
SetFractionalPointSize(font.GetFractionalPointSize());
#else
SetPointSize(font.GetPointSize());
SetFractionalPointSize(font.GetFractionalPointSize());
#endif
// set the family/facename
@@ -268,7 +273,8 @@ public:
wxFontFamily GetFamily() const;
wxFontEncoding GetEncoding() const;
void SetPointSize(float pointsize);
void SetPointSize(int pointsize);
void SetFractionalPointSize(float pointsize);
void SetPixelSize(const wxSize& pixelSize);
void SetStyle(wxFontStyle style);
void SetNumericWeight(int weight);
@@ -279,6 +285,17 @@ public:
void SetFamily(wxFontFamily family);
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
// to be valid. If no valid facename is given, sets the
// first valid facename returned by wxFontEnumerator::GetFacenames().

View File

@@ -66,7 +66,6 @@ public:
// implement base class pure virtuals
virtual float GetFractionalPointSize() const wxOVERRIDE;
virtual wxFontStyle GetStyle() const wxOVERRIDE;
virtual wxFontWeight GetWeight() const wxOVERRIDE;
virtual int GetNumericWeight() const wxOVERRIDE;
virtual wxString GetFaceName() const wxOVERRIDE;
virtual bool GetUnderlined() const wxOVERRIDE;
@@ -75,10 +74,9 @@ public:
virtual const wxNativeFontInfo *GetNativeFontInfo() const wxOVERRIDE;
virtual bool IsFixedWidth() const wxOVERRIDE;
virtual void SetPointSize(float pointSize) wxOVERRIDE;
virtual void SetFractionalPointSize(float pointSize) wxOVERRIDE;
virtual void SetFamily(wxFontFamily family) wxOVERRIDE;
virtual void SetStyle(wxFontStyle style) wxOVERRIDE;
virtual void SetWeight(wxFontWeight weight) wxOVERRIDE;
virtual void SetNumericWeight(int weight) wxOVERRIDE;
virtual bool SetFaceName( const wxString& faceName ) wxOVERRIDE;
virtual void SetUnderlined( bool underlined ) wxOVERRIDE;

View File

@@ -90,19 +90,19 @@ public:
virtual ~wxFont();
// implement base class pure virtuals
virtual int GetPointSize() const;
virtual float GetFractionalPointSize() const;
virtual wxFontStyle GetStyle() const;
virtual wxFontWeight GetWeight() const;
virtual int GetNumericWeight() const;
virtual wxString GetFaceName() const;
virtual bool GetUnderlined() const;
virtual wxFontEncoding GetEncoding() const;
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
virtual bool IsFixedWidth() const;
virtual void SetPointSize( int pointSize );
virtual void SetFractionalPointSize(float pointSize);
virtual void SetFamily(wxFontFamily family);
virtual void SetStyle(wxFontStyle style);
virtual void SetWeight(wxFontWeight weight);
virtual void SetNumericWeight(int weight);
virtual bool SetFaceName( const wxString& faceName );
virtual void SetUnderlined( bool underlined );
virtual void SetEncoding(wxFontEncoding encoding);

View File

@@ -27,19 +27,7 @@ public:
// ctors and such
wxFont() { }
wxFont(const wxFontInfo& info)
{
Create(info.GetPointSize(),
info.GetFamily(),
info.GetStyle(),
info.GetWeight(),
info.IsUnderlined(),
info.GetFaceName(),
info.GetEncoding());
if ( info.IsUsingSizeInPixels() )
SetPixelSize(info.GetPixelSize());
}
wxFont(const wxFontInfo& info);
wxFont(const wxNativeFontInfo& info);
@@ -82,18 +70,18 @@ public:
virtual ~wxFont();
// implement base class pure virtuals
virtual int GetPointSize() const;
virtual float GetFractionalPointSize() const;
virtual wxFontStyle GetStyle() const;
virtual wxFontWeight GetWeight() const;
virtual int GetNumericWeight() const;
virtual bool GetUnderlined() const;
virtual wxString GetFaceName() const;
virtual wxFontEncoding GetEncoding() const;
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
virtual void SetPointSize(int pointSize);
virtual void SetFractionalPointSize(float pointSize);
virtual void SetFamily(wxFontFamily family);
virtual void SetStyle(wxFontStyle style);
virtual void SetWeight(wxFontWeight weight);
virtual void SetNumericWeight(int weight);
virtual bool SetFaceName(const wxString& faceName);
virtual void SetUnderlined(bool underlined);
virtual void SetEncoding(wxFontEncoding encoding);

View File

@@ -44,8 +44,13 @@ public:
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
{
return DoCreate(size, wxDefaultSize, false, family, style,
weight, underlined, face, encoding);
return DoCreate(InfoFromLegacyParams(size,
family,
style,
weight,
underlined,
face,
encoding));
}
wxFont(const wxSize& pixelSize,
@@ -76,8 +81,13 @@ public:
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
{
return DoCreate(-1, pixelSize, true, family, style,
weight, underlined, face, encoding);
return DoCreate(InfoFromLegacyParams(pixelSize,
family,
style,
weight,
underlined,
face,
encoding));
}
bool Create(const wxNativeFontInfo& info, WXHFONT hFont = 0);
@@ -89,7 +99,6 @@ public:
virtual wxSize GetPixelSize() const wxOVERRIDE;
virtual bool IsUsingSizeInPixels() const wxOVERRIDE;
virtual wxFontStyle GetStyle() const wxOVERRIDE;
virtual wxFontWeight GetWeight() const wxOVERRIDE;
virtual int GetNumericWeight() const wxOVERRIDE;
virtual bool GetUnderlined() const wxOVERRIDE;
virtual bool GetStrikethrough() const wxOVERRIDE;
@@ -97,11 +106,10 @@ public:
virtual wxFontEncoding GetEncoding() const wxOVERRIDE;
virtual const wxNativeFontInfo *GetNativeFontInfo() const wxOVERRIDE;
virtual void SetPointSize(float pointSize) wxOVERRIDE;
virtual void SetFractionalPointSize(float pointSize) wxOVERRIDE;
virtual void SetPixelSize(const wxSize& pixelSize) wxOVERRIDE;
virtual void SetFamily(wxFontFamily family) wxOVERRIDE;
virtual void SetStyle(wxFontStyle style) wxOVERRIDE;
virtual void SetWeight(wxFontWeight weight) wxOVERRIDE;
virtual void SetNumericWeight(int weight) wxOVERRIDE;
virtual bool SetFaceName(const wxString& faceName) wxOVERRIDE;
virtual void SetUnderlined(bool underlined) wxOVERRIDE;
@@ -149,16 +157,8 @@ public:
WXHFONT GetHFONT() const;
protected:
// real font creation function, used in all cases
bool DoCreate(int size,
const wxSize& pixelSize,
bool sizeUsingPixels,
wxFontFamily family,
wxFontStyle style,
wxFontWeight weight,
bool underlined = false,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
// Common helper of overloaded Create() methods.
bool DoCreate(const wxFontInfo& info);
virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info) wxOVERRIDE;
virtual wxFontFamily DoGetFamily() const wxOVERRIDE;

View File

@@ -36,19 +36,7 @@ public:
// ctors and such
wxFont() { }
wxFont(const wxFontInfo& info)
{
Create(info.GetPointSize(),
info.GetFamily(),
info.GetStyle(),
info.GetWeight(),
info.IsUnderlined(),
info.GetFaceName(),
info.GetEncoding());
if ( info.IsUsingSizeInPixels() )
SetPixelSize(info.GetPixelSize());
}
wxFont(const wxFontInfo& info);
wxFont( wxOSXSystemFont systemFont );
wxFont(CTFontRef font);
@@ -68,17 +56,6 @@ public:
Create(size, family, style, weight, underlined, face, encoding);
}
wxFont(float size,
wxFontFamily family,
wxFontStyle style,
wxFontWeight weight,
bool underlined = false,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
{
Create(size, family, style, weight, underlined, face, encoding);
}
wxFont(const wxSize& pixelSize,
wxFontFamily family,
wxFontStyle style,
@@ -99,14 +76,6 @@ public:
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
bool Create(float size,
wxFontFamily family,
wxFontStyle style,
wxFontWeight weight,
bool underlined = false,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
wxFont(const wxNativeFontInfo& info)
{
(void)Create(info);
@@ -122,7 +91,6 @@ public:
virtual float GetFractionalPointSize() const wxOVERRIDE;
virtual wxSize GetPixelSize() const wxOVERRIDE;
virtual wxFontStyle GetStyle() const wxOVERRIDE;
virtual wxFontWeight GetWeight() const wxOVERRIDE;
virtual int GetNumericWeight() const wxOVERRIDE;
virtual bool GetUnderlined() const wxOVERRIDE;
virtual bool GetStrikethrough() const wxOVERRIDE;
@@ -132,10 +100,9 @@ public:
virtual bool IsFixedWidth() const wxOVERRIDE;
virtual void SetPointSize(float pointSize) wxOVERRIDE;
virtual void SetFractionalPointSize(float pointSize) wxOVERRIDE;
virtual void SetFamily(wxFontFamily family) wxOVERRIDE;
virtual void SetStyle(wxFontStyle style) wxOVERRIDE;
virtual void SetWeight(wxFontWeight weight) wxOVERRIDE;
virtual void SetNumericWeight(int weight) wxOVERRIDE;
virtual bool SetFaceName(const wxString& faceName) wxOVERRIDE;
virtual void SetUnderlined(bool underlined) wxOVERRIDE;

View File

@@ -204,7 +204,7 @@ public:
wxFontMgrFontRefData(int size = wxDEFAULT,
wxFontFamily family = wxFONTFAMILY_DEFAULT,
wxFontStyle style = wxFONTSTYLE_NORMAL,
wxFontWeight weight = wxFONTWEIGHT_NORMAL,
int weight = wxFONTWEIGHT_NORMAL,
bool underlined = false,
const wxString& faceName = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
@@ -218,18 +218,18 @@ public:
const wxNativeFontInfo *GetNativeFontInfo() const { return &m_info; }
int GetPointSize() const { return m_info.pointSize; }
float GetFractionalPointSize() const { return m_info.pointSize; }
wxString GetFaceName() const { return m_info.faceName; }
wxFontFamily GetFamily() const { return m_info.family; }
wxFontStyle GetStyle() const { return m_info.style; }
wxFontWeight GetWeight() const { return m_info.weight; }
int GetNumericWeight() const { return m_info.weight; }
bool GetUnderlined() const { return m_info.underlined; }
wxFontEncoding GetEncoding() const { return m_info.encoding; }
void SetPointSize(int pointSize);
void SetFractionalPointSize(float pointSize);
void SetFamily(wxFontFamily family);
void SetStyle(wxFontStyle style);
void SetWeight(wxFontWeight weight);
void SetNumericWeight(int weight);
void SetFaceName(const wxString& faceName);
void SetUnderlined(bool underlined);
void SetEncoding(wxFontEncoding encoding);

View File

@@ -135,7 +135,9 @@ public:
font, &wxFont::SetUnderlined,
false, true);
// TODO: No support for strike-through yet.
FontModifier<bool>()(spanAttr.m_isStrikethrough,
font, &wxFont::SetStrikethrough,
false, true);
switch ( spanAttr.m_sizeKind )
{
@@ -159,7 +161,7 @@ public:
break;
case wxMarkupSpanAttributes::Size_PointParts:
font.SetPointSize((spanAttr.m_fontSize + 1023)/1024);
font.SetFractionalPointSize(spanAttr.m_fontSize/1024.);
break;
}

View File

@@ -32,6 +32,7 @@ public:
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
wxDEPRECATED_MSG("use wxFONT{FAMILY,STYLE,WEIGHT}_XXX constants")
wxFont(int size,
int family,
int style,
@@ -49,20 +50,20 @@ public:
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
// accessors: get the font characteristics
virtual int GetPointSize() const;
virtual float GetFractionalPointSize() const wxOVERRIDE;
virtual wxFontStyle GetStyle() const;
virtual wxFontWeight GetWeight() const;
virtual int GetNumericWeight() const wxOVERRIDE;
virtual bool GetUnderlined() const;
virtual wxString GetFaceName() const;
virtual wxFontEncoding GetEncoding() const;
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
// change the font characteristics
virtual void SetPointSize( int pointSize );
virtual void SetFractionalPointSize(float pointSize) wxOVERRIDE;
virtual void SetFamily( wxFontFamily family );
virtual void SetStyle( wxFontStyle style );
virtual void SetNumericWeight(int weight) wxOVERRIDE;
virtual bool SetFaceName(const wxString& facename);
virtual void SetWeight( wxFontWeight weight );
virtual void SetUnderlined( bool underlined );
virtual void SetEncoding(wxFontEncoding encoding);

View File

@@ -21,10 +21,10 @@
// returns the handle of the nearest available font or 0
extern wxNativeFont
wxLoadQueryNearestFont(int pointSize,
wxLoadQueryNearestFont(float pointSize,
wxFontFamily family,
wxFontStyle style,
wxFontWeight weight,
int weight,
bool underlined,
const wxString &facename,
wxFontEncoding encoding,

View File

@@ -81,9 +81,9 @@ public:
virtual ~wxFont();
// implement base class pure virtuals
virtual int GetPointSize() const;
virtual float GetFractionalPointSize() const;
virtual wxFontStyle GetStyle() const;
virtual wxFontWeight GetWeight() const;
virtual int GetNumericWeight() const;
virtual bool GetUnderlined() const;
virtual bool GetStrikethrough() const wxOVERRIDE;
virtual wxString GetFaceName() const;
@@ -92,10 +92,10 @@ public:
virtual bool IsFixedWidth() const;
virtual void SetPointSize(int pointSize);
virtual void SetFractionalPointSize(float pointSize);
virtual void SetFamily(wxFontFamily family);
virtual void SetStyle(wxFontStyle style);
virtual void SetWeight(wxFontWeight weight);
virtual void SetNumericWeight(int weight);
virtual bool SetFaceName(const wxString& faceName);
virtual void SetUnderlined(bool underlined);
virtual void SetStrikethrough(bool strikethrough) wxOVERRIDE;