Change fractional point size from float to double
There doesn't seem to be any compelling reason to use float. Using double is simpler, and avoids otherwise unnecessary float<->double conversions.
This commit is contained in:
@@ -74,7 +74,7 @@ public:
|
|||||||
bool Create(const wxNativeFontInfo& fontinfo);
|
bool Create(const wxNativeFontInfo& fontinfo);
|
||||||
|
|
||||||
// implement base class pure virtuals
|
// implement base class pure virtuals
|
||||||
virtual float GetFractionalPointSize() const;
|
virtual double GetFractionalPointSize() const;
|
||||||
virtual wxFontStyle GetStyle() const;
|
virtual wxFontStyle GetStyle() const;
|
||||||
virtual int GetNumericWeight() const;
|
virtual int GetNumericWeight() const;
|
||||||
virtual wxString GetFaceName() const;
|
virtual wxString GetFaceName() const;
|
||||||
@@ -83,7 +83,7 @@ public:
|
|||||||
virtual bool IsFixedWidth() const;
|
virtual bool IsFixedWidth() const;
|
||||||
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
|
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
|
||||||
|
|
||||||
virtual void SetFractionalPointSize(float pointSize);
|
virtual void SetFractionalPointSize(double pointSize);
|
||||||
virtual void SetFamily(wxFontFamily family);
|
virtual void SetFamily(wxFontFamily family);
|
||||||
virtual void SetStyle(wxFontStyle style);
|
virtual void SetStyle(wxFontStyle style);
|
||||||
virtual void SetNumericWeight(int weight);
|
virtual void SetNumericWeight(int weight);
|
||||||
|
@@ -129,22 +129,28 @@ public:
|
|||||||
// Default ctor uses the default font size appropriate for the current
|
// Default ctor uses the default font size appropriate for the current
|
||||||
// platform.
|
// platform.
|
||||||
wxFontInfo()
|
wxFontInfo()
|
||||||
{ InitPointSize(-1.0f); }
|
: m_pointSize(-1.0)
|
||||||
|
, m_pixelSize(wxDefaultSize)
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
|
||||||
// These ctors specify the font size, either in points or in pixels.
|
// These ctors specify the font size, either in points or in pixels.
|
||||||
// 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)
|
explicit wxFontInfo(double pointSize)
|
||||||
{ InitPointSize(static_cast<float>(pointSize)); }
|
: m_pointSize(pointSize >= 0.0 ? pointSize : -1.0)
|
||||||
template <typename T>
|
, m_pixelSize(wxDefaultSize)
|
||||||
explicit wxFontInfo(T pointSize)
|
{
|
||||||
{ InitPointSize(ToFloatPointSize(pointSize)); }
|
Init();
|
||||||
|
if (!wxIsSameDouble(m_pointSize, pointSize))
|
||||||
|
wxFAIL_MSG("Invalid font point size");
|
||||||
|
}
|
||||||
|
explicit wxFontInfo(const wxSize& pixelSize)
|
||||||
|
: m_pointSize(-1.0)
|
||||||
|
, m_pixelSize(pixelSize)
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
}
|
||||||
|
// Default copy ctor, assignment operator and dtor are OK
|
||||||
|
|
||||||
// Setters for the various attributes. All of them return the object itself
|
// Setters for the various attributes. All of them return the object itself
|
||||||
// so that the calls to them could be chained.
|
// so that the calls to them could be chained.
|
||||||
@@ -185,7 +191,6 @@ public:
|
|||||||
wxFontInfo& Encoding(wxFontEncoding encoding)
|
wxFontInfo& Encoding(wxFontEncoding encoding)
|
||||||
{ m_encoding = encoding; return *this; }
|
{ m_encoding = encoding; return *this; }
|
||||||
|
|
||||||
|
|
||||||
// Set all flags at once.
|
// Set all flags at once.
|
||||||
wxFontInfo& AllFlags(int flags)
|
wxFontInfo& AllFlags(int flags)
|
||||||
{
|
{
|
||||||
@@ -200,13 +205,12 @@ public:
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Accessors are mostly meant to be used by wxFont itself to extract the
|
// Accessors are mostly meant to be used by wxFont itself to extract the
|
||||||
// various pieces of the font description.
|
// various pieces of the font description.
|
||||||
|
|
||||||
bool IsUsingSizeInPixels() const { return m_pixelSize != wxDefaultSize; }
|
bool IsUsingSizeInPixels() const { return m_pixelSize != wxDefaultSize; }
|
||||||
float GetFractionalPointSize() const { return m_pointSize; }
|
double GetFractionalPointSize() const { return m_pointSize; }
|
||||||
int GetPointSize() const { return ToIntPointSize(m_pointSize); }
|
int GetPointSize() const { return wxRound(m_pointSize); }
|
||||||
wxSize GetPixelSize() const { return m_pixelSize; }
|
wxSize GetPixelSize() const { return m_pixelSize; }
|
||||||
|
|
||||||
// If face name is not empty, it has priority, otherwise use family.
|
// If face name is not empty, it has priority, otherwise use family.
|
||||||
@@ -250,28 +254,6 @@ public:
|
|||||||
|
|
||||||
wxFontEncoding GetEncoding() const { return m_encoding; }
|
wxFontEncoding GetEncoding() const { return m_encoding; }
|
||||||
|
|
||||||
|
|
||||||
// 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
|
// Another helper for converting arbitrary numeric weight to the closest
|
||||||
// value of wxFontWeight enum. It should be avoided in the new code (also
|
// 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
|
// note that the function for the conversion in the other direction is
|
||||||
@@ -296,21 +278,12 @@ public:
|
|||||||
private:
|
private:
|
||||||
void Init()
|
void Init()
|
||||||
{
|
{
|
||||||
m_pointSize = -1;
|
|
||||||
m_family = wxFONTFAMILY_DEFAULT;
|
m_family = wxFONTFAMILY_DEFAULT;
|
||||||
m_flags = wxFONTFLAG_DEFAULT;
|
m_flags = wxFONTFLAG_DEFAULT;
|
||||||
m_weight = wxFONTWEIGHT_NORMAL;
|
m_weight = wxFONTWEIGHT_NORMAL;
|
||||||
m_encoding = wxFONTENCODING_DEFAULT;
|
m_encoding = wxFONTENCODING_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitPointSize(float pointSize)
|
|
||||||
{
|
|
||||||
Init();
|
|
||||||
|
|
||||||
m_pointSize = pointSize;
|
|
||||||
m_pixelSize = wxDefaultSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Turn on or off the given bit in m_flags depending on the value of the
|
// Turn on or off the given bit in m_flags depending on the value of the
|
||||||
// boolean argument.
|
// boolean argument.
|
||||||
void SetFlag(int flag, bool on)
|
void SetFlag(int flag, bool on)
|
||||||
@@ -324,7 +297,7 @@ private:
|
|||||||
// The size information: if m_pixelSize is valid (!= wxDefaultSize), then
|
// The size information: if m_pixelSize is valid (!= wxDefaultSize), then
|
||||||
// it is used. Otherwise m_pointSize is used, except if it is < 0, which
|
// 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.
|
// means that the platform dependent font size should be used instead.
|
||||||
float m_pointSize;
|
double m_pointSize;
|
||||||
wxSize m_pixelSize;
|
wxSize m_pixelSize;
|
||||||
|
|
||||||
wxFontFamily m_family;
|
wxFontFamily m_family;
|
||||||
@@ -425,7 +398,7 @@ public:
|
|||||||
|
|
||||||
// accessors: get the font characteristics
|
// accessors: get the font characteristics
|
||||||
virtual int GetPointSize() const;
|
virtual int GetPointSize() const;
|
||||||
virtual float GetFractionalPointSize() const = 0;
|
virtual double GetFractionalPointSize() const = 0;
|
||||||
virtual wxSize GetPixelSize() const;
|
virtual wxSize GetPixelSize() const;
|
||||||
virtual bool IsUsingSizeInPixels() const;
|
virtual bool IsUsingSizeInPixels() const;
|
||||||
wxFontFamily GetFamily() const;
|
wxFontFamily GetFamily() const;
|
||||||
@@ -447,7 +420,7 @@ public:
|
|||||||
|
|
||||||
// change the font characteristics
|
// change the font characteristics
|
||||||
virtual void SetPointSize( int pointSize );
|
virtual void SetPointSize( int pointSize );
|
||||||
virtual void SetFractionalPointSize( float pointSize ) = 0;
|
virtual void SetFractionalPointSize( double pointSize ) = 0;
|
||||||
virtual void SetPixelSize( const wxSize& pixelSize );
|
virtual void SetPixelSize( const wxSize& pixelSize );
|
||||||
virtual void SetFamily( wxFontFamily family ) = 0;
|
virtual void SetFamily( wxFontFamily family ) = 0;
|
||||||
virtual void SetStyle( wxFontStyle style ) = 0;
|
virtual void SetStyle( wxFontStyle style ) = 0;
|
||||||
|
@@ -132,18 +132,18 @@ public:
|
|||||||
|
|
||||||
// MSW-specific: get point size from LOGFONT height using specified DPI,
|
// MSW-specific: get point size from LOGFONT height using specified DPI,
|
||||||
// or screen DPI when 0.
|
// or screen DPI when 0.
|
||||||
static float GetPointSizeAtPPI(int lfHeight, int ppi = 0);
|
static double GetPointSizeAtPPI(int lfHeight, int ppi = 0);
|
||||||
|
|
||||||
// MSW-specific: get the height value in pixels using LOGFONT convention
|
// MSW-specific: get the height value in pixels using LOGFONT convention
|
||||||
// (i.e. negative) corresponding to the given size in points and DPI.
|
// (i.e. negative) corresponding to the given size in points and DPI.
|
||||||
static int GetLogFontHeightAtPPI(float size, int ppi);
|
static int GetLogFontHeightAtPPI(double size, int ppi);
|
||||||
|
|
||||||
LOGFONT lf;
|
LOGFONT lf;
|
||||||
|
|
||||||
// MSW only has limited support for fractional point sizes and we need to
|
// MSW only has limited support for fractional point sizes and we need to
|
||||||
// store the fractional point size separately if it was initially specified
|
// store the fractional point size separately if it was initially specified
|
||||||
// as we can't losslessly recover it from LOGFONT later.
|
// as we can't losslessly recover it from LOGFONT later.
|
||||||
float pointSize;
|
double pointSize;
|
||||||
#elif defined(__WXOSX__)
|
#elif defined(__WXOSX__)
|
||||||
public:
|
public:
|
||||||
wxNativeFontInfo(const wxNativeFontInfo& info) { Init(info); }
|
wxNativeFontInfo(const wxNativeFontInfo& info) { Init(info); }
|
||||||
@@ -208,7 +208,7 @@ public :
|
|||||||
//
|
//
|
||||||
#define wxNO_NATIVE_FONTINFO
|
#define wxNO_NATIVE_FONTINFO
|
||||||
|
|
||||||
float pointSize;
|
double pointSize;
|
||||||
wxFontFamily family;
|
wxFontFamily family;
|
||||||
wxFontStyle style;
|
wxFontStyle style;
|
||||||
int weight;
|
int weight;
|
||||||
@@ -280,7 +280,7 @@ public:
|
|||||||
|
|
||||||
// accessors and modifiers for the font elements
|
// accessors and modifiers for the font elements
|
||||||
int GetPointSize() const;
|
int GetPointSize() const;
|
||||||
float GetFractionalPointSize() const;
|
double GetFractionalPointSize() const;
|
||||||
wxSize GetPixelSize() const;
|
wxSize GetPixelSize() const;
|
||||||
wxFontStyle GetStyle() const;
|
wxFontStyle GetStyle() const;
|
||||||
wxFontWeight GetWeight() const;
|
wxFontWeight GetWeight() const;
|
||||||
@@ -292,7 +292,7 @@ public:
|
|||||||
wxFontEncoding GetEncoding() const;
|
wxFontEncoding GetEncoding() const;
|
||||||
|
|
||||||
void SetPointSize(int pointsize);
|
void SetPointSize(int pointsize);
|
||||||
void SetFractionalPointSize(float pointsize);
|
void SetFractionalPointSize(double pointsize);
|
||||||
void SetPixelSize(const wxSize& pixelSize);
|
void SetPixelSize(const wxSize& pixelSize);
|
||||||
void SetStyle(wxFontStyle style);
|
void SetStyle(wxFontStyle style);
|
||||||
void SetNumericWeight(int weight);
|
void SetNumericWeight(int weight);
|
||||||
@@ -305,7 +305,7 @@ public:
|
|||||||
|
|
||||||
// Helper used in many ports: use the normal font size if the input is
|
// Helper used in many ports: use the normal font size if the input is
|
||||||
// negative, as we handle -1 as meaning this for compatibility.
|
// negative, as we handle -1 as meaning this for compatibility.
|
||||||
void SetSizeOrDefault(float size)
|
void SetSizeOrDefault(double size)
|
||||||
{
|
{
|
||||||
SetFractionalPointSize
|
SetFractionalPointSize
|
||||||
(
|
(
|
||||||
|
@@ -64,7 +64,7 @@ public:
|
|||||||
virtual ~wxFont();
|
virtual ~wxFont();
|
||||||
|
|
||||||
// implement base class pure virtuals
|
// implement base class pure virtuals
|
||||||
virtual float GetFractionalPointSize() const wxOVERRIDE;
|
virtual double GetFractionalPointSize() const wxOVERRIDE;
|
||||||
virtual wxFontStyle GetStyle() const wxOVERRIDE;
|
virtual wxFontStyle GetStyle() const wxOVERRIDE;
|
||||||
virtual int GetNumericWeight() const wxOVERRIDE;
|
virtual int GetNumericWeight() const wxOVERRIDE;
|
||||||
virtual wxString GetFaceName() const wxOVERRIDE;
|
virtual wxString GetFaceName() const wxOVERRIDE;
|
||||||
@@ -74,7 +74,7 @@ public:
|
|||||||
virtual const wxNativeFontInfo *GetNativeFontInfo() const wxOVERRIDE;
|
virtual const wxNativeFontInfo *GetNativeFontInfo() const wxOVERRIDE;
|
||||||
virtual bool IsFixedWidth() const wxOVERRIDE;
|
virtual bool IsFixedWidth() const wxOVERRIDE;
|
||||||
|
|
||||||
virtual void SetFractionalPointSize(float pointSize) wxOVERRIDE;
|
virtual void SetFractionalPointSize(double pointSize) wxOVERRIDE;
|
||||||
virtual void SetFamily(wxFontFamily family) wxOVERRIDE;
|
virtual void SetFamily(wxFontFamily family) wxOVERRIDE;
|
||||||
virtual void SetStyle(wxFontStyle style) wxOVERRIDE;
|
virtual void SetStyle(wxFontStyle style) wxOVERRIDE;
|
||||||
virtual void SetNumericWeight(int weight) wxOVERRIDE;
|
virtual void SetNumericWeight(int weight) wxOVERRIDE;
|
||||||
|
@@ -90,7 +90,7 @@ public:
|
|||||||
virtual ~wxFont();
|
virtual ~wxFont();
|
||||||
|
|
||||||
// implement base class pure virtuals
|
// implement base class pure virtuals
|
||||||
virtual float GetFractionalPointSize() const;
|
virtual double GetFractionalPointSize() const;
|
||||||
virtual wxFontStyle GetStyle() const;
|
virtual wxFontStyle GetStyle() const;
|
||||||
virtual int GetNumericWeight() const;
|
virtual int GetNumericWeight() const;
|
||||||
virtual wxString GetFaceName() const;
|
virtual wxString GetFaceName() const;
|
||||||
@@ -99,7 +99,7 @@ public:
|
|||||||
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
|
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
|
||||||
virtual bool IsFixedWidth() const;
|
virtual bool IsFixedWidth() const;
|
||||||
|
|
||||||
virtual void SetFractionalPointSize(float pointSize);
|
virtual void SetFractionalPointSize(double pointSize);
|
||||||
virtual void SetFamily(wxFontFamily family);
|
virtual void SetFamily(wxFontFamily family);
|
||||||
virtual void SetStyle(wxFontStyle style);
|
virtual void SetStyle(wxFontStyle style);
|
||||||
virtual void SetNumericWeight(int weight);
|
virtual void SetNumericWeight(int weight);
|
||||||
|
@@ -72,7 +72,7 @@ public:
|
|||||||
virtual ~wxFont();
|
virtual ~wxFont();
|
||||||
|
|
||||||
// implement base class pure virtuals
|
// implement base class pure virtuals
|
||||||
virtual float GetFractionalPointSize() const;
|
virtual double GetFractionalPointSize() const;
|
||||||
virtual wxFontStyle GetStyle() const;
|
virtual wxFontStyle GetStyle() const;
|
||||||
virtual int GetNumericWeight() const;
|
virtual int GetNumericWeight() const;
|
||||||
virtual bool GetUnderlined() const;
|
virtual bool GetUnderlined() const;
|
||||||
@@ -80,7 +80,7 @@ public:
|
|||||||
virtual wxFontEncoding GetEncoding() const;
|
virtual wxFontEncoding GetEncoding() const;
|
||||||
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
|
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
|
||||||
|
|
||||||
virtual void SetFractionalPointSize(float pointSize);
|
virtual void SetFractionalPointSize(double pointSize);
|
||||||
virtual void SetFamily(wxFontFamily family);
|
virtual void SetFamily(wxFontFamily family);
|
||||||
virtual void SetStyle(wxFontStyle style);
|
virtual void SetStyle(wxFontStyle style);
|
||||||
virtual void SetNumericWeight(int weight);
|
virtual void SetNumericWeight(int weight);
|
||||||
|
@@ -95,7 +95,7 @@ public:
|
|||||||
virtual ~wxFont();
|
virtual ~wxFont();
|
||||||
|
|
||||||
// implement base class pure virtuals
|
// implement base class pure virtuals
|
||||||
virtual float GetFractionalPointSize() const wxOVERRIDE;
|
virtual double GetFractionalPointSize() const wxOVERRIDE;
|
||||||
virtual wxSize GetPixelSize() const wxOVERRIDE;
|
virtual wxSize GetPixelSize() const wxOVERRIDE;
|
||||||
virtual bool IsUsingSizeInPixels() const wxOVERRIDE;
|
virtual bool IsUsingSizeInPixels() const wxOVERRIDE;
|
||||||
virtual wxFontStyle GetStyle() const wxOVERRIDE;
|
virtual wxFontStyle GetStyle() const wxOVERRIDE;
|
||||||
@@ -106,7 +106,7 @@ public:
|
|||||||
virtual wxFontEncoding GetEncoding() const wxOVERRIDE;
|
virtual wxFontEncoding GetEncoding() const wxOVERRIDE;
|
||||||
virtual const wxNativeFontInfo *GetNativeFontInfo() const wxOVERRIDE;
|
virtual const wxNativeFontInfo *GetNativeFontInfo() const wxOVERRIDE;
|
||||||
|
|
||||||
virtual void SetFractionalPointSize(float pointSize) wxOVERRIDE;
|
virtual void SetFractionalPointSize(double pointSize) wxOVERRIDE;
|
||||||
virtual void SetPixelSize(const wxSize& pixelSize) wxOVERRIDE;
|
virtual void SetPixelSize(const wxSize& pixelSize) wxOVERRIDE;
|
||||||
virtual void SetFamily(wxFontFamily family) wxOVERRIDE;
|
virtual void SetFamily(wxFontFamily family) wxOVERRIDE;
|
||||||
virtual void SetStyle(wxFontStyle style) wxOVERRIDE;
|
virtual void SetStyle(wxFontStyle style) wxOVERRIDE;
|
||||||
|
@@ -88,7 +88,7 @@ public:
|
|||||||
virtual ~wxFont();
|
virtual ~wxFont();
|
||||||
|
|
||||||
// implement base class pure virtuals
|
// implement base class pure virtuals
|
||||||
virtual float GetFractionalPointSize() const wxOVERRIDE;
|
virtual double GetFractionalPointSize() const wxOVERRIDE;
|
||||||
virtual wxSize GetPixelSize() const wxOVERRIDE;
|
virtual wxSize GetPixelSize() const wxOVERRIDE;
|
||||||
virtual wxFontStyle GetStyle() const wxOVERRIDE;
|
virtual wxFontStyle GetStyle() const wxOVERRIDE;
|
||||||
virtual int GetNumericWeight() const wxOVERRIDE;
|
virtual int GetNumericWeight() const wxOVERRIDE;
|
||||||
@@ -100,7 +100,7 @@ public:
|
|||||||
|
|
||||||
virtual bool IsFixedWidth() const wxOVERRIDE;
|
virtual bool IsFixedWidth() const wxOVERRIDE;
|
||||||
|
|
||||||
virtual void SetFractionalPointSize(float pointSize) wxOVERRIDE;
|
virtual void SetFractionalPointSize(double pointSize) wxOVERRIDE;
|
||||||
virtual void SetFamily(wxFontFamily family) wxOVERRIDE;
|
virtual void SetFamily(wxFontFamily family) wxOVERRIDE;
|
||||||
virtual void SetStyle(wxFontStyle style) wxOVERRIDE;
|
virtual void SetStyle(wxFontStyle style) wxOVERRIDE;
|
||||||
virtual void SetNumericWeight(int weight) wxOVERRIDE;
|
virtual void SetNumericWeight(int weight) wxOVERRIDE;
|
||||||
|
@@ -218,7 +218,7 @@ public:
|
|||||||
|
|
||||||
const wxNativeFontInfo *GetNativeFontInfo() const { return &m_info; }
|
const wxNativeFontInfo *GetNativeFontInfo() const { return &m_info; }
|
||||||
|
|
||||||
float GetFractionalPointSize() const { return m_info.pointSize; }
|
double GetFractionalPointSize() const { return m_info.pointSize; }
|
||||||
wxString GetFaceName() const { return m_info.faceName; }
|
wxString GetFaceName() const { return m_info.faceName; }
|
||||||
wxFontFamily GetFamily() const { return m_info.family; }
|
wxFontFamily GetFamily() const { return m_info.family; }
|
||||||
wxFontStyle GetStyle() const { return m_info.style; }
|
wxFontStyle GetStyle() const { return m_info.style; }
|
||||||
@@ -226,7 +226,7 @@ public:
|
|||||||
bool GetUnderlined() const { return m_info.underlined; }
|
bool GetUnderlined() const { return m_info.underlined; }
|
||||||
wxFontEncoding GetEncoding() const { return m_info.encoding; }
|
wxFontEncoding GetEncoding() const { return m_info.encoding; }
|
||||||
|
|
||||||
void SetFractionalPointSize(float pointSize);
|
void SetFractionalPointSize(double pointSize);
|
||||||
void SetFamily(wxFontFamily family);
|
void SetFamily(wxFontFamily family);
|
||||||
void SetStyle(wxFontStyle style);
|
void SetStyle(wxFontStyle style);
|
||||||
void SetNumericWeight(int weight);
|
void SetNumericWeight(int weight);
|
||||||
|
@@ -51,7 +51,7 @@ public:
|
|||||||
|
|
||||||
// accessors: get the font characteristics
|
// accessors: get the font characteristics
|
||||||
virtual int GetPointSize() const wxOVERRIDE;
|
virtual int GetPointSize() const wxOVERRIDE;
|
||||||
virtual float GetFractionalPointSize() const wxOVERRIDE;
|
virtual double GetFractionalPointSize() const wxOVERRIDE;
|
||||||
virtual wxSize GetPixelSize() const wxOVERRIDE;
|
virtual wxSize GetPixelSize() const wxOVERRIDE;
|
||||||
virtual wxFontStyle GetStyle() const wxOVERRIDE;
|
virtual wxFontStyle GetStyle() const wxOVERRIDE;
|
||||||
virtual int GetNumericWeight() const wxOVERRIDE;
|
virtual int GetNumericWeight() const wxOVERRIDE;
|
||||||
@@ -62,7 +62,7 @@ public:
|
|||||||
virtual bool GetStrikethrough() const wxOVERRIDE;
|
virtual bool GetStrikethrough() const wxOVERRIDE;
|
||||||
|
|
||||||
// change the font characteristics
|
// change the font characteristics
|
||||||
virtual void SetFractionalPointSize(float pointSize) wxOVERRIDE;
|
virtual void SetFractionalPointSize(double pointSize) wxOVERRIDE;
|
||||||
virtual void SetPixelSize(const wxSize& pixelSize) wxOVERRIDE;
|
virtual void SetPixelSize(const wxSize& pixelSize) wxOVERRIDE;
|
||||||
virtual void SetFamily( wxFontFamily family ) wxOVERRIDE;
|
virtual void SetFamily( wxFontFamily family ) wxOVERRIDE;
|
||||||
virtual void SetStyle( wxFontStyle style ) wxOVERRIDE;
|
virtual void SetStyle( wxFontStyle style ) wxOVERRIDE;
|
||||||
|
@@ -21,7 +21,7 @@
|
|||||||
|
|
||||||
// returns the handle of the nearest available font or 0
|
// returns the handle of the nearest available font or 0
|
||||||
extern wxNativeFont
|
extern wxNativeFont
|
||||||
wxLoadQueryNearestFont(float pointSize,
|
wxLoadQueryNearestFont(double pointSize,
|
||||||
wxFontFamily family,
|
wxFontFamily family,
|
||||||
wxFontStyle style,
|
wxFontStyle style,
|
||||||
int weight,
|
int weight,
|
||||||
|
@@ -81,7 +81,7 @@ public:
|
|||||||
virtual ~wxFont();
|
virtual ~wxFont();
|
||||||
|
|
||||||
// implement base class pure virtuals
|
// implement base class pure virtuals
|
||||||
virtual float GetFractionalPointSize() const;
|
virtual double GetFractionalPointSize() const;
|
||||||
virtual wxFontStyle GetStyle() const;
|
virtual wxFontStyle GetStyle() const;
|
||||||
virtual int GetNumericWeight() const;
|
virtual int GetNumericWeight() const;
|
||||||
virtual bool GetUnderlined() const;
|
virtual bool GetUnderlined() const;
|
||||||
@@ -92,7 +92,7 @@ public:
|
|||||||
|
|
||||||
virtual bool IsFixedWidth() const;
|
virtual bool IsFixedWidth() const;
|
||||||
|
|
||||||
virtual void SetFractionalPointSize(float pointSize);
|
virtual void SetFractionalPointSize(double pointSize);
|
||||||
virtual void SetFamily(wxFontFamily family);
|
virtual void SetFamily(wxFontFamily family);
|
||||||
virtual void SetStyle(wxFontStyle style);
|
virtual void SetStyle(wxFontStyle style);
|
||||||
virtual void SetNumericWeight(int weight);
|
virtual void SetNumericWeight(int weight);
|
||||||
|
@@ -322,16 +322,12 @@ public:
|
|||||||
/**
|
/**
|
||||||
Constructor setting the font size in points to use.
|
Constructor setting the font size in points to use.
|
||||||
|
|
||||||
The canonical type of @a pointSize argument is @c float, however any
|
Note that until wxWidgets 3.1.2 fractional point sizes were not
|
||||||
other integer type, as well as @c double, is also accepted for
|
supported, and the type of @a pointSize was @c int.
|
||||||
compatibility.
|
|
||||||
|
|
||||||
Notice that until wxWidgets 3.1.2, the type could only be @c int.
|
|
||||||
|
|
||||||
@see wxFont::SetPointSize()
|
@see wxFont::SetPointSize()
|
||||||
*/
|
*/
|
||||||
template <typename T>
|
explicit wxFontInfo(double pointSize);
|
||||||
explicit wxFontInfo(T pointSize);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Constructor setting the font size in pixels to use.
|
Constructor setting the font size in pixels to use.
|
||||||
@@ -786,7 +782,7 @@ public:
|
|||||||
|
|
||||||
@since 3.1.2
|
@since 3.1.2
|
||||||
*/
|
*/
|
||||||
virtual float GetFractionalPointSize() const;
|
virtual double GetFractionalPointSize() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Gets the pixel size.
|
Gets the pixel size.
|
||||||
@@ -1139,7 +1135,7 @@ public:
|
|||||||
|
|
||||||
@since 3.1.2
|
@since 3.1.2
|
||||||
*/
|
*/
|
||||||
virtual void SetFractionalPointSize(float pointSize);
|
virtual void SetFractionalPointSize(double pointSize);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sets the pixel size.
|
Sets the pixel size.
|
||||||
|
@@ -44,8 +44,6 @@
|
|||||||
|
|
||||||
#include "wx/tokenzr.h"
|
#include "wx/tokenzr.h"
|
||||||
|
|
||||||
#include <float.h> // for FLT_MAX
|
|
||||||
|
|
||||||
// debugger helper: this function can be called from a debugger to show what
|
// debugger helper: this function can be called from a debugger to show what
|
||||||
// the date really is
|
// the date really is
|
||||||
extern const char *wxDumpFont(const wxFont *font)
|
extern const char *wxDumpFont(const wxFont *font)
|
||||||
@@ -254,7 +252,7 @@ int wxFontBase::GetNumericWeightOf(wxFontWeight weight_)
|
|||||||
|
|
||||||
int wxFontBase::GetPointSize() const
|
int wxFontBase::GetPointSize() const
|
||||||
{
|
{
|
||||||
return wxFontInfo::ToIntPointSize(GetFractionalPointSize());
|
return wxRound(GetFractionalPointSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -279,7 +277,7 @@ bool wxFontBase::IsUsingSizeInPixels() const
|
|||||||
|
|
||||||
void wxFontBase::SetPointSize(int pointSize)
|
void wxFontBase::SetPointSize(int pointSize)
|
||||||
{
|
{
|
||||||
SetFractionalPointSize(wxFontInfo::ToFloatPointSize(pointSize));
|
SetFractionalPointSize(pointSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFontBase::SetPixelSize( const wxSize& pixelSize )
|
void wxFontBase::SetPixelSize( const wxSize& pixelSize )
|
||||||
@@ -688,7 +686,7 @@ wxFont& wxFont::MakeStrikethrough()
|
|||||||
|
|
||||||
wxFont& wxFont::Scale(float x)
|
wxFont& wxFont::Scale(float x)
|
||||||
{
|
{
|
||||||
SetFractionalPointSize(x*GetFractionalPointSize());
|
SetFractionalPointSize(double(x) * GetFractionalPointSize());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -727,12 +725,12 @@ void wxNativeFontInfo::SetFaceName(const wxArrayString& facenames)
|
|||||||
|
|
||||||
int wxNativeFontInfo::GetPointSize() const
|
int wxNativeFontInfo::GetPointSize() const
|
||||||
{
|
{
|
||||||
return wxFontInfo::ToIntPointSize(GetFractionalPointSize());
|
return wxRound(GetFractionalPointSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxNativeFontInfo::SetPointSize(int pointsize)
|
void wxNativeFontInfo::SetPointSize(int pointsize)
|
||||||
{
|
{
|
||||||
SetFractionalPointSize(wxFontInfo::ToFloatPointSize(pointsize));
|
SetFractionalPointSize(pointsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef wxNO_NATIVE_FONTINFO
|
#ifdef wxNO_NATIVE_FONTINFO
|
||||||
@@ -760,9 +758,9 @@ bool wxNativeFontInfo::FromString(const wxString& s)
|
|||||||
token = tokenizer.GetNextToken();
|
token = tokenizer.GetNextToken();
|
||||||
if ( !token.ToCDouble(&d) )
|
if ( !token.ToCDouble(&d) )
|
||||||
return false;
|
return false;
|
||||||
if ( d < 0 || d > FLT_MAX )
|
if ( d < 0 )
|
||||||
return false;
|
return false;
|
||||||
pointSize = static_cast<float>(d);
|
pointSize = d;
|
||||||
|
|
||||||
token = tokenizer.GetNextToken();
|
token = tokenizer.GetNextToken();
|
||||||
if ( !token.ToLong(&l) )
|
if ( !token.ToLong(&l) )
|
||||||
@@ -839,7 +837,7 @@ void wxNativeFontInfo::Init()
|
|||||||
encoding = wxFONTENCODING_DEFAULT;
|
encoding = wxFONTENCODING_DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
float wxNativeFontInfo::GetFractionalPointSize() const
|
double wxNativeFontInfo::GetFractionalPointSize() const
|
||||||
{
|
{
|
||||||
return pointSize;
|
return pointSize;
|
||||||
}
|
}
|
||||||
@@ -879,7 +877,7 @@ wxFontEncoding wxNativeFontInfo::GetEncoding() const
|
|||||||
return encoding;
|
return encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxNativeFontInfo::SetFractionalPointSize(float pointsize)
|
void wxNativeFontInfo::SetFractionalPointSize(double pointsize)
|
||||||
{
|
{
|
||||||
pointSize = pointsize;
|
pointSize = pointsize;
|
||||||
}
|
}
|
||||||
|
@@ -280,7 +280,7 @@ wxFontMgrFontRefData::GetFontInstance(float scale, bool antialiased) const
|
|||||||
antialiased);
|
antialiased);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFontMgrFontRefData::SetFractionalPointSize(float pointSize)
|
void wxFontMgrFontRefData::SetFractionalPointSize(double pointSize)
|
||||||
{
|
{
|
||||||
m_info.pointSize = pointSize;
|
m_info.pointSize = pointSize;
|
||||||
m_fontValid = false;
|
m_fontValid = false;
|
||||||
|
@@ -1036,22 +1036,22 @@ void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant )
|
|||||||
// adjust the font height to correspond to our new variant (notice that
|
// adjust the font height to correspond to our new variant (notice that
|
||||||
// we're only called if something really changed)
|
// we're only called if something really changed)
|
||||||
wxFont font = GetFont();
|
wxFont font = GetFont();
|
||||||
float size = font.GetFractionalPointSize();
|
double size = font.GetFractionalPointSize();
|
||||||
switch ( variant )
|
switch ( variant )
|
||||||
{
|
{
|
||||||
case wxWINDOW_VARIANT_NORMAL:
|
case wxWINDOW_VARIANT_NORMAL:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxWINDOW_VARIANT_SMALL:
|
case wxWINDOW_VARIANT_SMALL:
|
||||||
size /= 1.2f;
|
size /= 1.2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxWINDOW_VARIANT_MINI:
|
case wxWINDOW_VARIANT_MINI:
|
||||||
size /= 1.2f * 1.2f;
|
size /= 1.2 * 1.2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case wxWINDOW_VARIANT_LARGE:
|
case wxWINDOW_VARIANT_LARGE:
|
||||||
size *= 1.2f;
|
size *= 1.2;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@@ -94,7 +94,7 @@ wxIDirectFBFontPtr wxFont::GetDirectFBFont(bool antialiased) const
|
|||||||
return i ? i->GetDirectFBFont() : wxIDirectFBFontPtr();
|
return i ? i->GetDirectFBFont() : wxIDirectFBFontPtr();
|
||||||
}
|
}
|
||||||
|
|
||||||
float wxFont::GetFractionalPointSize() const
|
double wxFont::GetFractionalPointSize() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
|
wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
|
||||||
|
|
||||||
@@ -160,7 +160,7 @@ const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
|
|||||||
// change font attributes
|
// change font attributes
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void wxFont::SetFractionalPointSize(float pointSize)
|
void wxFont::SetFractionalPointSize(double pointSize)
|
||||||
{
|
{
|
||||||
AllocExclusive();
|
AllocExclusive();
|
||||||
M_FONTDATA->SetFractionalPointSize(pointSize);
|
M_FONTDATA->SetFractionalPointSize(pointSize);
|
||||||
|
@@ -49,7 +49,7 @@ public:
|
|||||||
|
|
||||||
// setters: all of them also take care to modify m_nativeFontInfo if we
|
// setters: all of them also take care to modify m_nativeFontInfo if we
|
||||||
// have it so as to not lose the information not carried by our fields
|
// have it so as to not lose the information not carried by our fields
|
||||||
void SetFractionalPointSize(float pointSize);
|
void SetFractionalPointSize(double pointSize);
|
||||||
void SetFamily(wxFontFamily family);
|
void SetFamily(wxFontFamily family);
|
||||||
void SetStyle(wxFontStyle style);
|
void SetStyle(wxFontStyle style);
|
||||||
void SetWeight(wxFontWeight weight);
|
void SetWeight(wxFontWeight weight);
|
||||||
@@ -134,7 +134,7 @@ wxFontRefData::wxFontRefData(const wxString& nativeFontInfoString)
|
|||||||
// wxFontRefData SetXXX()
|
// wxFontRefData SetXXX()
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void wxFontRefData::SetFractionalPointSize(float pointSize)
|
void wxFontRefData::SetFractionalPointSize(double pointSize)
|
||||||
{
|
{
|
||||||
m_nativeFontInfo.SetFractionalPointSize(pointSize);
|
m_nativeFontInfo.SetFractionalPointSize(pointSize);
|
||||||
}
|
}
|
||||||
@@ -283,7 +283,7 @@ wxFont::~wxFont()
|
|||||||
// accessors
|
// accessors
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
float wxFont::GetFractionalPointSize() const
|
double wxFont::GetFractionalPointSize() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
|
wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
|
||||||
|
|
||||||
@@ -356,7 +356,7 @@ bool wxFont::IsFixedWidth() const
|
|||||||
// change font attributes
|
// change font attributes
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void wxFont::SetFractionalPointSize(float pointSize)
|
void wxFont::SetFractionalPointSize(double pointSize)
|
||||||
{
|
{
|
||||||
AllocExclusive();
|
AllocExclusive();
|
||||||
|
|
||||||
|
@@ -77,7 +77,7 @@ public:
|
|||||||
|
|
||||||
// setters: all of them also take care to modify m_nativeFontInfo if we
|
// setters: all of them also take care to modify m_nativeFontInfo if we
|
||||||
// have it so as to not lose the information not carried by our fields
|
// have it so as to not lose the information not carried by our fields
|
||||||
void SetFractionalPointSize(float pointSize);
|
void SetFractionalPointSize(double pointSize);
|
||||||
void SetFamily(wxFontFamily family);
|
void SetFamily(wxFontFamily family);
|
||||||
void SetStyle(wxFontStyle style);
|
void SetStyle(wxFontStyle style);
|
||||||
void SetNumericWeight(int weight);
|
void SetNumericWeight(int weight);
|
||||||
@@ -108,7 +108,7 @@ private:
|
|||||||
// the map of font sizes to "GdkFont *"
|
// the map of font sizes to "GdkFont *"
|
||||||
wxScaledFontList m_scaled_xfonts;
|
wxScaledFontList m_scaled_xfonts;
|
||||||
|
|
||||||
float m_pointSize;
|
double m_pointSize;
|
||||||
wxFontFamily m_family;
|
wxFontFamily m_family;
|
||||||
wxFontStyle m_style;
|
wxFontStyle m_style;
|
||||||
int m_weight;
|
int m_weight;
|
||||||
@@ -311,7 +311,7 @@ wxFontRefData::~wxFontRefData()
|
|||||||
// wxFontRefData SetXXX()
|
// wxFontRefData SetXXX()
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void wxFontRefData::SetFractionalPointSize(float pointSize)
|
void wxFontRefData::SetFractionalPointSize(double pointSize)
|
||||||
{
|
{
|
||||||
m_pointSize = pointSize;
|
m_pointSize = pointSize;
|
||||||
|
|
||||||
@@ -485,7 +485,7 @@ wxGDIRefData *wxFont::CloneGDIRefData(const wxGDIRefData *data) const
|
|||||||
// accessors
|
// accessors
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
float wxFont::GetFractionalPointSize() const
|
double wxFont::GetFractionalPointSize() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
|
wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
|
||||||
|
|
||||||
@@ -568,7 +568,7 @@ bool wxFont::IsFixedWidth() const
|
|||||||
// change font attributes
|
// change font attributes
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void wxFont::SetFractionalPointSize(float pointSize)
|
void wxFont::SetFractionalPointSize(double pointSize)
|
||||||
{
|
{
|
||||||
Unshare();
|
Unshare();
|
||||||
|
|
||||||
|
@@ -93,7 +93,7 @@ public:
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
// common part of all ctors
|
// common part of all ctors
|
||||||
void Init(float size,
|
void Init(double size,
|
||||||
wxFontFamily family,
|
wxFontFamily family,
|
||||||
wxFontStyle style,
|
wxFontStyle style,
|
||||||
int weight,
|
int weight,
|
||||||
@@ -102,7 +102,7 @@ protected:
|
|||||||
wxFontEncoding encoding);
|
wxFontEncoding encoding);
|
||||||
|
|
||||||
// font attributes
|
// font attributes
|
||||||
float m_pointSize;
|
double m_pointSize;
|
||||||
wxFontFamily m_family;
|
wxFontFamily m_family;
|
||||||
wxFontStyle m_style;
|
wxFontStyle m_style;
|
||||||
int m_weight;
|
int m_weight;
|
||||||
@@ -163,7 +163,7 @@ wxXFont::~wxXFont()
|
|||||||
// wxFontRefData
|
// wxFontRefData
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void wxFontRefData::Init(float pointSize,
|
void wxFontRefData::Init(double pointSize,
|
||||||
wxFontFamily family,
|
wxFontFamily family,
|
||||||
wxFontStyle style,
|
wxFontStyle style,
|
||||||
int weight,
|
int weight,
|
||||||
@@ -381,7 +381,7 @@ void wxFont::Unshare()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFont::SetFractionalPointSize(float pointSize)
|
void wxFont::SetFractionalPointSize(double pointSize)
|
||||||
{
|
{
|
||||||
Unshare();
|
Unshare();
|
||||||
|
|
||||||
@@ -449,7 +449,7 @@ void wxFont::DoSetNativeFontInfo(const wxNativeFontInfo& info)
|
|||||||
// query font attributes
|
// query font attributes
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
float wxFont::GetFractionalPointSize() const
|
double wxFont::GetFractionalPointSize() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
|
wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
|
||||||
|
|
||||||
|
@@ -43,8 +43,6 @@
|
|||||||
#include "wx/scopeguard.h"
|
#include "wx/scopeguard.h"
|
||||||
#include "wx/tokenzr.h"
|
#include "wx/tokenzr.h"
|
||||||
|
|
||||||
#include <float.h> // for FLT_MAX
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// constants
|
// constants
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -79,7 +77,7 @@ public:
|
|||||||
void Free();
|
void Free();
|
||||||
|
|
||||||
// all wxFont accessors
|
// all wxFont accessors
|
||||||
float GetFractionalPointSize() const
|
double GetFractionalPointSize() const
|
||||||
{
|
{
|
||||||
return m_nativeFontInfo.GetFractionalPointSize();
|
return m_nativeFontInfo.GetFractionalPointSize();
|
||||||
}
|
}
|
||||||
@@ -168,7 +166,7 @@ public:
|
|||||||
// ... and setters: notice that all of them invalidate the currently
|
// ... and setters: notice that all of them invalidate the currently
|
||||||
// allocated HFONT, if any, so that the next call to GetHFONT() recreates a
|
// allocated HFONT, if any, so that the next call to GetHFONT() recreates a
|
||||||
// new one
|
// new one
|
||||||
void SetFractionalPointSize(float pointSize)
|
void SetFractionalPointSize(double pointSize)
|
||||||
{
|
{
|
||||||
Free();
|
Free();
|
||||||
|
|
||||||
@@ -411,18 +409,18 @@ wxNativeFontInfo::wxNativeFontInfo(const LOGFONT& lf_, const wxWindow* win)
|
|||||||
{ }
|
{ }
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
float wxNativeFontInfo::GetPointSizeAtPPI(int lfHeight, int ppi)
|
double wxNativeFontInfo::GetPointSizeAtPPI(int lfHeight, int ppi)
|
||||||
{
|
{
|
||||||
if ( ppi == 0 )
|
if ( ppi == 0 )
|
||||||
ppi = ::GetDeviceCaps(ScreenHDC(), LOGPIXELSY);
|
ppi = ::GetDeviceCaps(ScreenHDC(), LOGPIXELSY);
|
||||||
|
|
||||||
return abs(lfHeight) * 72.0f / ppi;
|
return abs(lfHeight) * 72.0 / ppi;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* static */
|
/* static */
|
||||||
int wxNativeFontInfo::GetLogFontHeightAtPPI(float size, int ppi)
|
int wxNativeFontInfo::GetLogFontHeightAtPPI(double size, int ppi)
|
||||||
{
|
{
|
||||||
return -wxRound(size * ppi / 72.0f);
|
return -wxRound(size * ppi / 72.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxNativeFontInfo::Init()
|
void wxNativeFontInfo::Init()
|
||||||
@@ -437,10 +435,10 @@ void wxNativeFontInfo::Init()
|
|||||||
? DEFAULT_QUALITY
|
? DEFAULT_QUALITY
|
||||||
: PROOF_QUALITY;
|
: PROOF_QUALITY;
|
||||||
|
|
||||||
pointSize = 0.0f;
|
pointSize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
float wxNativeFontInfo::GetFractionalPointSize() const
|
double wxNativeFontInfo::GetFractionalPointSize() const
|
||||||
{
|
{
|
||||||
return pointSize;
|
return pointSize;
|
||||||
}
|
}
|
||||||
@@ -523,7 +521,7 @@ wxFontEncoding wxNativeFontInfo::GetEncoding() const
|
|||||||
return wxGetFontEncFromCharSet(lf.lfCharSet);
|
return wxGetFontEncFromCharSet(lf.lfCharSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxNativeFontInfo::SetFractionalPointSize(float pointSizeNew)
|
void wxNativeFontInfo::SetFractionalPointSize(double pointSizeNew)
|
||||||
{
|
{
|
||||||
// We don't have the correct DPI to use here, so use that of the
|
// We don't have the correct DPI to use here, so use that of the
|
||||||
// primary screen and rely on WXAdjustToPPI() changing it later if
|
// primary screen and rely on WXAdjustToPPI() changing it later if
|
||||||
@@ -694,11 +692,7 @@ bool wxNativeFontInfo::FromString(const wxString& s)
|
|||||||
// lfHeight, as with v0 strings.
|
// lfHeight, as with v0 strings.
|
||||||
if ( !wxIsNullDouble(d) )
|
if ( !wxIsNullDouble(d) )
|
||||||
{
|
{
|
||||||
if ( d < 0 || d > FLT_MAX )
|
pointSize = d;
|
||||||
return false;
|
|
||||||
|
|
||||||
pointSize = static_cast<float>(d);
|
|
||||||
|
|
||||||
setPointSizeFromHeight = false;
|
setPointSizeFromHeight = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -901,7 +895,7 @@ bool wxFont::IsFree() const
|
|||||||
// change font attribute: we recreate font when doing it
|
// change font attribute: we recreate font when doing it
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void wxFont::SetFractionalPointSize(float pointSize)
|
void wxFont::SetFractionalPointSize(double pointSize)
|
||||||
{
|
{
|
||||||
AllocExclusive();
|
AllocExclusive();
|
||||||
|
|
||||||
@@ -998,7 +992,7 @@ void wxFont::DoSetNativeFontInfo(const wxNativeFontInfo& info)
|
|||||||
// accessors
|
// accessors
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
float wxFont::GetFractionalPointSize() const
|
double wxFont::GetFractionalPointSize() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
|
wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
|
||||||
|
|
||||||
|
@@ -1148,9 +1148,9 @@ wxGDIPlusFontData::wxGDIPlusFontData( wxGraphicsRenderer* renderer,
|
|||||||
if ( font.GetWeight() == wxFONTWEIGHT_BOLD )
|
if ( font.GetWeight() == wxFONTWEIGHT_BOLD )
|
||||||
style |= FontStyleBold;
|
style |= FontStyleBold;
|
||||||
|
|
||||||
REAL fontSize = (REAL)(!dpi.y
|
REAL fontSize = !dpi.y
|
||||||
? font.GetPixelSize().GetHeight()
|
? REAL(font.GetPixelSize().GetHeight())
|
||||||
: (font.GetFractionalPointSize() * dpi.y / 72.0f));
|
: REAL(font.GetFractionalPointSize()) * dpi.y / 72.0f;
|
||||||
|
|
||||||
Init(font.GetFaceName(), fontSize, style, col);
|
Init(font.GetFaceName(), fontSize, style, col);
|
||||||
}
|
}
|
||||||
|
@@ -3104,9 +3104,9 @@ wxD2DFontData::wxD2DFontData(wxGraphicsRenderer* renderer, const wxFont& font, c
|
|||||||
hr = familyNames->GetString(0, name, length+1);
|
hr = familyNames->GetString(0, name, length+1);
|
||||||
wxCHECK_HRESULT_RET(hr);
|
wxCHECK_HRESULT_RET(hr);
|
||||||
|
|
||||||
FLOAT fontSize = (FLOAT)(!dpi.y
|
FLOAT fontSize = !dpi.y
|
||||||
? font.GetPixelSize().GetHeight()
|
? FLOAT(font.GetPixelSize().GetHeight())
|
||||||
: (font.GetFractionalPointSize() * dpi.y / 72.0f));
|
: FLOAT(font.GetFractionalPointSize()) * dpi.y / 72.0f;
|
||||||
|
|
||||||
hr = wxDWriteFactory()->CreateTextFormat(
|
hr = wxDWriteFactory()->CreateTextFormat(
|
||||||
name,
|
name,
|
||||||
|
@@ -3383,7 +3383,7 @@ bool wxTextCtrl::GetStyle(long position, wxTextAttr& style)
|
|||||||
// Determine the pointSize that was used in SetStyle. Don't worry about
|
// Determine the pointSize that was used in SetStyle. Don't worry about
|
||||||
// lfHeight or PPI, style.SetFont() will lose this information anyway.
|
// lfHeight or PPI, style.SetFont() will lose this information anyway.
|
||||||
wxFont font(wxNativeFontInfo(lf, this));
|
wxFont font(wxNativeFontInfo(lf, this));
|
||||||
font.SetFractionalPointSize(cf.yHeight / 20.0f); // 1 pt = 20 twips
|
font.SetFractionalPointSize(cf.yHeight / 20.0); // 1 pt = 20 twips
|
||||||
if (font.IsOk())
|
if (font.IsOk())
|
||||||
{
|
{
|
||||||
style.SetFont(font);
|
style.SetFont(font);
|
||||||
|
@@ -49,7 +49,7 @@ public:
|
|||||||
|
|
||||||
wxFontRefData(CTFontRef font);
|
wxFontRefData(CTFontRef font);
|
||||||
|
|
||||||
float GetFractionalPointSize() const { return m_info.GetFractionalPointSize(); }
|
double GetFractionalPointSize() const { return m_info.GetFractionalPointSize(); }
|
||||||
|
|
||||||
wxFontFamily GetFamily() const { return m_info.GetFamily(); }
|
wxFontFamily GetFamily() const { return m_info.GetFamily(); }
|
||||||
|
|
||||||
@@ -75,7 +75,7 @@ public:
|
|||||||
|
|
||||||
const wxNativeFontInfo& GetNativeFontInfo() const;
|
const wxNativeFontInfo& GetNativeFontInfo() const;
|
||||||
|
|
||||||
void SetFractionalPointSize(float size)
|
void SetFractionalPointSize(double size)
|
||||||
{
|
{
|
||||||
if (GetFractionalPointSize() != size)
|
if (GetFractionalPointSize() != size)
|
||||||
{
|
{
|
||||||
@@ -569,7 +569,7 @@ wxGDIRefData* wxFont::CloneGDIRefData(const wxGDIRefData* data) const
|
|||||||
return new wxFontRefData(*static_cast<const wxFontRefData*>(data));
|
return new wxFontRefData(*static_cast<const wxFontRefData*>(data));
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFont::SetFractionalPointSize(float pointSize)
|
void wxFont::SetFractionalPointSize(double pointSize)
|
||||||
{
|
{
|
||||||
AllocExclusive();
|
AllocExclusive();
|
||||||
|
|
||||||
@@ -626,7 +626,7 @@ void wxFont::SetStrikethrough(bool strikethrough)
|
|||||||
|
|
||||||
// TODO: insert checks everywhere for M_FONTDATA == NULL!
|
// TODO: insert checks everywhere for M_FONTDATA == NULL!
|
||||||
|
|
||||||
float wxFont::GetFractionalPointSize() const
|
double wxFont::GetFractionalPointSize() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG(IsOk(), 0, wxT("invalid font"));
|
wxCHECK_MSG(IsOk(), 0, wxT("invalid font"));
|
||||||
|
|
||||||
@@ -1040,7 +1040,7 @@ wxString wxNativeFontInfo::ToString() const
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
float wxNativeFontInfo::GetFractionalPointSize() const
|
double wxNativeFontInfo::GetFractionalPointSize() const
|
||||||
{
|
{
|
||||||
return m_ctSize;
|
return m_ctSize;
|
||||||
}
|
}
|
||||||
@@ -1087,7 +1087,7 @@ bool wxNativeFontInfo::GetStrikethrough() const
|
|||||||
|
|
||||||
// changing the font descriptor
|
// changing the font descriptor
|
||||||
|
|
||||||
void wxNativeFontInfo::SetFractionalPointSize(float pointsize)
|
void wxNativeFontInfo::SetFractionalPointSize(double pointsize)
|
||||||
{
|
{
|
||||||
if (GetFractionalPointSize() != pointsize)
|
if (GetFractionalPointSize() != pointsize)
|
||||||
{
|
{
|
||||||
|
@@ -241,7 +241,7 @@ int wxFont::GetPointSize() const
|
|||||||
return M_FONTDATA.wxNativeFontInfo::GetPointSize();
|
return M_FONTDATA.wxNativeFontInfo::GetPointSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
float wxFont::GetFractionalPointSize() const
|
double wxFont::GetFractionalPointSize() const
|
||||||
{
|
{
|
||||||
return M_FONTDATA.GetFractionalPointSize();
|
return M_FONTDATA.GetFractionalPointSize();
|
||||||
}
|
}
|
||||||
@@ -287,7 +287,7 @@ bool wxFont::GetStrikethrough() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void wxFont::SetFractionalPointSize(float pointSize)
|
void wxFont::SetFractionalPointSize(double pointSize)
|
||||||
{
|
{
|
||||||
AllocExclusive();
|
AllocExclusive();
|
||||||
|
|
||||||
@@ -390,7 +390,7 @@ void wxNativeFontInfo::Init()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
float wxNativeFontInfo::GetFractionalPointSize() const
|
double wxNativeFontInfo::GetFractionalPointSize() const
|
||||||
{
|
{
|
||||||
return m_qtFont.pointSizeF();
|
return m_qtFont.pointSizeF();
|
||||||
}
|
}
|
||||||
@@ -501,7 +501,7 @@ wxFontEncoding wxNativeFontInfo::GetEncoding() const
|
|||||||
return wxFONTENCODING_UTF8;
|
return wxFONTENCODING_UTF8;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxNativeFontInfo::SetFractionalPointSize(float pointsize)
|
void wxNativeFontInfo::SetFractionalPointSize(double pointsize)
|
||||||
{
|
{
|
||||||
m_qtFont.setPointSizeF(pointsize);
|
m_qtFont.setPointSizeF(pointsize);
|
||||||
}
|
}
|
||||||
|
@@ -91,9 +91,9 @@ void wxNativeFontInfo::Free()
|
|||||||
pango_font_description_free(description);
|
pango_font_description_free(description);
|
||||||
}
|
}
|
||||||
|
|
||||||
float wxNativeFontInfo::GetFractionalPointSize() const
|
double wxNativeFontInfo::GetFractionalPointSize() const
|
||||||
{
|
{
|
||||||
return ((float) pango_font_description_get_size( description )) / PANGO_SCALE;
|
return double(pango_font_description_get_size(description)) / PANGO_SCALE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFontStyle wxNativeFontInfo::GetStyle() const
|
wxFontStyle wxNativeFontInfo::GetStyle() const
|
||||||
@@ -215,7 +215,7 @@ wxFontEncoding wxNativeFontInfo::GetEncoding() const
|
|||||||
return wxFONTENCODING_SYSTEM;
|
return wxFONTENCODING_SYSTEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxNativeFontInfo::SetFractionalPointSize(float pointsize)
|
void wxNativeFontInfo::SetFractionalPointSize(double pointsize)
|
||||||
{
|
{
|
||||||
pango_font_description_set_size( description, wxRound(pointsize * PANGO_SCALE) );
|
pango_font_description_set_size( description, wxRound(pointsize * PANGO_SCALE) );
|
||||||
}
|
}
|
||||||
@@ -489,7 +489,7 @@ static wxHashTable *g_fontHash = NULL;
|
|||||||
|
|
||||||
static bool wxTestFontSpec(const wxString& fontspec);
|
static bool wxTestFontSpec(const wxString& fontspec);
|
||||||
|
|
||||||
static wxNativeFont wxLoadQueryFont(float pointSize,
|
static wxNativeFont wxLoadQueryFont(double pointSize,
|
||||||
wxFontFamily family,
|
wxFontFamily family,
|
||||||
wxFontStyle style,
|
wxFontStyle style,
|
||||||
int weight,
|
int weight,
|
||||||
@@ -693,7 +693,7 @@ void wxNativeFontInfo::SetXFontName(const wxString& xFontName_)
|
|||||||
m_isDefault = false;
|
m_isDefault = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
float wxNativeFontInfo::GetFractionalPointSize() const
|
double wxNativeFontInfo::GetFractionalPointSize() const
|
||||||
{
|
{
|
||||||
const wxString s = GetXFontComponent(wxXLFD_POINTSIZE);
|
const wxString s = GetXFontComponent(wxXLFD_POINTSIZE);
|
||||||
|
|
||||||
@@ -785,7 +785,7 @@ wxFontEncoding wxNativeFontInfo::GetEncoding() const
|
|||||||
return wxFONTENCODING_MAX;
|
return wxFONTENCODING_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxNativeFontInfo::SetFractionalPointSize(float pointsize)
|
void wxNativeFontInfo::SetFractionalPointSize(double pointsize)
|
||||||
{
|
{
|
||||||
wxString s;
|
wxString s;
|
||||||
if ( pointsize < 0 )
|
if ( pointsize < 0 )
|
||||||
@@ -1029,7 +1029,7 @@ bool wxTestFontEncoding(const wxNativeEncodingInfo& info)
|
|||||||
// X-specific functions
|
// X-specific functions
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxNativeFont wxLoadQueryNearestFont(float pointSize,
|
wxNativeFont wxLoadQueryNearestFont(double pointSize,
|
||||||
wxFontFamily family,
|
wxFontFamily family,
|
||||||
wxFontStyle style,
|
wxFontStyle style,
|
||||||
int weight,
|
int weight,
|
||||||
@@ -1252,7 +1252,7 @@ static bool wxTestFontSpec(const wxString& fontspec)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static wxNativeFont wxLoadQueryFont(float pointSize,
|
static wxNativeFont wxLoadQueryFont(double pointSize,
|
||||||
wxFontFamily family,
|
wxFontFamily family,
|
||||||
wxFontStyle style,
|
wxFontStyle style,
|
||||||
int weight,
|
int weight,
|
||||||
|
@@ -138,7 +138,7 @@ public:
|
|||||||
|
|
||||||
// setters: all of them also take care to modify m_nativeFontInfo if we
|
// setters: all of them also take care to modify m_nativeFontInfo if we
|
||||||
// have it so as to not lose the information not carried by our fields
|
// have it so as to not lose the information not carried by our fields
|
||||||
void SetFractionalPointSize(float pointSize);
|
void SetFractionalPointSize(double pointSize);
|
||||||
void SetFamily(wxFontFamily family);
|
void SetFamily(wxFontFamily family);
|
||||||
void SetStyle(wxFontStyle style);
|
void SetStyle(wxFontStyle style);
|
||||||
void SetNumericWeight(int weight);
|
void SetNumericWeight(int weight);
|
||||||
@@ -250,7 +250,7 @@ void wxFontRefData::Init(int pointSize,
|
|||||||
m_nativeFontInfo.SetUnderlined(underlined);
|
m_nativeFontInfo.SetUnderlined(underlined);
|
||||||
#endif // wxUSE_UNICODE
|
#endif // wxUSE_UNICODE
|
||||||
|
|
||||||
SetFractionalPointSize(static_cast<float>(pointSize));
|
SetFractionalPointSize(pointSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFontRefData::InitFromNative()
|
void wxFontRefData::InitFromNative()
|
||||||
@@ -426,7 +426,7 @@ wxFontRefData::~wxFontRefData()
|
|||||||
// wxFontRefData SetXXX()
|
// wxFontRefData SetXXX()
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void wxFontRefData::SetFractionalPointSize(float pointSize)
|
void wxFontRefData::SetFractionalPointSize(double pointSize)
|
||||||
{
|
{
|
||||||
// NB: Pango doesn't support point sizes less than 1
|
// NB: Pango doesn't support point sizes less than 1
|
||||||
m_pointSize = pointSize == wxDEFAULT || pointSize < 1 ? wxDEFAULT_FONT_SIZE
|
m_pointSize = pointSize == wxDEFAULT || pointSize < 1 ? wxDEFAULT_FONT_SIZE
|
||||||
@@ -692,7 +692,7 @@ void wxFont::Unshare()
|
|||||||
// accessors
|
// accessors
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
float wxFont::GetFractionalPointSize() const
|
double wxFont::GetFractionalPointSize() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
|
wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
|
||||||
|
|
||||||
@@ -799,7 +799,7 @@ bool wxFont::IsFixedWidth() const
|
|||||||
// change font attributes
|
// change font attributes
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void wxFont::SetFractionalPointSize(float pointSize)
|
void wxFont::SetFractionalPointSize(double pointSize)
|
||||||
{
|
{
|
||||||
Unshare();
|
Unshare();
|
||||||
|
|
||||||
|
@@ -454,7 +454,7 @@ TEST_CASE("wxFont::NativeFontInfoUserDesc", "[font][fontinfo]")
|
|||||||
// strings (see #18590).
|
// strings (see #18590).
|
||||||
wxFont font(*wxNORMAL_FONT);
|
wxFont font(*wxNORMAL_FONT);
|
||||||
|
|
||||||
static const float sizes[] = { 12.0f, 10.5f, 13.8f, 10.123f, 11.1f };
|
static const double sizes[] = { 12.0, 10.5, 13.8, 10.123, 11.1 };
|
||||||
for ( unsigned n = 0; n < WXSIZEOF(sizes); n++ )
|
for ( unsigned n = 0; n < WXSIZEOF(sizes); n++ )
|
||||||
{
|
{
|
||||||
font.SetFractionalPointSize(sizes[n]);
|
font.SetFractionalPointSize(sizes[n]);
|
||||||
@@ -462,7 +462,7 @@ TEST_CASE("wxFont::NativeFontInfoUserDesc", "[font][fontinfo]")
|
|||||||
// Just setting the font can slightly change it because of rounding
|
// Just setting the font can slightly change it because of rounding
|
||||||
// errors, so don't expect the actual size to be exactly equal to what
|
// errors, so don't expect the actual size to be exactly equal to what
|
||||||
// we used -- but close enough.
|
// we used -- but close enough.
|
||||||
const float sizeUsed = font.GetFractionalPointSize();
|
const double sizeUsed = font.GetFractionalPointSize();
|
||||||
CHECK( sizeUsed == Approx(sizes[n]).epsilon(0.001) );
|
CHECK( sizeUsed == Approx(sizes[n]).epsilon(0.001) );
|
||||||
|
|
||||||
const wxString& desc = font.GetNativeFontInfoDesc();
|
const wxString& desc = font.GetNativeFontInfoDesc();
|
||||||
|
Reference in New Issue
Block a user