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:
7
configure
vendored
7
configure
vendored
@@ -38299,6 +38299,9 @@ $as_echo "$wx_cv_lib_gdiplus" >&6; }
|
||||
if test "$wx_cv_lib_gdiplus" = "yes"; then
|
||||
wx_has_graphics=1
|
||||
fi
|
||||
elif test "$WXGTK1" = "1"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: wxGraphicsContext not supported with GTK +1" >&5
|
||||
$as_echo "$as_me: WARNING: wxGraphicsContext not supported with GTK +1" >&2;}
|
||||
elif test "$wxUSE_GTK" = 1 -o "$wxUSE_QT" = 1 -o "$wxUSE_X11" = 1; then
|
||||
|
||||
pkg_failed=no
|
||||
@@ -38972,6 +38975,10 @@ case ".$ac_cv_cxxflags_gcc_option__Woverloaded_virtual" in
|
||||
esac
|
||||
|
||||
|
||||
if test "$WXGTK1" = "1"; then
|
||||
CXXWARNINGS="$CXXWARNINGS -Wno-deprecated-declarations -Wno-narrowing -Wno-write-strings"
|
||||
fi
|
||||
|
||||
if test "$WXGTK4" != 1 -a \( "$WXGTK3" = 1 -o "$wxUSE_MAC" = 1 \) ; then
|
||||
CXXWARNINGS="$CXXWARNINGS -Wno-deprecated-declarations"
|
||||
|
||||
|
@@ -7518,6 +7518,8 @@ if test "$wxUSE_GRAPHICS_CONTEXT" = "yes"; then
|
||||
if test "$wx_cv_lib_gdiplus" = "yes"; then
|
||||
wx_has_graphics=1
|
||||
fi
|
||||
elif test "$WXGTK1" = "1"; then
|
||||
AC_MSG_WARN([wxGraphicsContext not supported with GTK +1])
|
||||
elif test "$wxUSE_GTK" = 1 -o "$wxUSE_QT" = 1 -o "$wxUSE_X11" = 1; then
|
||||
PKG_CHECK_MODULES(CAIRO, cairo,
|
||||
[wx_has_graphics=1],
|
||||
@@ -7867,6 +7869,13 @@ elif test "$GXX" = yes ; then
|
||||
CXXWARNINGS="-Wall -Wundef -Wunused-parameter -Wno-ctor-dtor-privacy"
|
||||
AX_CXXFLAGS_GCC_OPTION(-Woverloaded-virtual, CXXWARNINGS)
|
||||
|
||||
dnl there are tons of warnings when building with GTK+ 1 which are never
|
||||
dnl going to get fixed, so disable them to at least see new warnings/errors
|
||||
dnl more clearly
|
||||
if test "$WXGTK1" = "1"; then
|
||||
CXXWARNINGS="$CXXWARNINGS -Wno-deprecated-declarations -Wno-narrowing -Wno-write-strings"
|
||||
fi
|
||||
|
||||
dnl when building using GTK+ 3 or Cocoa we currently get tons of deprecation
|
||||
dnl warnings from the standard headers -- disable them as we already know
|
||||
dnl that they're deprecated but we still have to use them to support older
|
||||
|
@@ -104,6 +104,8 @@ All (GUI):
|
||||
|
||||
- wxAdvanced library was merged into wxCore, simply remove all references
|
||||
to "adv" from your build system, it is not needed any longer.
|
||||
- Add support for non-integer font sizes (e.g. 10.5pt fonts).
|
||||
- Add support for font weights in 1..1000 interval and not just light/bold.
|
||||
- Add wxDataViewToggleRenderer::ShowAsRadio().
|
||||
- Improve stock items consistency and aesthetics (dhowland).
|
||||
- Fix bug with missing items in overflowing AUI toolbar (Maarten Bent).
|
||||
@@ -117,6 +119,7 @@ All (GUI):
|
||||
- Allow distinguishing between user- and script-opened windows in wxWebView.
|
||||
- Allow binding to events generated by their items in submenus too.
|
||||
- Add wxGrid::SetCornerLabelValue() (Pavel Kalugin).
|
||||
- Add strikethrough support for fonts defined in XRC.
|
||||
|
||||
wxGTK:
|
||||
|
||||
|
@@ -403,19 +403,28 @@ and can be one of the following "sub-properties":
|
||||
|
||||
@beginTable
|
||||
@hdr3col{property, type, description}
|
||||
@row3col{size, unsigned integer,
|
||||
@row3col{size, float,
|
||||
Pixel size of the font (default: wxNORMAL_FONT's size or @c sysfont's
|
||||
size if the @c sysfont property is used or the current size of the font
|
||||
of the enclosing control if the @c inherit property is used.}
|
||||
of the enclosing control if the @c inherit property is used. Note that
|
||||
versions of wxWidgets until 3.1.2 only supported integer values for the
|
||||
font size.}
|
||||
@row3col{style, enum,
|
||||
One of "normal", "italic" or "slant" (default: normal).}
|
||||
@row3col{weight, enum,
|
||||
One of "normal", "bold" or "light" (default: normal).}
|
||||
@row3col{weight, enum or integer,
|
||||
One of "thin", "extralight", "light", "normal", "medium", "semibold",
|
||||
"bold", "extrabold", "heavy", "extraheavy", corresponding to the similarly
|
||||
named elements of ::wxFontWeight enum, or a numeric value between 1 and
|
||||
1000 (default: normal). Note that versions of wxWidgets until 3.1.2 only
|
||||
supported "light", "normal" and "bold" values for weight.}
|
||||
@row3col{family, enum,
|
||||
One of "default", "roman", "script", "decorative", "swiss", "modern" or "teletype"
|
||||
(default: default).}
|
||||
@row3col{underlined, @ref overview_xrcformat_type_bool,
|
||||
Whether the font should be underlined (default: 0).}
|
||||
@row3col{strikethrough, @ref overview_xrcformat_type_bool,
|
||||
Whether the strikethrough font should be used (default: 0). This property
|
||||
is only supported since wxWidgets 3.1.2.}
|
||||
@row3col{face, ,
|
||||
Comma-separated list of face names; the first one available is used
|
||||
(default: unspecified).}
|
||||
|
@@ -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);
|
||||
|
@@ -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(); \
|
||||
|
@@ -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().
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
@@ -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);
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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);
|
||||
|
||||
|
@@ -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,
|
||||
|
@@ -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;
|
||||
|
@@ -322,9 +322,16 @@ public:
|
||||
/**
|
||||
Constructor setting the font size in points to use.
|
||||
|
||||
The canonical type of @a pointSize argument is @c float, however any
|
||||
other integer type, as well as @c double, is also accepted for
|
||||
compatibility.
|
||||
|
||||
Notice that until wxWidgets 3.1.2, the type could only be @c int.
|
||||
|
||||
@see wxFont::SetPointSize()
|
||||
*/
|
||||
explicit wxFontInfo(int pointSize);
|
||||
template <typename T>
|
||||
explicit wxFontInfo(T pointSize);
|
||||
|
||||
/**
|
||||
Constructor setting the font size in pixels to use.
|
||||
@@ -356,9 +363,24 @@ public:
|
||||
*/
|
||||
wxFontInfo& FaceName(const wxString& faceName);
|
||||
|
||||
/**
|
||||
Specify the weight of the font.
|
||||
|
||||
@param weight
|
||||
A font weight in the range from 1 to 1000, inclusive, with 1 being
|
||||
the thinnest and 1000 the heaviest possible font variant.
|
||||
@c wxFONTWEIGHT_XXX values from wxFontWeight enum can be used here.
|
||||
|
||||
@since 3.1.2
|
||||
*/
|
||||
wxFontInfo& Weight(int weight);
|
||||
|
||||
/**
|
||||
Use a bold version of the font.
|
||||
|
||||
This is a wrapper for Weight() calling it with ::wxFONTWEIGHT_BOLD
|
||||
argument.
|
||||
|
||||
@see ::wxFontWeight, wxFont::SetWeight()
|
||||
*/
|
||||
wxFontInfo& Bold(bool bold = true);
|
||||
@@ -366,6 +388,9 @@ public:
|
||||
/**
|
||||
Use a lighter version of the font.
|
||||
|
||||
This is a wrapper for Weight() calling it with ::wxFONTWEIGHT_LIGHT
|
||||
argument.
|
||||
|
||||
@see ::wxFontWeight, wxFont::SetWeight()
|
||||
*/
|
||||
wxFontInfo& Light(bool light = true);
|
||||
@@ -373,6 +398,9 @@ public:
|
||||
/**
|
||||
Use an italic version of the font.
|
||||
|
||||
This is a wrapper for Style() calling it with ::wxFONTSTYLE_ITALIC
|
||||
argument.
|
||||
|
||||
@see ::wxFontStyle, wxFont::SetStyle()
|
||||
*/
|
||||
wxFontInfo& Italic(bool italic = true);
|
||||
@@ -380,10 +408,20 @@ public:
|
||||
/**
|
||||
Use a slanted version of the font.
|
||||
|
||||
This is a wrapper for Style() calling it with ::wxFONTSTYLE_SLANT
|
||||
argument.
|
||||
|
||||
@see ::wxFontStyle, wxFont::SetStyle()
|
||||
*/
|
||||
wxFontInfo& Slant(bool slant = true);
|
||||
|
||||
/**
|
||||
Specify the style of the font using one of wxFontStyle constants.
|
||||
|
||||
@since 3.1.2
|
||||
*/
|
||||
wxFontInfo& Style(wxFontStyle style);
|
||||
|
||||
/**
|
||||
Set anti-aliasing flag.
|
||||
|
||||
@@ -419,8 +457,25 @@ public:
|
||||
Set all the font attributes at once.
|
||||
|
||||
See ::wxFontFlag for the various flags that can be used.
|
||||
|
||||
Note that calling this method affects the font weight stored in this
|
||||
object: it is set to ::wxFONTWEIGHT_LIGHT or ::wxFONTWEIGHT_BOLD if the
|
||||
corresponding flag is present in @a flags, or ::wxFONTWEIGHT_NORMAL
|
||||
otherwise.
|
||||
*/
|
||||
wxFontInfo& AllFlags(int flags);
|
||||
|
||||
/**
|
||||
Get the symbolic weight closest to the given raw weight value.
|
||||
|
||||
@param numWeight
|
||||
A valid raw weight value, i.e. a value in the range 1 to 1000,
|
||||
inclusive.
|
||||
@return A valid element of wxFontWeight enum.
|
||||
|
||||
@since 3.1.2
|
||||
*/
|
||||
static wxFontWeight GetWeightClosestToNumericValue(int numWeight);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -503,7 +558,10 @@ public:
|
||||
historical reasons, the value 70 here is interpreted at @c
|
||||
wxDEFAULT and results in creation of the font with the default size
|
||||
and not of a font with the size of 70pt. If you really need the
|
||||
latter, please use SetPointSize(70).
|
||||
latter, please use SetPointSize(70). Note that this constructor and
|
||||
the matching Create() method overload are the only places in wxFont
|
||||
API handling @c wxDEFAULT specially: neither SetPointSize() nor the
|
||||
constructor taking wxFontInfo handle this value in this way.
|
||||
@param family
|
||||
The font family: a generic portable way of referring to fonts without specifying a
|
||||
facename. This parameter must be one of the ::wxFontFamily enumeration values.
|
||||
@@ -1059,19 +1117,29 @@ public:
|
||||
void SetNativeFontInfo(const wxNativeFontInfo& info);
|
||||
|
||||
/**
|
||||
Sets the point size.
|
||||
Sets the font size in points to an integer value.
|
||||
|
||||
This is a legacy version of the function only supporting integer point
|
||||
sizes. It can still be used, but to avoid unnecessarily restricting the
|
||||
font size in points to integer values, consider using the new (added in
|
||||
wxWidgets 3.1.2) SetFractionalPointSize() function instead.
|
||||
*/
|
||||
virtual void SetPointSize(int pointSize);
|
||||
|
||||
/**
|
||||
Sets the font size in points.
|
||||
|
||||
The <em>point size</em> is defined as 1/72 of the Anglo-Saxon inch
|
||||
(25.4 mm): it is approximately 0.0139 inch or 352.8 um.
|
||||
|
||||
@param pointSize
|
||||
Size in points. This can also be a fractional point size like 11.5.
|
||||
Note that until wxWidgets 3.1.2, the size had to be an integer number
|
||||
(and the type of this parameter was @c int).
|
||||
|
||||
@see GetPointSize()
|
||||
@see GetFractionalPointSize(), SetPointSize()
|
||||
|
||||
@since 3.1.2
|
||||
*/
|
||||
virtual void SetPointSize(float pointSize);
|
||||
virtual void SetFractionalPointSize(float pointSize);
|
||||
|
||||
/**
|
||||
Sets the pixel size.
|
||||
@@ -1208,6 +1276,22 @@ public:
|
||||
*/
|
||||
static void SetDefaultEncoding(wxFontEncoding encoding);
|
||||
|
||||
/**
|
||||
Get the raw weight value corresponding to the given symbolic constant.
|
||||
|
||||
For compatibility, this function handles the values @c wxNORMAL, @c
|
||||
wxLIGHT and @c wxBOLD, that have values 90, 91 and 92, specially and
|
||||
converts them to the corresponding @c wxFONTWEIGHT_XXX weight value.
|
||||
|
||||
@param weight
|
||||
A valid element of wxFontWeight enum, i.e. this argument can't have
|
||||
value ::wxFONTWEIGHT_INVALID.
|
||||
@return Numeric weight, between 1 and 1000.
|
||||
|
||||
@since 3.1.2
|
||||
*/
|
||||
static int GetNumericWeightOf(wxFontWeight weight);
|
||||
|
||||
//@{
|
||||
/**
|
||||
This function takes the same parameters as the relative
|
||||
|
@@ -41,7 +41,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);
|
||||
|
@@ -454,14 +454,15 @@ t_bitmap = t_url?,
|
||||
)?
|
||||
|
||||
t_font = (
|
||||
[xrc:p="o"] element size {_, t_integer }* &
|
||||
[xrc:p="o"] element size {_, t_float }* &
|
||||
[xrc:p="o"] element style {_, ("normal" | "italic" | "slant") }* &
|
||||
[xrc:p="o"] element weight {_, ("normal" | "thin" | "extralight" | "light" |
|
||||
"medium" | "semibold" | "bold" | "extrabold" |
|
||||
"heavy" | "extraheavy") }* &
|
||||
"heavy" | "extraheavy" | t_integer) }* &
|
||||
[xrc:p="o"] element family {_, ("roman" | "script" | "decorative" | "swiss" |
|
||||
"modern" | "teletype") }* &
|
||||
[xrc:p="o"] element underlined {_, t_bool }* &
|
||||
[xrc:p="o"] element strikethrough{_, t_bool }* &
|
||||
[xrc:p="o"] element face {_, t_text }* &
|
||||
[xrc:p="o"] element encoding {_, t_text }* &
|
||||
[xrc:p="o"] element sysfont {_, ("wxSYS_OEM_FIXED_FONT" | "wxSYS_ANSI_FIXED_FONT" |
|
||||
|
@@ -337,8 +337,7 @@ void MyCanvas::CreateCaret()
|
||||
|
||||
void MyCanvas::SetFontSize(int fontSize)
|
||||
{
|
||||
m_font = wxFont(fontSize, wxFONTFAMILY_TELETYPE,
|
||||
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
m_font = wxFont(wxFontInfo(fontSize).Family(wxFONTFAMILY_TELETYPE));
|
||||
|
||||
wxClientDC dc(this);
|
||||
dc.SetFont(m_font);
|
||||
|
@@ -28,6 +28,12 @@ of MSW, MAC and OS2
|
||||
#define USE_WXUNIVERSAL 0
|
||||
#endif
|
||||
|
||||
#ifdef WXUSINGDLL
|
||||
#define USE_DLL 1
|
||||
#else
|
||||
#define USE_DLL 0
|
||||
#endif
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#define USE_WXMSW 1
|
||||
#else
|
||||
@@ -52,14 +58,16 @@ of MSW, MAC and OS2
|
||||
#define USE_WXGTK 0
|
||||
#endif
|
||||
|
||||
#define USE_GENERIC_DIALOGS (!USE_WXUNIVERSAL && !USE_DLL)
|
||||
|
||||
#define USE_COLOURDLG_GENERIC \
|
||||
((USE_WXMSW || USE_WXMAC) && USE_WXUNIVERSAL && wxUSE_COLOURDLG)
|
||||
((USE_WXMSW || USE_WXMAC) && USE_GENERIC_DIALOGS && wxUSE_COLOURDLG)
|
||||
#define USE_DIRDLG_GENERIC \
|
||||
((USE_WXMSW || USE_WXMAC) && USE_WXUNIVERSAL && wxUSE_DIRDLG)
|
||||
((USE_WXMSW || USE_WXMAC) && USE_GENERIC_DIALOGS && wxUSE_DIRDLG)
|
||||
#define USE_FILEDLG_GENERIC \
|
||||
((USE_WXMSW || USE_WXMAC) && USE_WXUNIVERSAL && wxUSE_FILEDLG)
|
||||
((USE_WXMSW || USE_WXMAC) && USE_GENERIC_DIALOGS && wxUSE_FILEDLG)
|
||||
#define USE_FONTDLG_GENERIC \
|
||||
((USE_WXMSW || USE_WXMACFONTDLG) && USE_WXUNIVERSAL && wxUSE_FONTDLG)
|
||||
((USE_WXMSW || USE_WXMACFONTDLG) && USE_GENERIC_DIALOGS && wxUSE_FONTDLG)
|
||||
|
||||
// Turn USE_MODAL_PRESENTATION to 0 if there is any reason for not presenting difference
|
||||
// between modal and modeless dialogs (ie. not implemented it in your port yet)
|
||||
|
@@ -1072,7 +1072,7 @@ void MyCanvas::DrawAlpha(wxDC& dc)
|
||||
|
||||
dc.SetTextBackground( wxColour(160, 192, 160, 160) );
|
||||
dc.SetTextForeground( wxColour(255, 128, 128, 128) );
|
||||
dc.SetFont( wxFont( 40, wxFONTFAMILY_SWISS, wxFONTSTYLE_ITALIC, wxFONTWEIGHT_NORMAL ) );
|
||||
dc.SetFont( wxFontInfo(40).Family(wxFONTFAMILY_SWISS).Italic() );
|
||||
dc.DrawText( wxT("Hello!"), 120, 80 );
|
||||
}
|
||||
#endif // wxDRAWING_DC_SUPPORTS_ALPHA || wxUSE_GRAPHICS_CONTEXT
|
||||
|
@@ -522,8 +522,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||
|
||||
// create the listbox in which we will show misc messages as they come
|
||||
m_lbox = new wxListBox(this, wxID_ANY);
|
||||
wxFont font(12, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL,
|
||||
wxFONTWEIGHT_NORMAL);
|
||||
wxFont font(wxFontInfo(12).Family(wxFONTFAMILY_TELETYPE));
|
||||
if ( font.IsOk() )
|
||||
m_lbox->SetFont(font);
|
||||
|
||||
|
@@ -23,12 +23,16 @@
|
||||
#include "wx/log.h"
|
||||
#endif
|
||||
|
||||
#include "wx/checkbox.h"
|
||||
#include "wx/choicdlg.h"
|
||||
#include "wx/fontdlg.h"
|
||||
#include "wx/fontenum.h"
|
||||
#include "wx/fontmap.h"
|
||||
#include "wx/encconv.h"
|
||||
#include "wx/sizer.h"
|
||||
#include "wx/spinctrl.h"
|
||||
#include "wx/splitter.h"
|
||||
#include "wx/statline.h"
|
||||
#include "wx/stdpaths.h"
|
||||
#include "wx/textfile.h"
|
||||
#include "wx/settings.h"
|
||||
@@ -60,14 +64,85 @@ public:
|
||||
virtual bool OnInit() wxOVERRIDE;
|
||||
};
|
||||
|
||||
// MyCanvas is a canvas on which we show the font sample
|
||||
class MyCanvas: public wxWindow
|
||||
// FontPanel contains controls allowing to specify the font properties
|
||||
class FontPanel : public wxPanel
|
||||
{
|
||||
public:
|
||||
MyCanvas( wxWindow *parent );
|
||||
virtual ~MyCanvas(){};
|
||||
explicit FontPanel(wxWindow* parent);
|
||||
|
||||
// accessors for the frame
|
||||
void ShowFont(const wxFont& font) { m_font = font; DoUpdate(); }
|
||||
|
||||
wxFontInfo GetFontInfo() const;
|
||||
|
||||
private:
|
||||
// Update m_useXXX flags depending on which control was changed last.
|
||||
void OnFacename(wxCommandEvent& e) { m_useFamily = false; e.Skip(); }
|
||||
void OnFamily(wxCommandEvent& e) { m_useFamily = true; e.Skip(); }
|
||||
|
||||
void OnWeightChoice(wxCommandEvent& e) { m_useNumericWeight = false; e.Skip(); }
|
||||
void OnWeightSpin(wxCommandEvent& e) { m_useNumericWeight = true; e.Skip(); }
|
||||
|
||||
|
||||
// Unlike wxFontXXX, the elements of these enum are consecutive, which is
|
||||
// more convenient here.
|
||||
enum Family
|
||||
{
|
||||
Family_Default,
|
||||
Family_Decorative,
|
||||
Family_Roman,
|
||||
Family_Script,
|
||||
Family_Swiss,
|
||||
Family_Modern,
|
||||
Family_Teletype
|
||||
};
|
||||
|
||||
enum Style
|
||||
{
|
||||
Style_Normal,
|
||||
Style_Italic,
|
||||
Style_Slant
|
||||
};
|
||||
|
||||
enum Weight
|
||||
{
|
||||
Weight_Thin,
|
||||
Weight_Extralight,
|
||||
Weight_Light,
|
||||
Weight_Normal,
|
||||
Weight_Medium,
|
||||
Weight_Semibold,
|
||||
Weight_Bold,
|
||||
Weight_Extrabold,
|
||||
Weight_Heavy,
|
||||
Weight_Extraheavy
|
||||
};
|
||||
|
||||
void DoUpdate();
|
||||
|
||||
wxFont m_font;
|
||||
|
||||
wxTextCtrl* m_textFaceName;
|
||||
wxChoice* m_choiceFamily;
|
||||
wxSpinCtrlDouble* m_spinPointSize;
|
||||
wxChoice* m_choiceStyle;
|
||||
wxChoice* m_choiceWeight;
|
||||
wxSpinCtrl* m_spinWeight;
|
||||
wxCheckBox* m_checkUnderlined;
|
||||
wxCheckBox* m_checkStrikethrough;
|
||||
wxCheckBox* m_checkFixedWidth;
|
||||
wxStaticText* m_labelInfo;
|
||||
|
||||
bool m_useFamily;
|
||||
bool m_useNumericWeight;
|
||||
};
|
||||
|
||||
// FontCanvas shows the font characters.
|
||||
class FontCanvas : public wxWindow
|
||||
{
|
||||
public:
|
||||
explicit FontCanvas( wxWindow *parent );
|
||||
|
||||
// accessors for FontWindow
|
||||
const wxFont& GetTextFont() const { return m_font; }
|
||||
const wxColour& GetColour() const { return m_colour; }
|
||||
void SetTextFont(const wxFont& font) { m_font = font; }
|
||||
@@ -76,6 +151,12 @@ public:
|
||||
// event handlers
|
||||
void OnPaint( wxPaintEvent &event );
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestClientSize() const wxOVERRIDE
|
||||
{
|
||||
return wxSize(80*GetCharWidth(), 15*GetCharHeight());
|
||||
}
|
||||
|
||||
private:
|
||||
wxColour m_colour;
|
||||
wxFont m_font;
|
||||
@@ -83,22 +164,37 @@ private:
|
||||
wxDECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
// FontWindow contains both FontPanel and FontCanvas
|
||||
class FontWindow : public wxWindow
|
||||
{
|
||||
public:
|
||||
explicit FontWindow(wxWindow *parent);
|
||||
|
||||
const wxFont& GetTextFont() const { return m_canvas->GetTextFont(); }
|
||||
const wxColour& GetColour() const { return m_canvas->GetColour(); }
|
||||
|
||||
wxFont MakeNewFont() const { return m_panel->GetFontInfo(); }
|
||||
|
||||
void UpdateFont(const wxFont& font, const wxColour& colour);
|
||||
|
||||
private:
|
||||
FontPanel* const m_panel;
|
||||
FontCanvas* const m_canvas;
|
||||
};
|
||||
|
||||
// Define a new frame type: this is going to be our main frame
|
||||
class MyFrame : public wxFrame
|
||||
{
|
||||
public:
|
||||
// ctor(s)
|
||||
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
|
||||
|
||||
// accessors
|
||||
MyCanvas *GetCanvas() const { return m_canvas; }
|
||||
MyFrame();
|
||||
|
||||
// event handlers (these functions should _not_ be virtual)
|
||||
void OnQuit(wxCommandEvent& event);
|
||||
void OnAbout(wxCommandEvent& event);
|
||||
|
||||
void OnGetBaseFont(wxCommandEvent& WXUNUSED(event))
|
||||
{ DoChangeFont(m_canvas->GetTextFont().GetBaseFont()); }
|
||||
{ DoChangeFont(m_fontWindow->GetTextFont().GetBaseFont()); }
|
||||
void OnIncFont(wxCommandEvent& WXUNUSED(event)) { DoResizeFont(+2); }
|
||||
void OnDecFont(wxCommandEvent& WXUNUSED(event)) { DoResizeFont(-2); }
|
||||
|
||||
@@ -133,6 +229,9 @@ public:
|
||||
void OnSetEncoding(wxCommandEvent& event);
|
||||
void OnPrivateFont(wxCommandEvent& event);
|
||||
|
||||
void OnFontPanelApply(wxCommandEvent& WXUNUSED(event))
|
||||
{ DoChangeFont(m_fontWindow->MakeNewFont()); }
|
||||
|
||||
protected:
|
||||
bool DoEnumerateFamilies(bool fixedWidthOnly,
|
||||
wxFontEncoding encoding = wxFONTENCODING_SYSTEM,
|
||||
@@ -149,10 +248,8 @@ protected:
|
||||
// wxFONTFAMILY_DEFAULT if the dialog was cancelled
|
||||
wxFontFamily GetFamilyFromUser();
|
||||
|
||||
size_t m_fontSize; // in points
|
||||
|
||||
wxTextCtrl *m_textctrl;
|
||||
MyCanvas *m_canvas;
|
||||
FontWindow *m_fontWindow;
|
||||
|
||||
private:
|
||||
// any class wishing to process wxWidgets events must use this macro
|
||||
@@ -292,11 +389,9 @@ bool MyApp::OnInit()
|
||||
{
|
||||
if ( !wxApp::OnInit() )
|
||||
return false;
|
||||
wxString privfont = argv[0].BeforeLast('/');
|
||||
|
||||
// Create the main application window
|
||||
MyFrame *frame = new MyFrame(wxT("Font wxWidgets demo"),
|
||||
wxPoint(50, 50), wxSize(600, 400));
|
||||
MyFrame *frame = new MyFrame();
|
||||
|
||||
// Show it
|
||||
frame->Show(true);
|
||||
@@ -312,11 +407,9 @@ bool MyApp::OnInit()
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// frame constructor
|
||||
MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||
: wxFrame((wxFrame *)NULL, wxID_ANY, title, pos, size), m_textctrl(NULL)
|
||||
MyFrame::MyFrame()
|
||||
: wxFrame(NULL, wxID_ANY, "wxWidgets font sample")
|
||||
{
|
||||
m_fontSize = wxNORMAL_FONT->GetPointSize();
|
||||
|
||||
SetIcon(wxICON(sample));
|
||||
|
||||
// create a menu bar
|
||||
@@ -447,20 +540,26 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||
|
||||
wxSplitterWindow *splitter = new wxSplitterWindow(this);
|
||||
|
||||
m_fontWindow = new FontWindow(splitter);
|
||||
|
||||
m_fontWindow->Bind(wxEVT_BUTTON, &MyFrame::OnFontPanelApply, this);
|
||||
|
||||
m_textctrl = new wxTextCtrl(splitter, wxID_ANY,
|
||||
wxT("Paste text here to see how it looks\nlike in the given font"),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxDefaultPosition,
|
||||
wxSize(-1, 6*GetCharHeight()),
|
||||
wxTE_MULTILINE);
|
||||
|
||||
m_canvas = new MyCanvas(splitter);
|
||||
|
||||
splitter->SplitHorizontally(m_textctrl, m_canvas, 100);
|
||||
splitter->SplitHorizontally(m_fontWindow, m_textctrl, 0);
|
||||
|
||||
#if wxUSE_STATUSBAR
|
||||
// create a status bar just for fun (by default with 1 pane only)
|
||||
CreateStatusBar();
|
||||
SetStatusText(wxT("Welcome to wxWidgets font demo!"));
|
||||
#endif // wxUSE_STATUSBAR
|
||||
|
||||
SetClientSize(splitter->GetBestSize());
|
||||
splitter->SetSashPosition(m_fontWindow->GetBestSize().y);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
@@ -601,7 +700,7 @@ void MyFrame::OnSetNativeDesc(wxCommandEvent& WXUNUSED(event))
|
||||
(
|
||||
wxT("Enter native font string"),
|
||||
wxT("Input font description"),
|
||||
m_canvas->GetTextFont().GetNativeFontInfoDesc(),
|
||||
m_fontWindow->GetTextFont().GetNativeFontInfoDesc(),
|
||||
this
|
||||
);
|
||||
if ( fontInfo.empty() )
|
||||
@@ -621,7 +720,7 @@ void MyFrame::OnSetNativeDesc(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
void MyFrame::OnSetNativeUserDesc(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxString fontdesc = GetCanvas()->GetTextFont().GetNativeFontInfoUserDesc();
|
||||
wxString fontdesc = m_fontWindow->GetTextFont().GetNativeFontInfoUserDesc();
|
||||
wxString fontUserInfo = wxGetTextFromUser(
|
||||
wxT("Here you can edit current font description"),
|
||||
wxT("Input font description"), fontdesc,
|
||||
@@ -646,14 +745,14 @@ void MyFrame::OnSetFamily(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxFontFamily f = GetFamilyFromUser();
|
||||
|
||||
wxFont font = m_canvas->GetTextFont();
|
||||
wxFont font = m_fontWindow->GetTextFont();
|
||||
font.SetFamily(f);
|
||||
DoChangeFont(font);
|
||||
}
|
||||
|
||||
void MyFrame::OnSetFaceName(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxString facename = GetCanvas()->GetTextFont().GetFaceName();
|
||||
wxString facename = m_fontWindow->GetTextFont().GetFaceName();
|
||||
wxString newFaceName = wxGetTextFromUser(
|
||||
wxT("Here you can edit current font face name."),
|
||||
wxT("Input font facename"), facename,
|
||||
@@ -661,7 +760,7 @@ void MyFrame::OnSetFaceName(wxCommandEvent& WXUNUSED(event))
|
||||
if (newFaceName.IsEmpty())
|
||||
return; // user clicked "Cancel" - do nothing
|
||||
|
||||
wxFont font(GetCanvas()->GetTextFont());
|
||||
wxFont font(m_fontWindow->GetTextFont());
|
||||
if (font.SetFaceName(newFaceName)) // change facename only
|
||||
{
|
||||
wxASSERT_MSG(font.IsOk(), wxT("The font should now be valid"));
|
||||
@@ -681,7 +780,7 @@ void MyFrame::OnSetEncoding(wxCommandEvent& WXUNUSED(event))
|
||||
if ( enc == wxFONTENCODING_SYSTEM )
|
||||
return;
|
||||
|
||||
wxFont font = m_canvas->GetTextFont();
|
||||
wxFont font = m_fontWindow->GetTextFont();
|
||||
font.SetEncoding(enc);
|
||||
DoChangeFont(font);
|
||||
}
|
||||
@@ -745,7 +844,7 @@ wxFontFamily MyFrame::GetFamilyFromUser()
|
||||
|
||||
void MyFrame::DoResizeFont(int diff)
|
||||
{
|
||||
wxFont font = m_canvas->GetTextFont();
|
||||
wxFont font = m_fontWindow->GetTextFont();
|
||||
|
||||
font.SetPointSize(font.GetPointSize() + diff);
|
||||
DoChangeFont(font);
|
||||
@@ -753,7 +852,7 @@ void MyFrame::DoResizeFont(int diff)
|
||||
|
||||
void MyFrame::OnBold(wxCommandEvent& event)
|
||||
{
|
||||
wxFont font = m_canvas->GetTextFont();
|
||||
wxFont font = m_fontWindow->GetTextFont();
|
||||
|
||||
font.SetWeight(event.IsChecked() ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL);
|
||||
DoChangeFont(font);
|
||||
@@ -761,7 +860,7 @@ void MyFrame::OnBold(wxCommandEvent& event)
|
||||
|
||||
void MyFrame::OnLight(wxCommandEvent& event)
|
||||
{
|
||||
wxFont font = m_canvas->GetTextFont();
|
||||
wxFont font = m_fontWindow->GetTextFont();
|
||||
|
||||
font.SetWeight(event.IsChecked() ? wxFONTWEIGHT_LIGHT : wxFONTWEIGHT_NORMAL);
|
||||
DoChangeFont(font);
|
||||
@@ -769,7 +868,7 @@ void MyFrame::OnLight(wxCommandEvent& event)
|
||||
|
||||
void MyFrame::OnItalic(wxCommandEvent& event)
|
||||
{
|
||||
wxFont font = m_canvas->GetTextFont();
|
||||
wxFont font = m_fontWindow->GetTextFont();
|
||||
|
||||
font.SetStyle(event.IsChecked() ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL);
|
||||
DoChangeFont(font);
|
||||
@@ -777,7 +876,7 @@ void MyFrame::OnItalic(wxCommandEvent& event)
|
||||
|
||||
void MyFrame::OnSlant(wxCommandEvent& event)
|
||||
{
|
||||
wxFont font = m_canvas->GetTextFont();
|
||||
wxFont font = m_fontWindow->GetTextFont();
|
||||
|
||||
font.SetStyle(event.IsChecked() ? wxFONTSTYLE_SLANT : wxFONTSTYLE_NORMAL);
|
||||
DoChangeFont(font);
|
||||
@@ -785,7 +884,7 @@ void MyFrame::OnSlant(wxCommandEvent& event)
|
||||
|
||||
void MyFrame::OnUnderline(wxCommandEvent& event)
|
||||
{
|
||||
wxFont font = m_canvas->GetTextFont();
|
||||
wxFont font = m_fontWindow->GetTextFont();
|
||||
|
||||
font.SetUnderlined(event.IsChecked());
|
||||
DoChangeFont(font);
|
||||
@@ -793,7 +892,7 @@ void MyFrame::OnUnderline(wxCommandEvent& event)
|
||||
|
||||
void MyFrame::OnStrikethrough(wxCommandEvent& event)
|
||||
{
|
||||
wxFont font = m_canvas->GetTextFont();
|
||||
wxFont font = m_fontWindow->GetTextFont();
|
||||
font.SetStrikethrough(event.IsChecked());
|
||||
DoChangeFont(font);
|
||||
}
|
||||
@@ -873,10 +972,7 @@ void MyFrame::OnwxSystemSettingsFont(wxCommandEvent& event)
|
||||
|
||||
void MyFrame::DoChangeFont(const wxFont& font, const wxColour& col)
|
||||
{
|
||||
m_canvas->SetTextFont(font);
|
||||
if ( col.IsOk() )
|
||||
m_canvas->SetColour(col);
|
||||
m_canvas->Refresh();
|
||||
m_fontWindow->UpdateFont(font, col);
|
||||
|
||||
m_textctrl->SetFont(font);
|
||||
if ( col.IsOk() )
|
||||
@@ -903,8 +999,8 @@ void MyFrame::DoChangeFont(const wxFont& font, const wxColour& col)
|
||||
void MyFrame::OnSelectFont(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxFontData data;
|
||||
data.SetInitialFont(m_canvas->GetTextFont());
|
||||
data.SetColour(m_canvas->GetColour());
|
||||
data.SetInitialFont(m_fontWindow->GetTextFont());
|
||||
data.SetColour(m_fontWindow->GetColour());
|
||||
|
||||
wxFontDialog dialog(this, data);
|
||||
if ( dialog.ShowModal() == wxID_OK )
|
||||
@@ -919,7 +1015,7 @@ void MyFrame::OnSelectFont(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
void MyFrame::OnPrivateFont(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxFont font(GetCanvas()->GetTextFont());
|
||||
wxFont font(m_fontWindow->GetTextFont());
|
||||
if (font.SetFaceName("wxprivate"))
|
||||
{
|
||||
wxASSERT_MSG( font.IsOk(), wxT("The font should now be valid")) ;
|
||||
@@ -1071,20 +1167,317 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// MyCanvas
|
||||
// FontWindow
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxBEGIN_EVENT_TABLE(MyCanvas, wxWindow)
|
||||
EVT_PAINT(MyCanvas::OnPaint)
|
||||
FontWindow::FontWindow(wxWindow *parent)
|
||||
: wxWindow(parent, wxID_ANY),
|
||||
m_panel(new FontPanel(this)),
|
||||
m_canvas(new FontCanvas(this))
|
||||
{
|
||||
wxSizer* const sizer = new wxBoxSizer(wxVERTICAL);
|
||||
sizer->Add(m_panel, wxSizerFlags().Expand().Border());
|
||||
sizer->Add(new wxStaticLine(this), wxSizerFlags().Expand());
|
||||
sizer->Add(m_canvas, wxSizerFlags(1).Expand());
|
||||
SetSizer(sizer);
|
||||
}
|
||||
|
||||
void FontWindow::UpdateFont(const wxFont& font, const wxColour& colour)
|
||||
{
|
||||
m_panel->ShowFont(font);
|
||||
|
||||
m_canvas->SetTextFont(font);
|
||||
if ( colour.IsOk() )
|
||||
m_canvas->SetColour(colour);
|
||||
m_canvas->Refresh();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// FontPanel
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
FontPanel::FontPanel(wxWindow* parent)
|
||||
: wxPanel(parent)
|
||||
{
|
||||
m_useFamily =
|
||||
m_useNumericWeight = false;
|
||||
|
||||
m_textFaceName = new wxTextCtrl(this, wxID_ANY, wxString(),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxTE_PROCESS_ENTER);
|
||||
m_textFaceName->Bind(wxEVT_TEXT, &FontPanel::OnFacename, this);
|
||||
|
||||
// Must be in sync with the Family enum.
|
||||
const wxString familiesNames[] =
|
||||
{
|
||||
"Default",
|
||||
"Decorative",
|
||||
"Roman",
|
||||
"Script",
|
||||
"Swiss",
|
||||
"Modern",
|
||||
"Teletype",
|
||||
};
|
||||
m_choiceFamily = new wxChoice(this, wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
WXSIZEOF(familiesNames), familiesNames);
|
||||
m_choiceFamily->Bind(wxEVT_CHOICE, &FontPanel::OnFamily, this);
|
||||
|
||||
m_spinPointSize = new wxSpinCtrlDouble(this, wxID_ANY, wxString(),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxSP_ARROW_KEYS,
|
||||
1.0, 100.0, 10.0, 0.1);
|
||||
|
||||
m_spinPointSize->SetInitialSize
|
||||
(
|
||||
m_spinPointSize->GetSizeFromTextSize(GetTextExtent("999.9").x)
|
||||
);
|
||||
|
||||
// Must be in sync with the Style enum.
|
||||
const wxString stylesNames[] =
|
||||
{
|
||||
"Normal",
|
||||
"Italic",
|
||||
"Slant",
|
||||
};
|
||||
|
||||
m_choiceStyle = new wxChoice(this, wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
WXSIZEOF(stylesNames), stylesNames);
|
||||
|
||||
// Must be in sync with the Weight enum.
|
||||
const wxString weightsNames[] =
|
||||
{
|
||||
"Thin",
|
||||
"Extra light",
|
||||
"Light",
|
||||
"Normal",
|
||||
"Medium",
|
||||
"Semi-bold",
|
||||
"Bold",
|
||||
"Extra bold",
|
||||
"Heavy",
|
||||
"Extra heavy",
|
||||
};
|
||||
|
||||
m_choiceWeight = new wxChoice(this, wxID_ANY,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
WXSIZEOF(weightsNames), weightsNames);
|
||||
m_choiceWeight->Bind(wxEVT_CHOICE, &FontPanel::OnWeightChoice, this);
|
||||
|
||||
m_spinWeight = new wxSpinCtrl(this, wxID_ANY, wxString(),
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxSP_ARROW_KEYS,
|
||||
1, wxFONTWEIGHT_MAX);
|
||||
m_spinWeight->SetInitialSize
|
||||
(
|
||||
m_spinWeight->GetSizeFromTextSize(GetTextExtent("9999").x)
|
||||
);
|
||||
m_spinWeight->Bind(wxEVT_SPINCTRL, &FontPanel::OnWeightSpin, this);
|
||||
|
||||
m_checkUnderlined = new wxCheckBox(this, wxID_ANY, wxString());
|
||||
m_checkStrikethrough = new wxCheckBox(this, wxID_ANY, wxString());
|
||||
m_checkFixedWidth = new wxCheckBox(this, wxID_ANY, wxString());
|
||||
m_checkFixedWidth->Disable(); // Can't be changed by the user.
|
||||
|
||||
m_labelInfo = new wxStaticText(this, wxID_ANY, "\n\n\n");
|
||||
|
||||
|
||||
const int border = wxSizerFlags::GetDefaultBorder();
|
||||
|
||||
// Columns are: label, control, gap, label, control, label, control (there
|
||||
// is no second gap column because we don't want any gap in the weight row).
|
||||
wxFlexGridSizer* const sizer = new wxFlexGridSizer(7, wxSize(border, border));
|
||||
|
||||
const wxSizerFlags flagsLabel = wxSizerFlags().CentreVertical();
|
||||
const wxSizerFlags flagsValue = wxSizerFlags().Expand().CentreVertical();
|
||||
|
||||
sizer->Add(new wxStaticText(this, wxID_ANY, "Face &name:"), flagsLabel);
|
||||
sizer->Add(m_textFaceName, flagsValue);
|
||||
|
||||
sizer->AddSpacer(2*border);
|
||||
|
||||
sizer->Add(new wxStaticText(this, wxID_ANY, "&Family:"), flagsLabel);
|
||||
sizer->Add(m_choiceFamily, flagsValue);
|
||||
|
||||
sizer->Add(new wxStaticText(this, wxID_ANY, "&Point size:"),
|
||||
wxSizerFlags().DoubleBorder(wxLEFT).CentreVertical());
|
||||
sizer->Add(m_spinPointSize, flagsValue);
|
||||
|
||||
|
||||
sizer->Add(new wxStaticText(this, wxID_ANY, "&Style:"), flagsLabel);
|
||||
sizer->Add(m_choiceStyle, flagsValue);
|
||||
|
||||
sizer->AddSpacer(0);
|
||||
|
||||
sizer->Add(new wxStaticText(this, wxID_ANY, "&Weight:"), flagsLabel);
|
||||
sizer->Add(m_choiceWeight, flagsValue);
|
||||
|
||||
sizer->Add(new wxStaticText(this, wxID_ANY, "or &raw value:"), flagsLabel);
|
||||
sizer->Add(m_spinWeight, flagsValue);
|
||||
|
||||
|
||||
sizer->Add(new wxStaticText(this, wxID_ANY, "&Underlined:"), flagsLabel);
|
||||
sizer->Add(m_checkUnderlined, flagsValue);
|
||||
|
||||
sizer->AddSpacer(0);
|
||||
|
||||
sizer->Add(new wxStaticText(this, wxID_ANY, "&Strike through:"), flagsLabel);
|
||||
sizer->Add(m_checkStrikethrough, flagsValue);
|
||||
|
||||
sizer->Add(new wxStaticText(this, wxID_ANY, "Fixed width:"), flagsLabel);
|
||||
sizer->Add(m_checkFixedWidth, flagsValue);
|
||||
|
||||
wxSizer* const sizerTop = new wxBoxSizer(wxVERTICAL);
|
||||
sizerTop->Add(sizer, wxSizerFlags().Expand().Border(wxBOTTOM));
|
||||
sizerTop->Add(new wxButton(this, wxID_APPLY, "&Apply changes"),
|
||||
wxSizerFlags().Border(wxBOTTOM).Centre());
|
||||
sizerTop->Add(m_labelInfo, wxSizerFlags().Expand().Border(wxTOP));
|
||||
SetSizer(sizerTop);
|
||||
|
||||
ShowFont(*wxNORMAL_FONT);
|
||||
}
|
||||
|
||||
void FontPanel::DoUpdate()
|
||||
{
|
||||
m_textFaceName->ChangeValue(m_font.GetFaceName());
|
||||
|
||||
Family family = Family_Default;
|
||||
switch ( m_font.GetFamily() )
|
||||
{
|
||||
case wxFONTFAMILY_DECORATIVE: family = Family_Decorative; break;
|
||||
case wxFONTFAMILY_ROMAN: family = Family_Roman; break;
|
||||
case wxFONTFAMILY_SCRIPT: family = Family_Script; break;
|
||||
case wxFONTFAMILY_SWISS: family = Family_Swiss; break;
|
||||
case wxFONTFAMILY_MODERN: family = Family_Modern; break;
|
||||
case wxFONTFAMILY_TELETYPE: family = Family_Teletype; break;
|
||||
|
||||
case wxFONTFAMILY_DEFAULT:
|
||||
case wxFONTFAMILY_UNKNOWN:
|
||||
// Leave family as Family_Default, what else can we do.
|
||||
break;
|
||||
}
|
||||
m_choiceFamily->SetSelection(family);
|
||||
|
||||
m_spinPointSize->SetValue(m_font.GetFractionalPointSize());
|
||||
|
||||
Style style = Style_Normal;
|
||||
switch ( m_font.GetStyle() )
|
||||
{
|
||||
case wxFONTSTYLE_ITALIC: style = Style_Italic; break;
|
||||
case wxFONTSTYLE_SLANT: style = Style_Slant; break;
|
||||
|
||||
case wxFONTSTYLE_NORMAL:
|
||||
case wxFONTSTYLE_MAX:
|
||||
break;
|
||||
}
|
||||
m_choiceStyle->SetSelection(style);
|
||||
|
||||
Weight weight = Weight_Normal;
|
||||
switch ( m_font.GetWeight() )
|
||||
{
|
||||
case wxFONTWEIGHT_THIN: weight = Weight_Thin; break;
|
||||
case wxFONTWEIGHT_EXTRALIGHT: weight = Weight_Extralight; break;
|
||||
case wxFONTWEIGHT_LIGHT: weight = Weight_Light; break;
|
||||
case wxFONTWEIGHT_MEDIUM: weight = Weight_Medium; break;
|
||||
case wxFONTWEIGHT_SEMIBOLD: weight = Weight_Semibold; break;
|
||||
case wxFONTWEIGHT_BOLD: weight = Weight_Bold; break;
|
||||
case wxFONTWEIGHT_EXTRABOLD: weight = Weight_Extrabold; break;
|
||||
case wxFONTWEIGHT_HEAVY: weight = Weight_Heavy; break;
|
||||
case wxFONTWEIGHT_EXTRAHEAVY: weight = Weight_Extraheavy; break;
|
||||
|
||||
case wxFONTWEIGHT_NORMAL:
|
||||
case wxFONTWEIGHT_INVALID:
|
||||
break;
|
||||
}
|
||||
m_choiceWeight->SetSelection(weight);
|
||||
m_spinWeight->SetValue(m_font.GetNumericWeight());
|
||||
|
||||
m_checkUnderlined->SetValue(m_font.GetUnderlined());
|
||||
m_checkStrikethrough->SetValue(m_font.GetStrikethrough());
|
||||
m_checkFixedWidth->SetValue(m_font.IsFixedWidth());
|
||||
|
||||
const wxSize pixelSize = m_font.GetPixelSize();
|
||||
wxClientDC dc(this);
|
||||
dc.SetFont(m_font);
|
||||
|
||||
m_labelInfo->SetLabelText
|
||||
(
|
||||
wxString::Format
|
||||
(
|
||||
"Font info string: %s\n"
|
||||
"Size in pixels: %d*%d, "
|
||||
"average char size: %d*%d",
|
||||
m_font.GetNativeFontInfoDesc(),
|
||||
pixelSize.x, pixelSize.y,
|
||||
dc.GetCharWidth(), dc.GetCharHeight()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
wxFontInfo FontPanel::GetFontInfo() const
|
||||
{
|
||||
wxFontInfo info(m_spinPointSize->GetValue());
|
||||
|
||||
if ( m_useFamily )
|
||||
{
|
||||
const wxFontFamily families[] =
|
||||
{
|
||||
wxFONTFAMILY_DEFAULT,
|
||||
wxFONTFAMILY_DECORATIVE,
|
||||
wxFONTFAMILY_ROMAN,
|
||||
wxFONTFAMILY_SCRIPT,
|
||||
wxFONTFAMILY_SWISS,
|
||||
wxFONTFAMILY_MODERN,
|
||||
wxFONTFAMILY_TELETYPE,
|
||||
};
|
||||
info.Family(families[m_choiceFamily->GetSelection()]);
|
||||
}
|
||||
else
|
||||
{
|
||||
info.FaceName(m_textFaceName->GetValue());
|
||||
}
|
||||
|
||||
switch ( m_choiceStyle->GetSelection() )
|
||||
{
|
||||
case Style_Normal:
|
||||
break;
|
||||
|
||||
case Style_Italic:
|
||||
info.Italic();
|
||||
break;
|
||||
|
||||
case Style_Slant:
|
||||
info.Slant();
|
||||
break;
|
||||
}
|
||||
|
||||
info.Weight(m_useNumericWeight ? m_spinWeight->GetValue()
|
||||
: (m_choiceWeight->GetSelection() + 1)*100);
|
||||
|
||||
if ( m_checkUnderlined->GetValue() )
|
||||
info.Underlined();
|
||||
if ( m_checkStrikethrough->GetValue() )
|
||||
info.Strikethrough();
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// FontCanvas
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxBEGIN_EVENT_TABLE(FontCanvas, wxWindow)
|
||||
EVT_PAINT(FontCanvas::OnPaint)
|
||||
wxEND_EVENT_TABLE()
|
||||
|
||||
MyCanvas::MyCanvas( wxWindow *parent )
|
||||
FontCanvas::FontCanvas( wxWindow *parent )
|
||||
: wxWindow( parent, wxID_ANY ),
|
||||
m_colour(*wxRED), m_font(*wxNORMAL_FONT)
|
||||
{
|
||||
}
|
||||
|
||||
void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
||||
void FontCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
PrepareDC(dc);
|
||||
@@ -1094,55 +1487,10 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
|
||||
dc.Clear();
|
||||
dc.SetFont(m_font);
|
||||
|
||||
// one text line height
|
||||
wxCoord hLine = dc.GetCharHeight();
|
||||
|
||||
// the current text origin
|
||||
wxCoord x = 5,
|
||||
y = 5;
|
||||
|
||||
// output the font name/info
|
||||
wxString fontInfo;
|
||||
|
||||
fontInfo.Printf(wxT("Face name: %s, family: %s"),
|
||||
m_font.GetFaceName().c_str(),
|
||||
m_font.GetFamilyString().c_str());
|
||||
|
||||
dc.DrawText(fontInfo, x, y);
|
||||
y += hLine;
|
||||
|
||||
fontInfo.Printf(wxT("Size: %d points or %d pixels; %d*%d average char size"),
|
||||
m_font.GetPointSize(),
|
||||
m_font.GetPixelSize().y,
|
||||
dc.GetCharWidth(), dc.GetCharHeight());
|
||||
|
||||
dc.DrawText(fontInfo, x, y);
|
||||
y += hLine;
|
||||
|
||||
fontInfo.Printf(wxT("Style: %s, weight: %s, fixed width: %s, encoding: %s"),
|
||||
m_font.GetStyleString().c_str(),
|
||||
m_font.GetWeightString().c_str(),
|
||||
m_font.IsFixedWidth() ? wxT("yes") : wxT("no"),
|
||||
wxFontMapper::GetEncodingDescription(m_font.GetEncoding()));
|
||||
|
||||
dc.DrawText(fontInfo, x, y);
|
||||
y += hLine;
|
||||
|
||||
if ( m_font.IsOk() )
|
||||
{
|
||||
const wxNativeFontInfo *info = m_font.GetNativeFontInfo();
|
||||
if ( info )
|
||||
{
|
||||
wxString fontDesc = m_font.GetNativeFontInfoUserDesc();
|
||||
fontInfo.Printf(wxT("Native font info: %s"), fontDesc.c_str());
|
||||
|
||||
dc.DrawText(fontInfo, x, y);
|
||||
y += hLine;
|
||||
}
|
||||
}
|
||||
|
||||
y += hLine;
|
||||
|
||||
// prepare to draw the font
|
||||
dc.SetTextForeground(m_colour);
|
||||
|
||||
|
@@ -244,8 +244,7 @@ MyFrame::MyFrame(const wxString& title)
|
||||
wxTE_MULTILINE|wxTE_READONLY|wxHSCROLL);
|
||||
|
||||
// set monospace font to have output in nice columns
|
||||
wxFont font(9, wxFONTFAMILY_TELETYPE,
|
||||
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
wxFont font(wxFontInfo(9).Family(wxFONTFAMILY_TELETYPE));
|
||||
headerText->SetFont(font);
|
||||
m_evtConsole->SetFont(font);
|
||||
|
||||
|
@@ -206,8 +206,7 @@ MyFrame::MyFrame(const wxString& title)
|
||||
wxTE_MULTILINE|wxTE_READONLY|wxTE_RICH|wxHSCROLL);
|
||||
|
||||
// set monospace font to have output in nice columns
|
||||
wxFont font(10, wxFONTFAMILY_TELETYPE,
|
||||
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
wxFont font(wxFontInfo(10).Family(wxFONTFAMILY_TELETYPE));
|
||||
headerText->SetFont(font);
|
||||
m_logText->SetFont(font);
|
||||
|
||||
|
@@ -489,7 +489,7 @@ bool MyGLCanvas::oglInit()
|
||||
int swi = 0, shi = 0; //Image sizes
|
||||
wxString stg("wxWidgets");
|
||||
// Set the font. Use a big pointsize so as to smoothing edges.
|
||||
wxFont font(48, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
wxFont font(wxFontInfo(48).Family(wxFONTFAMILY_MODERN));
|
||||
if ( !font.IsOk() )
|
||||
font = *wxSWISS_FONT;
|
||||
wxColour bgrdColo(*wxBLACK);
|
||||
|
@@ -387,7 +387,7 @@ MyFrame::MyFrame()
|
||||
sizer_panelsizer_h->Add(sizer_panelsizer_v, 0);
|
||||
sizer_panel->SetSizer(sizer_panelsizer_h);
|
||||
|
||||
wxFont label_font(8, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_LIGHT);
|
||||
wxFont label_font(wxFontInfo(8).Light());
|
||||
m_bitmap_creation_dc.SetFont(label_font);
|
||||
|
||||
wxRibbonPage* scheme = new wxRibbonPage(m_ribbon, wxID_ANY, wxT("Appearance"), eye_xpm);
|
||||
|
@@ -248,7 +248,7 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
||||
text->SetBackgroundColour(*wxWHITE);
|
||||
text->SetForegroundColour(*wxBLACK);
|
||||
wxFont font = text->GetFont();
|
||||
font.SetPointSize(2*font.GetPointSize()/3);
|
||||
font.SetFractionalPointSize(2.0*font.GetFractionalPointSize()/3.0);
|
||||
text->SetFont(font);
|
||||
#endif
|
||||
}
|
||||
|
@@ -402,8 +402,7 @@ MyFrame::MyFrame(const wxString& title)
|
||||
wxLog::SetActiveTarget(this);
|
||||
|
||||
// use fixed width font to align output in nice columns
|
||||
wxFont font(wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_TELETYPE,
|
||||
wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
wxFont font(wxFontInfo().Family(wxFONTFAMILY_TELETYPE));
|
||||
header->SetFont(font);
|
||||
m_txtctrl->SetFont(font);
|
||||
|
||||
|
@@ -347,7 +347,6 @@
|
||||
<object class="sizeritem">
|
||||
<flag>wxGROW|wxALL</flag>
|
||||
<border>5</border>
|
||||
<option>1</option>
|
||||
<object class="wxCollapsiblePane" name="controls_collpane">
|
||||
<label>Details:</label>
|
||||
<collapsed>0</collapsed>
|
||||
@@ -1096,6 +1095,24 @@ lay them out using wxSizers, absolute positioning, everything you like!
|
||||
<label>It was a dark and stormy night.</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<flag>wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL|wxALL</flag>
|
||||
<border>5</border>
|
||||
<object class="wxStaticText" name="wxID_STATIC">
|
||||
<label>Slightly larger strikethrough font:</label>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<flag>wxALIGN_LEFT|wxALIGN_CENTRE_VERTICAL</flag>
|
||||
<border>5</border>
|
||||
<object class="wxStaticText" name="controls_statictext">
|
||||
<label>It was a dark and stormy night.</label>
|
||||
<font>
|
||||
<size>12.5</size>
|
||||
<strikethrough>1</strikethrough>
|
||||
</font>
|
||||
</object>
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<flag>wxALIGN_RIGHT|wxALIGN_CENTRE_VERTICAL|wxALL</flag>
|
||||
<border>5</border>
|
||||
@@ -1127,7 +1144,7 @@ lay them out using wxSizers, absolute positioning, everything you like!
|
||||
<label>It was a dark and stormy night.</label>
|
||||
<font>
|
||||
<inherit>1</inherit>
|
||||
<weight>bold</weight>
|
||||
<weight>700</weight> <!-- same as "bold" -->
|
||||
</font>
|
||||
</object>
|
||||
</object>
|
||||
@@ -1494,7 +1511,6 @@ lay them out using wxSizers, absolute positioning, everything you like!
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<flag>wxGROW|wxALL</flag>
|
||||
<option>1</option>
|
||||
<border>5</border>
|
||||
<object class="wxColourPickerCtrl" name="controls_colourpicker">
|
||||
<value>#00ff00</value>
|
||||
@@ -1510,7 +1526,6 @@ lay them out using wxSizers, absolute positioning, everything you like!
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<flag>wxGROW|wxALL</flag>
|
||||
<option>1</option>
|
||||
<border>5</border>
|
||||
<object class="wxFilePickerCtrl" name="controls_filepicker">
|
||||
<message>Here goes a message</message>
|
||||
@@ -1528,7 +1543,6 @@ lay them out using wxSizers, absolute positioning, everything you like!
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<flag>wxGROW|wxALL</flag>
|
||||
<option>1</option>
|
||||
<border>5</border>
|
||||
<object class="wxDirPickerCtrl" name="controls_dirpicker">
|
||||
<value/>
|
||||
@@ -1545,7 +1559,6 @@ lay them out using wxSizers, absolute positioning, everything you like!
|
||||
</object>
|
||||
<object class="sizeritem">
|
||||
<flag>wxGROW|wxALL</flag>
|
||||
<option>1</option>
|
||||
<border>5</border>
|
||||
<object class="wxFontPickerCtrl" name="controls_fontpicker">
|
||||
<style>wxFNTP_USEFONT_FOR_LABEL</style>
|
||||
|
@@ -28,7 +28,6 @@
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/dc.h"
|
||||
#include "wx/intl.h"
|
||||
#include "wx/math.h"
|
||||
#include "wx/dcscreen.h"
|
||||
#include "wx/log.h"
|
||||
#include "wx/gdicmn.h"
|
||||
@@ -51,20 +50,12 @@ extern const char *wxDumpFont(const wxFont *font)
|
||||
{
|
||||
static char buf[256];
|
||||
|
||||
const wxFontWeight weight = font->GetWeight();
|
||||
|
||||
wxString s;
|
||||
s.Printf(wxS("%s-%s-%s-%d-%d"),
|
||||
s.Printf(wxS("%s-%d-%s-%.2f-%d"),
|
||||
font->GetFaceName(),
|
||||
weight == wxFONTWEIGHT_NORMAL
|
||||
? wxT("normal")
|
||||
: weight == wxFONTWEIGHT_BOLD
|
||||
? wxT("bold")
|
||||
: wxT("light"),
|
||||
font->GetStyle() == wxFONTSTYLE_NORMAL
|
||||
? wxT("regular")
|
||||
: wxT("italic"),
|
||||
font->GetPointSize(),
|
||||
font->GetNumericWeight(),
|
||||
font->GetStyle() == wxFONTSTYLE_NORMAL ? "regular" : "italic",
|
||||
font->GetFractionalPointSize(),
|
||||
font->GetEncoding());
|
||||
|
||||
wxStrlcpy(buf, s.mb_str(), WXSIZEOF(buf));
|
||||
@@ -232,9 +223,36 @@ bool wxFontBase::IsFixedWidth() const
|
||||
return GetFamily() == wxFONTFAMILY_TELETYPE;
|
||||
}
|
||||
|
||||
|
||||
// Convert to/from wxFontWeight enum elements and numeric weight values.
|
||||
|
||||
/* static */
|
||||
int wxFontBase::ConvertFromLegacyWeightIfNecessary(int weight)
|
||||
{
|
||||
switch ( weight )
|
||||
{
|
||||
case 90: return wxFONTWEIGHT_NORMAL;
|
||||
case 91: return wxFONTWEIGHT_LIGHT;
|
||||
case 92: return wxFONTWEIGHT_BOLD;
|
||||
default: return weight;
|
||||
}
|
||||
}
|
||||
|
||||
/* static */
|
||||
int wxFontBase::GetNumericWeightOf(wxFontWeight weight_)
|
||||
{
|
||||
const int weight = ConvertFromLegacyWeightIfNecessary(weight_);
|
||||
|
||||
wxASSERT(weight > wxFONTWEIGHT_INVALID);
|
||||
wxASSERT(weight <= wxFONTWEIGHT_MAX);
|
||||
wxASSERT(weight % 100 == 0);
|
||||
|
||||
return weight;
|
||||
}
|
||||
|
||||
int wxFontBase::GetPointSize() const
|
||||
{
|
||||
return wxRound(GetFractionalPointSize());
|
||||
return wxFontInfo::ToIntPointSize(GetFractionalPointSize());
|
||||
}
|
||||
|
||||
|
||||
@@ -245,11 +263,23 @@ wxSize wxFontBase::GetPixelSize() const
|
||||
return wxSize(dc.GetCharWidth(), dc.GetCharHeight());
|
||||
}
|
||||
|
||||
wxFontWeight wxFontBase::GetWeight() const
|
||||
{
|
||||
wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX, "invalid font" );
|
||||
|
||||
return wxFontInfo::GetWeightClosestToNumericValue(GetNumericWeight());
|
||||
}
|
||||
|
||||
bool wxFontBase::IsUsingSizeInPixels() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void wxFontBase::SetPointSize(int pointSize)
|
||||
{
|
||||
SetFractionalPointSize(wxFontInfo::ToFloatPointSize(pointSize));
|
||||
}
|
||||
|
||||
void wxFontBase::SetPixelSize( const wxSize& pixelSize )
|
||||
{
|
||||
wxCHECK_RET( pixelSize.GetWidth() >= 0 && pixelSize.GetHeight() > 0,
|
||||
@@ -313,13 +343,18 @@ void wxFontBase::SetPixelSize( const wxSize& pixelSize )
|
||||
SetPointSize(largestGood);
|
||||
}
|
||||
|
||||
void wxFontBase::SetWeight(wxFontWeight weight)
|
||||
{
|
||||
SetNumericWeight(GetNumericWeightOf(weight));
|
||||
}
|
||||
|
||||
void wxFontBase::DoSetNativeFontInfo(const wxNativeFontInfo& info)
|
||||
{
|
||||
#ifdef wxNO_NATIVE_FONTINFO
|
||||
SetPointSize(info.pointSize);
|
||||
SetFractionalPointSize(info.pointSize);
|
||||
SetFamily(info.family);
|
||||
SetStyle(info.style);
|
||||
SetWeight(info.weight);
|
||||
SetNumericWeight(info.weight);
|
||||
SetUnderlined(info.underlined);
|
||||
SetStrikethrough(info.strikethrough);
|
||||
SetFaceName(info.faceName);
|
||||
@@ -497,6 +532,74 @@ bool wxFontBase::SetFaceName(const wxString& facename)
|
||||
return true;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
void InitInfoWithLegacyParams(wxFontInfo& info,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
wxFontWeight weight,
|
||||
bool underlined,
|
||||
const wxString& face,
|
||||
wxFontEncoding encoding)
|
||||
{
|
||||
if ( static_cast<int>(style) == wxDEFAULT )
|
||||
style = wxFONTSTYLE_NORMAL;
|
||||
|
||||
if ( static_cast<int>(weight) == wxDEFAULT )
|
||||
weight = wxFONTWEIGHT_NORMAL;
|
||||
|
||||
info
|
||||
.Family(family)
|
||||
.Style(style)
|
||||
.Weight(wxFontBase::GetNumericWeightOf(weight))
|
||||
.Underlined(underlined)
|
||||
.FaceName(face)
|
||||
.Encoding(encoding);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
/* static */
|
||||
wxFontInfo wxFontBase::InfoFromLegacyParams(int pointSize,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
wxFontWeight weight,
|
||||
bool underlined,
|
||||
const wxString& face,
|
||||
wxFontEncoding encoding)
|
||||
{
|
||||
// Old code specifies wxDEFAULT instead of -1 or wxNORMAL instead of the
|
||||
// new type-safe wxFONTSTYLE_NORMAL or wxFONTWEIGHT_NORMAL, continue
|
||||
// handling this for compatibility.
|
||||
if ( pointSize == wxDEFAULT )
|
||||
pointSize = -1;
|
||||
|
||||
wxFontInfo info(pointSize);
|
||||
|
||||
InitInfoWithLegacyParams(info,
|
||||
family, style, weight, underlined, face, encoding);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
/* static */
|
||||
wxFontInfo wxFontBase::InfoFromLegacyParams(const wxSize& pixelSize,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
wxFontWeight weight,
|
||||
bool underlined,
|
||||
const wxString& face,
|
||||
wxFontEncoding encoding)
|
||||
{
|
||||
wxFontInfo info(pixelSize);
|
||||
|
||||
InitInfoWithLegacyParams(info,
|
||||
family, style, weight, underlined, face, encoding);
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
void wxFontBase::SetSymbolicSize(wxFontSymbolicSize size)
|
||||
{
|
||||
SetSymbolicSizeRelativeTo(size, wxNORMAL_FONT->GetPointSize());
|
||||
@@ -584,7 +687,7 @@ wxFont& wxFont::MakeStrikethrough()
|
||||
|
||||
wxFont& wxFont::Scale(float x)
|
||||
{
|
||||
SetPointSize(int(x*GetPointSize() + 0.5));
|
||||
SetFractionalPointSize(x*GetFractionalPointSize());
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -621,6 +724,15 @@ void wxNativeFontInfo::SetFaceName(const wxArrayString& facenames)
|
||||
#endif // wxUSE_FONTENUM/!wxUSE_FONTENUM
|
||||
}
|
||||
|
||||
int wxNativeFontInfo::GetPointSize() const
|
||||
{
|
||||
return wxFontInfo::ToIntPointSize(GetFractionalPointSize());
|
||||
}
|
||||
|
||||
void wxNativeFontInfo::SetPointSize(int pointsize)
|
||||
{
|
||||
SetFractionalPointSize(wxFontInfo::ToFloatPointSize(pointsize));
|
||||
}
|
||||
|
||||
#ifdef wxNO_NATIVE_FONTINFO
|
||||
|
||||
@@ -635,6 +747,7 @@ void wxNativeFontInfo::SetFaceName(const wxArrayString& facenames)
|
||||
bool wxNativeFontInfo::FromString(const wxString& s)
|
||||
{
|
||||
long l;
|
||||
double d;
|
||||
unsigned long version;
|
||||
|
||||
wxStringTokenizer tokenizer(s, wxT(";"));
|
||||
@@ -644,9 +757,11 @@ bool wxNativeFontInfo::FromString(const wxString& s)
|
||||
return false;
|
||||
|
||||
token = tokenizer.GetNextToken();
|
||||
if ( !token.ToLong(&l) )
|
||||
if ( !token.ToCDouble(&d) )
|
||||
return false;
|
||||
pointSize = static_cast<float>(d);
|
||||
if ( static_cast<double>(pointSize) != d )
|
||||
return false;
|
||||
pointSize = (int)l;
|
||||
|
||||
token = tokenizer.GetNextToken();
|
||||
if ( !token.ToLong(&l) )
|
||||
@@ -661,7 +776,9 @@ bool wxNativeFontInfo::FromString(const wxString& s)
|
||||
token = tokenizer.GetNextToken();
|
||||
if ( !token.ToLong(&l) )
|
||||
return false;
|
||||
weight = (wxFontWeight)l;
|
||||
weight = ConvertFromLegacyWeightIfNecessary(l);
|
||||
if ( weight <= wxFONTWEIGHT_INVALID || weight > wxFONTWEIGHT_MAX )
|
||||
return false;
|
||||
|
||||
token = tokenizer.GetNextToken();
|
||||
if ( !token.ToLong(&l) )
|
||||
@@ -695,12 +812,12 @@ wxString wxNativeFontInfo::ToString() const
|
||||
{
|
||||
wxString s;
|
||||
|
||||
s.Printf(wxT("%d;%d;%d;%d;%d;%d;%d;%s;%d"),
|
||||
s.Printf(wxT("%d;%f;%d;%d;%d;%d;%d;%s;%d"),
|
||||
1, // version
|
||||
pointSize,
|
||||
GetFractionalPointSize(),
|
||||
family,
|
||||
(int)style,
|
||||
(int)weight,
|
||||
weight,
|
||||
underlined,
|
||||
strikethrough,
|
||||
faceName.GetData(),
|
||||
@@ -711,7 +828,7 @@ wxString wxNativeFontInfo::ToString() const
|
||||
|
||||
void wxNativeFontInfo::Init()
|
||||
{
|
||||
pointSize = 0;
|
||||
pointSize = 0.0f;
|
||||
family = wxFONTFAMILY_DEFAULT;
|
||||
style = wxFONTSTYLE_NORMAL;
|
||||
weight = wxFONTWEIGHT_NORMAL;
|
||||
@@ -721,7 +838,7 @@ void wxNativeFontInfo::Init()
|
||||
encoding = wxFONTENCODING_DEFAULT;
|
||||
}
|
||||
|
||||
int wxNativeFontInfo::GetPointSize() const
|
||||
float wxNativeFontInfo::GetFractionalPointSize() const
|
||||
{
|
||||
return pointSize;
|
||||
}
|
||||
@@ -731,7 +848,7 @@ wxFontStyle wxNativeFontInfo::GetStyle() const
|
||||
return style;
|
||||
}
|
||||
|
||||
wxFontWeight wxNativeFontInfo::GetWeight() const
|
||||
int wxNativeFontInfo::GetNumericWeight() const
|
||||
{
|
||||
return weight;
|
||||
}
|
||||
@@ -761,7 +878,7 @@ wxFontEncoding wxNativeFontInfo::GetEncoding() const
|
||||
return encoding;
|
||||
}
|
||||
|
||||
void wxNativeFontInfo::SetPointSize(int pointsize)
|
||||
void wxNativeFontInfo::SetFractionalPointSize(float pointsize)
|
||||
{
|
||||
pointSize = pointsize;
|
||||
}
|
||||
@@ -771,7 +888,7 @@ void wxNativeFontInfo::SetStyle(wxFontStyle style_)
|
||||
style = style_;
|
||||
}
|
||||
|
||||
void wxNativeFontInfo::SetWeight(wxFontWeight weight_)
|
||||
void wxNativeFontInfo::SetNumericWeight(int weight_)
|
||||
{
|
||||
weight = weight_;
|
||||
}
|
||||
@@ -1213,7 +1330,7 @@ bool wxNativeFontInfo::FromUserString(const wxString& s)
|
||||
|
||||
// set point size to default value if size was not given
|
||||
if ( !pointsizefound )
|
||||
SetPointSize(wxNORMAL_FONT->GetPointSize());
|
||||
SetFractionalPointSize(wxNORMAL_FONT->GetFractionalPointSize());
|
||||
|
||||
// set font weight to default value if weight was not given
|
||||
if ( !weightfound )
|
||||
@@ -1234,36 +1351,14 @@ bool wxNativeFontInfo::FromUserString(const wxString& s)
|
||||
|
||||
wxFontWeight wxNativeFontInfo::GetWeight() const
|
||||
{
|
||||
// round to nearest hundredth = wxFONTWEIGHT_ constant
|
||||
int weight = ((GetNumericWeight() + 50) / 100) * 100;
|
||||
|
||||
if (weight < wxFONTWEIGHT_THIN)
|
||||
weight = wxFONTWEIGHT_THIN;
|
||||
if (weight > wxFONTWEIGHT_MAX)
|
||||
weight = wxFONTWEIGHT_MAX;
|
||||
|
||||
return (wxFontWeight)weight;
|
||||
return wxFontInfo::GetWeightClosestToNumericValue(GetNumericWeight());
|
||||
}
|
||||
|
||||
void wxNativeFontInfo::SetWeight(wxFontWeight weight)
|
||||
{
|
||||
// deal with compatibility constants
|
||||
if (weight >= 90 && weight <= 92)
|
||||
{
|
||||
if (weight == 90 /* wxNORMAL */)
|
||||
weight = wxFONTWEIGHT_NORMAL;
|
||||
else if (weight == 91 /* wxLIGHT */)
|
||||
weight = wxFONTWEIGHT_LIGHT;
|
||||
else if (weight == 92 /* wxBOLD */)
|
||||
weight = wxFONTWEIGHT_BOLD;
|
||||
}
|
||||
|
||||
wxASSERT(weight > wxFONTWEIGHT_INVALID || weight <= wxFONTWEIGHT_MAX);
|
||||
wxASSERT(weight % 100 == 0);
|
||||
|
||||
wxFontWeight formerWeight = GetWeight();
|
||||
if (formerWeight != weight)
|
||||
SetNumericWeight(weight);
|
||||
const int numWeight = wxFontBase::GetNumericWeightOf(weight);
|
||||
if ( numWeight != GetNumericWeight() )
|
||||
SetNumericWeight(numWeight);
|
||||
}
|
||||
|
||||
// wxFont <-> wxString utilities, used by wxConfig
|
||||
|
@@ -118,7 +118,7 @@ wxFontBundleBase::GetFaceForFont(const wxFontMgrFontRefData& font) const
|
||||
|
||||
int type = FaceType_Regular;
|
||||
|
||||
if ( font.GetWeight() == wxFONTWEIGHT_BOLD )
|
||||
if ( font.GetNumericWeight() >= wxFONTWEIGHT_BOLD )
|
||||
type |= FaceType_Bold;
|
||||
|
||||
// FIXME -- this should read "if ( font->GetStyle() == wxFONTSTYLE_ITALIC )",
|
||||
@@ -227,7 +227,7 @@ void wxFontsManagerBase::AddBundle(wxFontBundle *bundle)
|
||||
wxFontMgrFontRefData::wxFontMgrFontRefData(int size,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
wxFontWeight weight,
|
||||
int weight,
|
||||
bool underlined,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding)
|
||||
@@ -240,7 +240,7 @@ wxFontMgrFontRefData::wxFontMgrFontRefData(int size,
|
||||
m_info.family = (wxFontFamily)family;
|
||||
m_info.faceName = faceName;
|
||||
m_info.style = (wxFontStyle)style;
|
||||
m_info.weight = (wxFontWeight)weight;
|
||||
m_info.weight = weight;
|
||||
m_info.pointSize = size;
|
||||
m_info.underlined = underlined;
|
||||
m_info.encoding = encoding;
|
||||
@@ -281,7 +281,7 @@ wxFontMgrFontRefData::GetFontInstance(float scale, bool antialiased) const
|
||||
antialiased);
|
||||
}
|
||||
|
||||
void wxFontMgrFontRefData::SetPointSize(int pointSize)
|
||||
void wxFontMgrFontRefData::SetFractionalPointSize(float pointSize)
|
||||
{
|
||||
m_info.pointSize = pointSize;
|
||||
m_fontValid = false;
|
||||
@@ -299,7 +299,7 @@ void wxFontMgrFontRefData::SetStyle(wxFontStyle style)
|
||||
m_fontValid = false;
|
||||
}
|
||||
|
||||
void wxFontMgrFontRefData::SetWeight(wxFontWeight weight)
|
||||
void wxFontMgrFontRefData::SetNumericWeight(int weight)
|
||||
{
|
||||
m_info.weight = weight;
|
||||
m_fontValid = false;
|
||||
|
@@ -1020,22 +1020,22 @@ void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant )
|
||||
// adjust the font height to correspond to our new variant (notice that
|
||||
// we're only called if something really changed)
|
||||
wxFont font = GetFont();
|
||||
int size = font.GetPointSize();
|
||||
float size = font.GetFractionalPointSize();
|
||||
switch ( variant )
|
||||
{
|
||||
case wxWINDOW_VARIANT_NORMAL:
|
||||
break;
|
||||
|
||||
case wxWINDOW_VARIANT_SMALL:
|
||||
size = wxRound(size / 1.2);
|
||||
size /= 1.2f;
|
||||
break;
|
||||
|
||||
case wxWINDOW_VARIANT_MINI:
|
||||
size = wxRound(size / (1.2 * 1.2));
|
||||
size /= 1.2f * 1.2f;
|
||||
break;
|
||||
|
||||
case wxWINDOW_VARIANT_LARGE:
|
||||
size = wxRound(size * 1.2);
|
||||
size *= 1.2f;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -1043,7 +1043,7 @@ void wxWindowBase::DoSetWindowVariant( wxWindowVariant variant )
|
||||
break;
|
||||
}
|
||||
|
||||
font.SetPointSize(size);
|
||||
font.SetFractionalPointSize(size);
|
||||
SetFont(font);
|
||||
}
|
||||
|
||||
|
@@ -40,8 +40,14 @@ typedef wxFontMgrFontRefData wxFontRefData;
|
||||
|
||||
bool wxFont::Create(const wxNativeFontInfo& info)
|
||||
{
|
||||
return Create(info.pointSize, info.family, info.style, info.weight,
|
||||
info.underlined, info.faceName, info.encoding);
|
||||
m_refData = new wxFontRefData(info.pointSize,
|
||||
info.family,
|
||||
info.style,
|
||||
info.weight,
|
||||
info.underlined,
|
||||
info.faceName,
|
||||
info.encoding);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxFont::Create(int pointSize,
|
||||
@@ -81,11 +87,11 @@ wxIDirectFBFontPtr wxFont::GetDirectFBFont(bool antialiased) const
|
||||
return i ? i->GetDirectFBFont() : wxIDirectFBFontPtr();
|
||||
}
|
||||
|
||||
int wxFont::GetPointSize() const
|
||||
float wxFont::GetFractionalPointSize() const
|
||||
{
|
||||
wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
|
||||
|
||||
return M_FONTDATA->GetPointSize();
|
||||
return M_FONTDATA->GetFractionalPointSize();
|
||||
}
|
||||
|
||||
wxString wxFont::GetFaceName() const
|
||||
@@ -107,11 +113,11 @@ wxFontStyle wxFont::GetStyle() const
|
||||
return M_FONTDATA->GetStyle();
|
||||
}
|
||||
|
||||
wxFontWeight wxFont::GetWeight() const
|
||||
int wxFont::GetNumericWeight() const
|
||||
{
|
||||
wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX, wxT("invalid font") );
|
||||
|
||||
return M_FONTDATA->GetWeight();
|
||||
return M_FONTDATA->GetNumericWeight();
|
||||
}
|
||||
|
||||
bool wxFont::GetUnderlined() const
|
||||
@@ -147,10 +153,10 @@ const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
|
||||
// change font attributes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxFont::SetPointSize(int pointSize)
|
||||
void wxFont::SetFractionalPointSize(float pointSize)
|
||||
{
|
||||
AllocExclusive();
|
||||
M_FONTDATA->SetPointSize(pointSize);
|
||||
M_FONTDATA->SetFractionalPointSize(pointSize);
|
||||
}
|
||||
|
||||
void wxFont::SetFamily(wxFontFamily family)
|
||||
@@ -165,10 +171,10 @@ void wxFont::SetStyle(wxFontStyle style)
|
||||
M_FONTDATA->SetStyle(style);
|
||||
}
|
||||
|
||||
void wxFont::SetWeight(wxFontWeight weight)
|
||||
void wxFont::SetNumericWeight(int weight)
|
||||
{
|
||||
AllocExclusive();
|
||||
M_FONTDATA->SetWeight(weight);
|
||||
M_FONTDATA->SetNumericWeight(weight);
|
||||
}
|
||||
|
||||
bool wxFont::SetFaceName(const wxString& faceName)
|
||||
|
@@ -147,7 +147,7 @@ bool wxGenericAboutDialog::Create(const wxAboutDialogInfo& info, wxWindow* paren
|
||||
nameAndVersion << wxT(' ') << info.GetVersion();
|
||||
wxStaticText *label = new wxStaticText(this, wxID_ANY, nameAndVersion);
|
||||
wxFont fontBig(*wxNORMAL_FONT);
|
||||
fontBig.SetPointSize(fontBig.GetPointSize() + 2);
|
||||
fontBig.SetFractionalPointSize(fontBig.GetFractionalPointSize() + 2.0);
|
||||
fontBig.SetWeight(wxFONTWEIGHT_BOLD);
|
||||
label->SetFont(fontBig);
|
||||
|
||||
|
@@ -213,7 +213,7 @@ wxTipDialog::wxTipDialog(wxWindow *parent,
|
||||
if (!isPda)
|
||||
{
|
||||
wxFont font = text->GetFont();
|
||||
font.SetPointSize(int(1.6 * font.GetPointSize()));
|
||||
font.SetFractionalPointSize(1.6 * font.GetFractionalPointSize());
|
||||
font.SetWeight(wxFONTWEIGHT_BOLD);
|
||||
text->SetFont(font);
|
||||
}
|
||||
|
123
src/gtk/font.cpp
123
src/gtk/font.cpp
@@ -32,13 +32,6 @@
|
||||
|
||||
#include "wx/gtk/private.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// the default size (in points) for the fonts
|
||||
static const int wxDEFAULT_FONT_SIZE = 12;
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFontRefData
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -46,26 +39,17 @@ static const int wxDEFAULT_FONT_SIZE = 12;
|
||||
class wxFontRefData : public wxGDIRefData
|
||||
{
|
||||
public:
|
||||
// from broken down font parameters, also default ctor
|
||||
wxFontRefData(int size = -1,
|
||||
wxFontFamily family = wxFONTFAMILY_DEFAULT,
|
||||
wxFontStyle style = wxFONTSTYLE_NORMAL,
|
||||
wxFontWeight weight = wxFONTWEIGHT_NORMAL,
|
||||
bool underlined = false,
|
||||
bool strikethrough = false,
|
||||
const wxString& faceName = wxEmptyString,
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
||||
// main and also default ctor
|
||||
wxFontRefData(const wxFontInfo& info = wxFontInfo());
|
||||
|
||||
wxFontRefData(const wxString& nativeFontInfoString);
|
||||
|
||||
// copy ctor
|
||||
wxFontRefData( const wxFontRefData& data );
|
||||
|
||||
virtual ~wxFontRefData();
|
||||
|
||||
// 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
|
||||
void SetPointSize(float pointSize);
|
||||
void SetFractionalPointSize(float pointSize);
|
||||
void SetFamily(wxFontFamily family);
|
||||
void SetStyle(wxFontStyle style);
|
||||
void SetWeight(wxFontWeight weight);
|
||||
@@ -79,16 +63,6 @@ public:
|
||||
void SetNativeFontInfo(const wxNativeFontInfo& info);
|
||||
|
||||
protected:
|
||||
// common part of all ctors
|
||||
void Init(int pointSize,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
wxFontWeight weight,
|
||||
bool underlined,
|
||||
bool strikethrough,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding);
|
||||
|
||||
// set all fields from (already initialized and valid) m_nativeFontInfo
|
||||
void InitFromNative();
|
||||
|
||||
@@ -106,49 +80,30 @@ private:
|
||||
// wxFontRefData
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxFontRefData::Init(int pointSize,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
wxFontWeight weight,
|
||||
bool underlined,
|
||||
bool strikethrough,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding WXUNUSED(encoding))
|
||||
wxFontRefData::wxFontRefData(const wxFontInfo& info)
|
||||
{
|
||||
// Old code could wrongly specify wxDEFAULT instead of -1 or wxNORMAL or,
|
||||
// preferably, wxFONTSTYLE_NORMAL or wxFONTWEIGHT_NORMAL, continue handling
|
||||
// this for compatibility.
|
||||
if ( pointSize == wxDEFAULT )
|
||||
pointSize = -1;
|
||||
|
||||
if ( static_cast<int>(style) == wxDEFAULT )
|
||||
style = wxFONTSTYLE_NORMAL;
|
||||
|
||||
if ( static_cast<int>(weight) == wxDEFAULT )
|
||||
weight = wxFONTWEIGHT_NORMAL;
|
||||
|
||||
if (family == wxFONTFAMILY_DEFAULT)
|
||||
family = wxFONTFAMILY_SWISS;
|
||||
|
||||
// Create native font info
|
||||
m_nativeFontInfo.description = pango_font_description_new();
|
||||
|
||||
// And set its values
|
||||
if (!faceName.empty())
|
||||
if ( info.HasFaceName() )
|
||||
{
|
||||
pango_font_description_set_family( m_nativeFontInfo.description,
|
||||
wxGTK_CONV_SYS(faceName) );
|
||||
wxGTK_CONV_SYS(info.GetFaceName()) );
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFontFamily family = info.GetFamily();
|
||||
if (family == wxFONTFAMILY_DEFAULT)
|
||||
family = wxFONTFAMILY_SWISS;
|
||||
SetFamily(family);
|
||||
}
|
||||
|
||||
SetStyle( style );
|
||||
SetPointSize( pointSize == -1 ? wxDEFAULT_FONT_SIZE : pointSize );
|
||||
SetWeight( weight );
|
||||
SetUnderlined( underlined );
|
||||
SetStrikethrough( strikethrough );
|
||||
SetStyle( info.GetStyle() );
|
||||
m_nativeFontInfo.SetSizeOrDefault(info.GetFractionalPointSize());
|
||||
SetNumericWeight( info.GetNumericWeight() );
|
||||
SetUnderlined( info.IsUnderlined() );
|
||||
SetStrikethrough( info.IsStrikethrough() );
|
||||
}
|
||||
|
||||
void wxFontRefData::InitFromNative()
|
||||
@@ -159,7 +114,7 @@ void wxFontRefData::InitFromNative()
|
||||
// Pango sometimes needs to have a size
|
||||
int pango_size = pango_font_description_get_size( desc );
|
||||
if (pango_size == 0)
|
||||
m_nativeFontInfo.SetPointSize(wxDEFAULT_FONT_SIZE);
|
||||
m_nativeFontInfo.SetSizeOrDefault(-1); // i.e. default
|
||||
}
|
||||
|
||||
wxFontRefData::wxFontRefData( const wxFontRefData& data )
|
||||
@@ -168,14 +123,6 @@ wxFontRefData::wxFontRefData( const wxFontRefData& data )
|
||||
{
|
||||
}
|
||||
|
||||
wxFontRefData::wxFontRefData(int size, wxFontFamily family, wxFontStyle style,
|
||||
wxFontWeight weight, bool underlined, bool strikethrough,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding)
|
||||
{
|
||||
Init(size, family, style, weight, underlined, strikethrough, faceName, encoding);
|
||||
}
|
||||
|
||||
wxFontRefData::wxFontRefData(const wxString& nativeFontInfoString)
|
||||
{
|
||||
m_nativeFontInfo.FromString( nativeFontInfoString );
|
||||
@@ -183,17 +130,13 @@ wxFontRefData::wxFontRefData(const wxString& nativeFontInfoString)
|
||||
InitFromNative();
|
||||
}
|
||||
|
||||
wxFontRefData::~wxFontRefData()
|
||||
{
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFontRefData SetXXX()
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxFontRefData::SetPointSize(float pointSize)
|
||||
void wxFontRefData::SetFractionalPointSize(float pointSize)
|
||||
{
|
||||
m_nativeFontInfo.SetPointSize(pointSize);
|
||||
m_nativeFontInfo.SetFractionalPointSize(pointSize);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -293,14 +236,7 @@ wxFont::wxFont(const wxNativeFontInfo& info)
|
||||
|
||||
wxFont::wxFont(const wxFontInfo& info)
|
||||
{
|
||||
m_refData = new wxFontRefData(info.GetPointSize(),
|
||||
info.GetFamily(),
|
||||
info.GetStyle(),
|
||||
info.GetWeight(),
|
||||
info.IsUnderlined(),
|
||||
info.IsStrikethrough(),
|
||||
info.GetFaceName(),
|
||||
info.GetEncoding());
|
||||
m_refData = new wxFontRefData(info);
|
||||
|
||||
wxSize pixelSize = info.GetPixelSize();
|
||||
if ( pixelSize != wxDefaultSize )
|
||||
@@ -317,8 +253,9 @@ bool wxFont::Create( int pointSize,
|
||||
{
|
||||
UnRef();
|
||||
|
||||
m_refData = new wxFontRefData(pointSize, family, style, weight,
|
||||
underlined, false, face, encoding);
|
||||
m_refData = new wxFontRefData(InfoFromLegacyParams(pointSize, family,
|
||||
style, weight, underlined,
|
||||
face, encoding));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -372,13 +309,6 @@ wxFontStyle wxFont::GetStyle() const
|
||||
return M_FONTDATA->m_nativeFontInfo.GetStyle();
|
||||
}
|
||||
|
||||
wxFontWeight wxFont::GetWeight() const
|
||||
{
|
||||
wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX, "invalid font" );
|
||||
|
||||
return M_FONTDATA->m_nativeFontInfo.GetWeight();
|
||||
}
|
||||
|
||||
int wxFont::GetNumericWeight() const
|
||||
{
|
||||
wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX, "invalid font" );
|
||||
@@ -426,11 +356,11 @@ bool wxFont::IsFixedWidth() const
|
||||
// change font attributes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxFont::SetPointSize(float pointSize)
|
||||
void wxFont::SetFractionalPointSize(float pointSize)
|
||||
{
|
||||
AllocExclusive();
|
||||
|
||||
M_FONTDATA->SetPointSize(pointSize);
|
||||
M_FONTDATA->SetFractionalPointSize(pointSize);
|
||||
}
|
||||
|
||||
void wxFont::SetFamily(wxFontFamily family)
|
||||
@@ -447,13 +377,6 @@ void wxFont::SetStyle(wxFontStyle style)
|
||||
M_FONTDATA->SetStyle(style);
|
||||
}
|
||||
|
||||
void wxFont::SetWeight(wxFontWeight weight)
|
||||
{
|
||||
AllocExclusive();
|
||||
|
||||
M_FONTDATA->SetWeight(weight);
|
||||
}
|
||||
|
||||
void wxFont::SetNumericWeight(int weight)
|
||||
{
|
||||
AllocExclusive();
|
||||
|
@@ -58,13 +58,7 @@ class wxFontRefData : public wxGDIRefData
|
||||
{
|
||||
public:
|
||||
// from broken down font parameters, also default ctor
|
||||
wxFontRefData(int size = -1,
|
||||
wxFontFamily family = wxFONTFAMILY_DEFAULT,
|
||||
wxFontStyle style = wxFONTSTYLE_NORMAL,
|
||||
wxFontWeight weight = wxFONTWEIGHT_NORMAL,
|
||||
bool underlined = false,
|
||||
const wxString& faceName = wxEmptyString,
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
||||
wxFontRefData(const wxFontInfo& info = wxFontInfo());
|
||||
|
||||
// from XFLD
|
||||
wxFontRefData(const wxString& fontname);
|
||||
@@ -83,10 +77,10 @@ public:
|
||||
|
||||
// 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
|
||||
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 SetUnderlined(bool underlined);
|
||||
bool SetFaceName(const wxString& facename);
|
||||
void SetEncoding(wxFontEncoding encoding);
|
||||
@@ -96,10 +90,10 @@ public:
|
||||
|
||||
protected:
|
||||
// common part of all ctors
|
||||
void Init(int pointSize,
|
||||
void Init(float pointSize,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
wxFontWeight weight,
|
||||
int weight,
|
||||
bool underlined,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding);
|
||||
@@ -114,10 +108,10 @@ private:
|
||||
// the map of font sizes to "GdkFont *"
|
||||
wxScaledFontList m_scaled_xfonts;
|
||||
|
||||
int m_pointSize;
|
||||
float m_pointSize;
|
||||
wxFontFamily m_family;
|
||||
wxFontStyle m_style;
|
||||
wxFontWeight m_weight;
|
||||
int m_weight;
|
||||
bool m_underlined;
|
||||
wxString m_faceName;
|
||||
wxFontEncoding m_encoding; // Unused under GTK 2.0
|
||||
@@ -135,10 +129,10 @@ private:
|
||||
// wxFontRefData
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxFontRefData::Init(int pointSize,
|
||||
void wxFontRefData::Init(float pointSize,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
wxFontWeight weight,
|
||||
int weight,
|
||||
bool underlined,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding)
|
||||
@@ -147,15 +141,10 @@ void wxFontRefData::Init(int pointSize,
|
||||
|
||||
m_faceName = faceName;
|
||||
|
||||
// we accept both wxDEFAULT and wxNORMAL here - should we?
|
||||
m_style = style == wxDEFAULT ? wxFONTSTYLE_NORMAL : style;
|
||||
m_weight = weight == wxDEFAULT ? wxFONTWEIGHT_NORMAL : weight;
|
||||
m_style = style;
|
||||
m_weight = weight;
|
||||
|
||||
// and here, do we really want to forbid creation of the font of the size
|
||||
// 90 (the value of wxDEFAULT)??
|
||||
m_pointSize = pointSize == wxDEFAULT || pointSize == -1
|
||||
? wxDEFAULT_FONT_SIZE
|
||||
: pointSize;
|
||||
m_pointSize = pointSize < 0 ? wxDEFAULT_FONT_SIZE : pointSize;
|
||||
|
||||
m_underlined = underlined;
|
||||
m_encoding = encoding;
|
||||
@@ -206,7 +195,7 @@ void wxFontRefData::InitFromNative()
|
||||
if ( m_nativeFontInfo.GetXFontComponent(wxXLFD_POINTSIZE).ToLong(&ptSize) )
|
||||
{
|
||||
// size in XLFD is in 10 point units
|
||||
m_pointSize = (int)(ptSize / 10);
|
||||
m_pointSize = ptSize / 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -281,12 +270,15 @@ wxFontRefData::wxFontRefData( const wxFontRefData& data )
|
||||
m_nativeFontInfo.FromString(data.m_nativeFontInfo.ToString());
|
||||
}
|
||||
|
||||
wxFontRefData::wxFontRefData(int size, wxFontFamily family, wxFontStyle style,
|
||||
wxFontWeight weight, bool underlined,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding)
|
||||
wxFontRefData::wxFontRefData(const wxFontInfo& info)
|
||||
{
|
||||
Init(size, family, style, weight, underlined, faceName, encoding);
|
||||
Init(info.GetFractionalPointSize(),
|
||||
info.GetFamily(),
|
||||
info.GetStyle(),
|
||||
info.GetNumericWeight(),
|
||||
info.IsUnderlined(),
|
||||
info.GetFaceName(),
|
||||
info.GetEncoding());
|
||||
}
|
||||
|
||||
wxFontRefData::wxFontRefData(const wxString& fontname)
|
||||
@@ -319,19 +311,13 @@ wxFontRefData::~wxFontRefData()
|
||||
// wxFontRefData SetXXX()
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxFontRefData::SetPointSize(int pointSize)
|
||||
void wxFontRefData::SetFractionalPointSize(float pointSize)
|
||||
{
|
||||
m_pointSize = pointSize;
|
||||
|
||||
if ( HasNativeFont() )
|
||||
{
|
||||
wxString size;
|
||||
if ( pointSize == -1 )
|
||||
size = wxT('*');
|
||||
else
|
||||
size.Printf(wxT("%d"), 10*pointSize);
|
||||
|
||||
m_nativeFontInfo.SetXFontComponent(wxXLFD_POINTSIZE, size);
|
||||
m_nativeFontInfo.SetFractionalPointSize(pointSize);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -371,33 +357,13 @@ void wxFontRefData::SetStyle(wxFontStyle style)
|
||||
}
|
||||
}
|
||||
|
||||
void wxFontRefData::SetWeight(wxFontWeight weight)
|
||||
void wxFontRefData::SetNumericWeight(int weight)
|
||||
{
|
||||
m_weight = weight;
|
||||
|
||||
if ( HasNativeFont() )
|
||||
{
|
||||
wxString boldness;
|
||||
switch ( weight )
|
||||
{
|
||||
case wxFONTWEIGHT_BOLD:
|
||||
boldness = wxT("bold");
|
||||
break;
|
||||
|
||||
case wxFONTWEIGHT_LIGHT:
|
||||
boldness = wxT("light");
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( wxT("unknown font weight") );
|
||||
// fall through
|
||||
|
||||
case wxFONTWEIGHT_NORMAL:
|
||||
// unspecified
|
||||
boldness = wxT("medium");
|
||||
}
|
||||
|
||||
m_nativeFontInfo.SetXFontComponent(wxXLFD_WEIGHT, boldness);
|
||||
m_nativeFontInfo.SetNumericWeight(weight);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,8 +431,9 @@ bool wxFont::Create( int pointSize,
|
||||
{
|
||||
UnRef();
|
||||
|
||||
m_refData = new wxFontRefData(pointSize, family, style, weight,
|
||||
underlined, face, encoding);
|
||||
m_refData = new wxFontRefData(InfoFromLegacyParams(pointSize, family,
|
||||
style, weight, underlined,
|
||||
face, encoding));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -518,7 +485,7 @@ wxGDIRefData *wxFont::CloneGDIRefData(const wxGDIRefData *data) const
|
||||
// accessors
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int wxFont::GetPointSize() const
|
||||
float wxFont::GetFractionalPointSize() const
|
||||
{
|
||||
wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
|
||||
|
||||
@@ -544,7 +511,7 @@ wxFontStyle wxFont::GetStyle() const
|
||||
return M_FONTDATA->m_style;
|
||||
}
|
||||
|
||||
wxFontWeight wxFont::GetWeight() const
|
||||
int wxFont::GetNumericWeight() const
|
||||
{
|
||||
wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX, wxT("invalid font") );
|
||||
|
||||
@@ -601,11 +568,11 @@ bool wxFont::IsFixedWidth() const
|
||||
// change font attributes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxFont::SetPointSize(int pointSize)
|
||||
void wxFont::SetFractionalPointSize(float pointSize)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
M_FONTDATA->SetPointSize(pointSize);
|
||||
M_FONTDATA->SetFractionalPointSize(pointSize);
|
||||
}
|
||||
|
||||
void wxFont::SetFamily(wxFontFamily family)
|
||||
@@ -622,11 +589,11 @@ void wxFont::SetStyle(wxFontStyle style)
|
||||
M_FONTDATA->SetStyle(style);
|
||||
}
|
||||
|
||||
void wxFont::SetWeight(wxFontWeight weight)
|
||||
void wxFont::SetNumericWeight(int weight)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
M_FONTDATA->SetWeight(weight);
|
||||
M_FONTDATA->SetNumericWeight(weight);
|
||||
}
|
||||
|
||||
bool wxFont::SetFaceName(const wxString& faceName)
|
||||
@@ -699,7 +666,7 @@ GdkFont *wxFont::GetInternalFont( float scale ) const
|
||||
wxCHECK_MSG( IsOk(), font, wxT("invalid font") );
|
||||
|
||||
long int_scale = long(scale * 100.0 + 0.5); // key for fontlist
|
||||
int point_scale = (int)((M_FONTDATA->m_pointSize * 10 * int_scale) / 100);
|
||||
float point_scale = (M_FONTDATA->m_pointSize * 10 * scale) / 100.0;
|
||||
|
||||
wxScaledFontList& list = M_FONTDATA->m_scaled_xfonts;
|
||||
wxScaledFontList::iterator i = list.find(int_scale);
|
||||
|
@@ -72,15 +72,15 @@ class wxFontRefData: public wxGDIRefData
|
||||
friend class wxFont;
|
||||
|
||||
public:
|
||||
wxFontRefData(int size = wxDEFAULT,
|
||||
wxFontFamily family = wxFONTFAMILY_DEFAULT,
|
||||
wxFontStyle style = wxFONTSTYLE_NORMAL,
|
||||
wxFontWeight weight = wxFONTWEIGHT_NORMAL,
|
||||
bool underlined = false,
|
||||
const wxString& faceName = wxEmptyString,
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
|
||||
wxFontRefData(const wxFontInfo& info = wxFontInfo())
|
||||
{
|
||||
Init(size, family, style, weight, underlined, faceName, encoding);
|
||||
Init(info.GetFractionalPointSize(),
|
||||
info.GetFamily(),
|
||||
info.GetStyle(),
|
||||
info.GetNumericWeight(),
|
||||
info.IsUnderlined(),
|
||||
info.GetFaceName(),
|
||||
info.GetEncoding());
|
||||
}
|
||||
|
||||
wxFontRefData(const wxFontRefData& data)
|
||||
@@ -93,19 +93,19 @@ public:
|
||||
|
||||
protected:
|
||||
// common part of all ctors
|
||||
void Init(int size,
|
||||
void Init(float size,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
wxFontWeight weight,
|
||||
int weight,
|
||||
bool underlined,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding);
|
||||
|
||||
// font attributes
|
||||
int m_pointSize;
|
||||
float m_pointSize;
|
||||
wxFontFamily m_family;
|
||||
wxFontStyle m_style;
|
||||
wxFontWeight m_weight;
|
||||
int m_weight;
|
||||
bool m_underlined;
|
||||
wxString m_faceName;
|
||||
wxFontEncoding m_encoding;
|
||||
@@ -163,10 +163,10 @@ wxXFont::~wxXFont()
|
||||
// wxFontRefData
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxFontRefData::Init(int pointSize,
|
||||
void wxFontRefData::Init(float pointSize,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
wxFontWeight weight,
|
||||
int weight,
|
||||
bool underlined,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding)
|
||||
@@ -178,17 +178,10 @@ void wxFontRefData::Init(int pointSize,
|
||||
|
||||
m_faceName = faceName;
|
||||
|
||||
if (style == wxDEFAULT)
|
||||
m_style = wxFONTSTYLE_NORMAL;
|
||||
else
|
||||
m_style = style;
|
||||
|
||||
if (weight == wxDEFAULT)
|
||||
m_weight = wxFONTWEIGHT_NORMAL;
|
||||
else
|
||||
m_weight = weight;
|
||||
|
||||
if (pointSize == wxDEFAULT)
|
||||
if (pointSize < 0)
|
||||
m_pointSize = 12;
|
||||
else
|
||||
m_pointSize = pointSize;
|
||||
@@ -220,6 +213,14 @@ wxFont::wxFont(const wxNativeFontInfo& info)
|
||||
(void)Create(info.GetXFontName());
|
||||
}
|
||||
|
||||
wxFont::wxFont(const wxFontInfo& info)
|
||||
{
|
||||
m_refData = new wxFontRefData(info);
|
||||
|
||||
if ( info.IsUsingSizeInPixels() )
|
||||
SetPixelSize(info.GetPixelSize());
|
||||
}
|
||||
|
||||
bool wxFont::Create(int pointSize,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
@@ -229,8 +230,10 @@ bool wxFont::Create(int pointSize,
|
||||
wxFontEncoding encoding)
|
||||
{
|
||||
UnRef();
|
||||
m_refData = new wxFontRefData(pointSize, family, style, weight,
|
||||
underlined, faceName, encoding);
|
||||
|
||||
m_refData = new wxFontRefData(InfoFromLegacyParams(pointSize, family,
|
||||
style, weight, underlined,
|
||||
faceName, encoding));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -371,7 +374,7 @@ void wxFont::Unshare()
|
||||
}
|
||||
}
|
||||
|
||||
void wxFont::SetPointSize(int pointSize)
|
||||
void wxFont::SetFractionalPointSize(float pointSize)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
@@ -395,7 +398,7 @@ void wxFont::SetStyle(wxFontStyle style)
|
||||
M_FONTDATA->m_nativeFontInfo.GetXFontName().Clear(); // invalid now
|
||||
}
|
||||
|
||||
void wxFont::SetWeight(wxFontWeight weight)
|
||||
void wxFont::SetNumericWeight(int weight)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
@@ -439,7 +442,7 @@ void wxFont::DoSetNativeFontInfo(const wxNativeFontInfo& info)
|
||||
// query font attributes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int wxFont::GetPointSize() const
|
||||
float wxFont::GetFractionalPointSize() const
|
||||
{
|
||||
wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
|
||||
|
||||
@@ -465,7 +468,7 @@ wxFontStyle wxFont::GetStyle() const
|
||||
return M_FONTDATA->m_style;
|
||||
}
|
||||
|
||||
wxFontWeight wxFont::GetWeight() const
|
||||
int wxFont::GetNumericWeight() const
|
||||
{
|
||||
wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX, wxT("invalid font") );
|
||||
|
||||
|
189
src/msw/font.cpp
189
src/msw/font.cpp
@@ -57,28 +57,7 @@ static const int PITCH_MASK = FIXED_PITCH | VARIABLE_PITCH;
|
||||
class WXDLLEXPORT wxFontRefData: public wxGDIRefData
|
||||
{
|
||||
public:
|
||||
// constructors
|
||||
wxFontRefData()
|
||||
{
|
||||
Init(-1, wxSize(0,0), false, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL,
|
||||
wxFONTWEIGHT_NORMAL, false, false, wxEmptyString,
|
||||
wxFONTENCODING_DEFAULT);
|
||||
}
|
||||
|
||||
wxFontRefData(int size,
|
||||
const wxSize& pixelSize,
|
||||
bool sizeUsingPixels,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
wxFontWeight weight,
|
||||
bool underlined,
|
||||
bool strikethrough,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding)
|
||||
{
|
||||
Init(size, pixelSize, sizeUsingPixels, family, style, weight,
|
||||
underlined, strikethrough, faceName, encoding);
|
||||
}
|
||||
wxFontRefData(const wxFontInfo& info = wxFontInfo());
|
||||
|
||||
wxFontRefData(const wxNativeFontInfo& info, WXHFONT hFont = 0)
|
||||
{
|
||||
@@ -100,7 +79,7 @@ public:
|
||||
// all wxFont accessors
|
||||
float GetFractionalPointSize() const
|
||||
{
|
||||
return m_nativeFontInfo.GetPointSize();
|
||||
return m_nativeFontInfo.GetFractionalPointSize();
|
||||
}
|
||||
|
||||
wxSize GetPixelSize() const
|
||||
@@ -123,11 +102,6 @@ public:
|
||||
return m_nativeFontInfo.GetStyle();
|
||||
}
|
||||
|
||||
wxFontWeight GetWeight() const
|
||||
{
|
||||
return m_nativeFontInfo.GetWeight();
|
||||
}
|
||||
|
||||
int GetNumericWeight() const
|
||||
{
|
||||
return m_nativeFontInfo.GetNumericWeight();
|
||||
@@ -181,11 +155,11 @@ public:
|
||||
// ... and setters: notice that all of them invalidate the currently
|
||||
// allocated HFONT, if any, so that the next call to GetHFONT() recreates a
|
||||
// new one
|
||||
void SetPointSize(float pointSize)
|
||||
void SetFractionalPointSize(float pointSize)
|
||||
{
|
||||
Free();
|
||||
|
||||
m_nativeFontInfo.SetPointSize(pointSize);
|
||||
m_nativeFontInfo.SetFractionalPointSize(pointSize);
|
||||
m_sizeUsingPixels = false;
|
||||
}
|
||||
|
||||
@@ -214,13 +188,6 @@ public:
|
||||
m_nativeFontInfo.SetStyle(style);
|
||||
}
|
||||
|
||||
void SetWeight(wxFontWeight weight)
|
||||
{
|
||||
Free();
|
||||
|
||||
m_nativeFontInfo.SetWeight(weight);
|
||||
}
|
||||
|
||||
void SetNumericWeight(int weight)
|
||||
{
|
||||
Free();
|
||||
@@ -278,18 +245,6 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
// common part of all ctors
|
||||
void Init(int size,
|
||||
const wxSize& pixelSize,
|
||||
bool sizeUsingPixels,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
wxFontWeight weight,
|
||||
bool underlined,
|
||||
bool strikethrough,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding);
|
||||
|
||||
void Init(const wxNativeFontInfo& info, WXHFONT hFont = 0);
|
||||
|
||||
void AllocIfNeeded() const
|
||||
@@ -354,38 +309,33 @@ protected:
|
||||
// wxFontRefData
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxFontRefData::Init(int pointSize,
|
||||
const wxSize& pixelSize,
|
||||
bool sizeUsingPixels,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
wxFontWeight weight,
|
||||
bool underlined,
|
||||
bool strikethrough,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding)
|
||||
wxFontRefData::wxFontRefData(const wxFontInfo& info)
|
||||
{
|
||||
m_hFont = NULL;
|
||||
|
||||
m_sizeUsingPixels = sizeUsingPixels;
|
||||
m_sizeUsingPixels = info.IsUsingSizeInPixels();
|
||||
if ( m_sizeUsingPixels )
|
||||
SetPixelSize(pixelSize);
|
||||
{
|
||||
m_nativeFontInfo.SetPixelSize(info.GetPixelSize());
|
||||
}
|
||||
else
|
||||
SetPointSize(pointSize == -1 ? wxNORMAL_FONT->GetPointSize() : pointSize);
|
||||
{
|
||||
m_nativeFontInfo.SetSizeOrDefault(info.GetFractionalPointSize());
|
||||
}
|
||||
|
||||
SetStyle(style);
|
||||
SetWeight(weight);
|
||||
SetUnderlined(underlined);
|
||||
SetStrikethrough(strikethrough);
|
||||
SetStyle(info.GetStyle());
|
||||
SetNumericWeight(info.GetNumericWeight());
|
||||
SetUnderlined(info.IsUnderlined());
|
||||
SetStrikethrough(info.IsStrikethrough());
|
||||
|
||||
// set the family/facename
|
||||
SetFamily(family);
|
||||
if ( !faceName.empty() )
|
||||
SetFaceName(faceName);
|
||||
SetFamily(info.GetFamily());
|
||||
if ( info.HasFaceName() )
|
||||
SetFaceName(info.GetFaceName());
|
||||
|
||||
// deal with encoding now (it may override the font family and facename
|
||||
// so do it after setting them)
|
||||
SetEncoding(encoding);
|
||||
SetEncoding(info.GetEncoding());
|
||||
}
|
||||
|
||||
void wxFontRefData::Init(const wxNativeFontInfo& info, WXHFONT hFont)
|
||||
@@ -446,21 +396,20 @@ void wxNativeFontInfo::Init()
|
||||
lf.lfQuality = wxSystemOptions::GetOptionInt("msw.font.no-proof-quality")
|
||||
? DEFAULT_QUALITY
|
||||
: PROOF_QUALITY;
|
||||
}
|
||||
|
||||
int wxNativeFontInfo::GetPointSize() const
|
||||
{
|
||||
return wxRound(GetFractionalPointSize());
|
||||
pointSize = 0.0f;
|
||||
}
|
||||
|
||||
float wxNativeFontInfo::GetFractionalPointSize() const
|
||||
{
|
||||
if ( pointSize != 0.0f )
|
||||
return pointSize;
|
||||
|
||||
// FIXME: using the screen here results in incorrect font size calculation
|
||||
// for printing!
|
||||
const int ppInch = ::GetDeviceCaps(ScreenHDC(), LOGPIXELSY);
|
||||
|
||||
// BC++ 2007 doesn't provide abs(long) overload, hence the cast
|
||||
return (int) (((72.0*abs((int)lf.lfHeight)) / (double) ppInch) + 0.5);
|
||||
return (72.0*abs(lf.lfHeight)) / (double) ppInch;
|
||||
}
|
||||
|
||||
wxSize wxNativeFontInfo::GetPixelSize() const
|
||||
@@ -541,13 +490,17 @@ wxFontEncoding wxNativeFontInfo::GetEncoding() const
|
||||
return wxGetFontEncFromCharSet(lf.lfCharSet);
|
||||
}
|
||||
|
||||
void wxNativeFontInfo::SetPointSize(float pointsize)
|
||||
void wxNativeFontInfo::SetFractionalPointSize(float pointsize)
|
||||
{
|
||||
// Store it to be able to return it from GetFractionalPointSize() later
|
||||
// exactly.
|
||||
pointSize = pointsize;
|
||||
|
||||
// FIXME: using the screen here results in incorrect font size calculation
|
||||
// for printing!
|
||||
const int ppInch = ::GetDeviceCaps(ScreenHDC(), LOGPIXELSY);
|
||||
|
||||
lf.lfHeight = -(int)((pointsize*((double)ppInch)/72.0) + 0.5);
|
||||
lf.lfHeight = -wxRound(pointsize*((double)ppInch)/72.0);
|
||||
}
|
||||
|
||||
void wxNativeFontInfo::SetPixelSize(const wxSize& pixelSize)
|
||||
@@ -682,9 +635,32 @@ bool wxNativeFontInfo::FromString(const wxString& s)
|
||||
|
||||
// first the version
|
||||
wxString token = tokenizer.GetNextToken();
|
||||
if ( token != wxS('0') )
|
||||
if ( !token.ToLong(&l) )
|
||||
return false;
|
||||
|
||||
switch ( l )
|
||||
{
|
||||
case 0:
|
||||
// Fractional point size is not present in this version.
|
||||
pointSize = 0.0f;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
{
|
||||
double d;
|
||||
if ( !tokenizer.GetNextToken().ToCDouble(&d) )
|
||||
return false;
|
||||
pointSize = static_cast<float>(d);
|
||||
if ( static_cast<double>(pointSize) != d )
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Unknown version.
|
||||
return false;
|
||||
}
|
||||
|
||||
token = tokenizer.GetNextToken();
|
||||
if ( !token.ToLong(&l) )
|
||||
return false;
|
||||
@@ -763,8 +739,9 @@ wxString wxNativeFontInfo::ToString() const
|
||||
{
|
||||
wxString s;
|
||||
|
||||
s.Printf(wxS("%d;%ld;%ld;%ld;%ld;%ld;%d;%d;%d;%d;%d;%d;%d;%d;%s"),
|
||||
0, // version, in case we want to change the format later
|
||||
s.Printf(wxS("%d;%f;%ld;%ld;%ld;%ld;%ld;%d;%d;%d;%d;%d;%d;%d;%d;%s"),
|
||||
1, // version
|
||||
pointSize,
|
||||
lf.lfHeight,
|
||||
lf.lfWidth,
|
||||
lf.lfEscapement,
|
||||
@@ -796,16 +773,7 @@ wxFont::wxFont(const wxString& fontdesc)
|
||||
|
||||
wxFont::wxFont(const wxFontInfo& info)
|
||||
{
|
||||
m_refData = new wxFontRefData(info.GetPointSize(),
|
||||
info.GetPixelSize(),
|
||||
info.IsUsingSizeInPixels(),
|
||||
info.GetFamily(),
|
||||
info.GetStyle(),
|
||||
info.GetWeight(),
|
||||
info.IsUnderlined(),
|
||||
info.IsStrikethrough(),
|
||||
info.GetFaceName(),
|
||||
info.GetEncoding());
|
||||
m_refData = new wxFontRefData(info);
|
||||
}
|
||||
|
||||
bool wxFont::Create(const wxNativeFontInfo& info, WXHFONT hFont)
|
||||
@@ -817,28 +785,11 @@ bool wxFont::Create(const wxNativeFontInfo& info, WXHFONT hFont)
|
||||
return RealizeResource();
|
||||
}
|
||||
|
||||
bool wxFont::DoCreate(int pointSize,
|
||||
const wxSize& pixelSize,
|
||||
bool sizeUsingPixels,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
wxFontWeight weight,
|
||||
bool underlined,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding)
|
||||
bool wxFont::DoCreate(const wxFontInfo& info)
|
||||
{
|
||||
UnRef();
|
||||
|
||||
// wxDEFAULT is a valid value for the font size too so we must treat it
|
||||
// specially here (otherwise the size would be 70 == wxDEFAULT value)
|
||||
if ( pointSize == wxDEFAULT )
|
||||
{
|
||||
pointSize = wxNORMAL_FONT->GetPointSize();
|
||||
}
|
||||
|
||||
m_refData = new wxFontRefData(pointSize, pixelSize, sizeUsingPixels,
|
||||
family, style, weight,
|
||||
underlined, false, faceName, encoding);
|
||||
m_refData = new wxFontRefData(info);
|
||||
|
||||
return RealizeResource();
|
||||
}
|
||||
@@ -900,12 +851,12 @@ bool wxFont::IsFree() const
|
||||
// change font attribute: we recreate font when doing it
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxFont::SetPointSize(float pointSize)
|
||||
void wxFont::SetFractionalPointSize(float pointSize)
|
||||
{
|
||||
AllocExclusive();
|
||||
|
||||
M_FONTDATA->Free();
|
||||
M_FONTDATA->SetPointSize(pointSize);
|
||||
M_FONTDATA->SetFractionalPointSize(pointSize);
|
||||
}
|
||||
|
||||
void wxFont::SetPixelSize(const wxSize& pixelSize)
|
||||
@@ -929,13 +880,6 @@ void wxFont::SetStyle(wxFontStyle style)
|
||||
M_FONTDATA->SetStyle(style);
|
||||
}
|
||||
|
||||
void wxFont::SetWeight(wxFontWeight weight)
|
||||
{
|
||||
AllocExclusive();
|
||||
|
||||
M_FONTDATA->SetWeight(weight);
|
||||
}
|
||||
|
||||
void wxFont::SetNumericWeight(int weight)
|
||||
{
|
||||
AllocExclusive();
|
||||
@@ -1025,13 +969,6 @@ wxFontStyle wxFont::GetStyle() const
|
||||
return M_FONTDATA->GetStyle();
|
||||
}
|
||||
|
||||
wxFontWeight wxFont::GetWeight() const
|
||||
{
|
||||
wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX, "invalid font" );
|
||||
|
||||
return M_FONTDATA->GetWeight();
|
||||
}
|
||||
|
||||
int wxFont::GetNumericWeight() const
|
||||
{
|
||||
wxCHECK_MSG(IsOk(), wxFONTWEIGHT_MAX, wxT("invalid font"));
|
||||
|
@@ -335,7 +335,7 @@ public:
|
||||
const wxColour& col );
|
||||
wxGDIPlusFontData(wxGraphicsRenderer* renderer,
|
||||
const wxString& name,
|
||||
REAL sizeInPixels,
|
||||
REAL size,
|
||||
int style,
|
||||
const wxColour& col);
|
||||
~wxGDIPlusFontData();
|
||||
@@ -349,8 +349,7 @@ private :
|
||||
void Init(const wxString& name,
|
||||
REAL size,
|
||||
int style,
|
||||
const wxColour& col,
|
||||
Unit fontUnit);
|
||||
const wxColour& col);
|
||||
|
||||
Brush* m_textBrush;
|
||||
Font* m_font;
|
||||
@@ -986,8 +985,7 @@ void
|
||||
wxGDIPlusFontData::Init(const wxString& name,
|
||||
REAL size,
|
||||
int style,
|
||||
const wxColour& col,
|
||||
Unit fontUnit)
|
||||
const wxColour& col)
|
||||
{
|
||||
#if wxUSE_PRIVATE_FONTS
|
||||
// If the user has registered any private fonts, they should be used in
|
||||
@@ -1007,7 +1005,7 @@ wxGDIPlusFontData::Init(const wxString& name,
|
||||
int rc = gs_pFontFamily[j].GetFamilyName(familyName);
|
||||
if ( rc == 0 && name == familyName )
|
||||
{
|
||||
m_font = new Font(&gs_pFontFamily[j], size, style, fontUnit);
|
||||
m_font = new Font(&gs_pFontFamily[j], size, style, UnitPoint);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1016,7 +1014,7 @@ wxGDIPlusFontData::Init(const wxString& name,
|
||||
if ( !m_font )
|
||||
#endif // wxUSE_PRIVATE_FONTS
|
||||
{
|
||||
m_font = new Font(name.wc_str(), size, style, fontUnit);
|
||||
m_font = new Font(name.wc_str(), size, style, UnitPoint);
|
||||
}
|
||||
|
||||
m_textBrush = new SolidBrush(wxColourToColor(col));
|
||||
@@ -1037,19 +1035,17 @@ wxGDIPlusFontData::wxGDIPlusFontData( wxGraphicsRenderer* renderer,
|
||||
if ( font.GetWeight() == wxFONTWEIGHT_BOLD )
|
||||
style |= FontStyleBold;
|
||||
|
||||
// Create font which size is measured in logical units
|
||||
// and let the system rescale it according to the target resolution.
|
||||
Init(font.GetFaceName(), font.GetPixelSize().GetHeight(), style, col, UnitPixel);
|
||||
Init(font.GetFaceName(), font.GetFractionalPointSize(), style, col);
|
||||
}
|
||||
|
||||
wxGDIPlusFontData::wxGDIPlusFontData(wxGraphicsRenderer* renderer,
|
||||
const wxString& name,
|
||||
REAL sizeInPixels,
|
||||
REAL size,
|
||||
int style,
|
||||
const wxColour& col) :
|
||||
wxGraphicsObjectRefData(renderer)
|
||||
{
|
||||
Init(name, sizeInPixels, style, col, UnitPixel);
|
||||
Init(name, size, style, col);
|
||||
}
|
||||
|
||||
wxGDIPlusFontData::~wxGDIPlusFontData()
|
||||
|
@@ -2637,7 +2637,7 @@ wxD2DPenData* wxGetD2DPenData(const wxGraphicsPen& pen)
|
||||
class wxD2DFontData : public wxGraphicsObjectRefData
|
||||
{
|
||||
public:
|
||||
wxD2DFontData(wxGraphicsRenderer* renderer, ID2D1Factory* d2d1Factory, const wxFont& font, const wxColor& color);
|
||||
wxD2DFontData(wxGraphicsRenderer* renderer, const wxFont& font, const wxColor& color);
|
||||
|
||||
wxCOMPtr<IDWriteTextLayout> CreateTextLayout(const wxString& text) const;
|
||||
|
||||
@@ -2662,7 +2662,7 @@ private:
|
||||
bool m_strikethrough;
|
||||
};
|
||||
|
||||
wxD2DFontData::wxD2DFontData(wxGraphicsRenderer* renderer, ID2D1Factory* d2dFactory, const wxFont& font, const wxColor& color) :
|
||||
wxD2DFontData::wxD2DFontData(wxGraphicsRenderer* renderer, const wxFont& font, const wxColor& color) :
|
||||
wxGraphicsObjectRefData(renderer), m_brushData(renderer, wxBrush(color)),
|
||||
m_underlined(font.GetUnderlined()), m_strikethrough(font.GetStrikethrough())
|
||||
{
|
||||
@@ -2715,16 +2715,15 @@ wxD2DFontData::wxD2DFontData(wxGraphicsRenderer* renderer, ID2D1Factory* d2dFact
|
||||
hr = familyNames->GetString(0, name, length+1);
|
||||
wxCHECK_HRESULT_RET(hr);
|
||||
|
||||
FLOAT dpiX, dpiY;
|
||||
d2dFactory->GetDesktopDpi(&dpiX, &dpiY);
|
||||
|
||||
hr = wxDWriteFactory()->CreateTextFormat(
|
||||
name,
|
||||
NULL,
|
||||
m_font->GetWeight(),
|
||||
m_font->GetStyle(),
|
||||
m_font->GetStretch(),
|
||||
(FLOAT)(font.GetPixelSize().GetHeight()) / (dpiY / 96.0),
|
||||
// We need to use DIP units for the font size, with 1dip = 1/96in,
|
||||
// while wxFont uses points with 1pt = 1/72in.
|
||||
font.GetFractionalPointSize()*96/72,
|
||||
L"en-us",
|
||||
&m_textFormat);
|
||||
|
||||
@@ -4708,7 +4707,7 @@ wxImage wxD2DRenderer::CreateImageFromBitmap(const wxGraphicsBitmap& bmp)
|
||||
|
||||
wxGraphicsFont wxD2DRenderer::CreateFont(const wxFont& font, const wxColour& col)
|
||||
{
|
||||
wxD2DFontData* fontData = new wxD2DFontData(this, GetD2DFactory(), font, col);
|
||||
wxD2DFontData* fontData = new wxD2DFontData(this, font, col);
|
||||
if ( !fontData->GetFont() )
|
||||
{
|
||||
// Apparently a non-TrueType font is given and hence
|
||||
|
@@ -149,8 +149,7 @@ wxFont wxCreateFontFromStockObject(int index)
|
||||
LOGFONT lf;
|
||||
if ( ::GetObject(hFont, sizeof(LOGFONT), &lf) != 0 )
|
||||
{
|
||||
wxNativeFontInfo info;
|
||||
info.lf = lf;
|
||||
wxNativeFontInfo info(lf);
|
||||
font.Create(info);
|
||||
}
|
||||
else
|
||||
@@ -182,8 +181,8 @@ wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
|
||||
// for most (simple) controls, e.g. buttons and such but other
|
||||
// controls may prefer to use lfStatusFont or lfCaptionFont if it
|
||||
// is more appropriate for them
|
||||
wxNativeFontInfo info;
|
||||
info.lf = wxMSWImpl::GetNonClientMetrics().lfMessageFont;
|
||||
const wxNativeFontInfo
|
||||
info(wxMSWImpl::GetNonClientMetrics().lfMessageFont);
|
||||
gs_fontDefault = new wxFont(info);
|
||||
}
|
||||
|
||||
|
@@ -36,44 +36,23 @@
|
||||
class WXDLLEXPORT wxFontRefData : public wxGDIRefData
|
||||
{
|
||||
public:
|
||||
wxFontRefData()
|
||||
{
|
||||
Init(10, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL,
|
||||
false, false, wxEmptyString, wxFONTENCODING_DEFAULT);
|
||||
}
|
||||
|
||||
wxFontRefData(float size,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
wxFontWeight weight,
|
||||
bool underlined,
|
||||
bool strikethrough,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding)
|
||||
{
|
||||
Init(size, family, style, weight, underlined, strikethrough, faceName, encoding);
|
||||
}
|
||||
wxFontRefData(const wxFontInfo& info = wxFontInfo());
|
||||
|
||||
wxFontRefData(const wxFontRefData& data);
|
||||
|
||||
wxFontRefData(const wxNativeFontInfo& info)
|
||||
: m_info(info)
|
||||
{
|
||||
Init();
|
||||
m_info.Init(info);
|
||||
}
|
||||
|
||||
wxFontRefData(CTFontRef font);
|
||||
|
||||
virtual ~wxFontRefData();
|
||||
|
||||
float GetFractionalPointSize() const { return m_info.GetFractionalPointSize(); }
|
||||
|
||||
wxFontFamily GetFamily() const { return m_info.GetFamily(); }
|
||||
|
||||
wxFontStyle GetStyle() const { return m_info.GetStyle(); }
|
||||
|
||||
wxFontWeight GetWeight() const { return m_info.GetWeight(); }
|
||||
|
||||
int GetNumericWeight() const { return m_info.GetNumericWeight(); }
|
||||
|
||||
bool GetUnderlined() const { return m_info.GetUnderlined(); }
|
||||
@@ -94,11 +73,11 @@ public:
|
||||
|
||||
const wxNativeFontInfo& GetNativeFontInfo() const;
|
||||
|
||||
void SetPointSize(float size)
|
||||
void SetFractionalPointSize(float size)
|
||||
{
|
||||
if (GetFractionalPointSize() != size)
|
||||
{
|
||||
m_info.SetPointSize(size);
|
||||
m_info.SetFractionalPointSize(size);
|
||||
Free();
|
||||
}
|
||||
}
|
||||
@@ -121,15 +100,6 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void SetWeight(wxFontWeight weight)
|
||||
{
|
||||
if (m_info.GetWeight() != weight)
|
||||
{
|
||||
m_info.SetWeight(weight);
|
||||
Free();
|
||||
}
|
||||
}
|
||||
|
||||
void SetNumericWeight(int weight)
|
||||
{
|
||||
if (m_info.GetNumericWeight() != weight)
|
||||
@@ -179,16 +149,6 @@ public:
|
||||
|
||||
void Alloc();
|
||||
protected:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
void Init(float size,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
wxFontWeight weight,
|
||||
bool underlined,
|
||||
bool strikethrough,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding);
|
||||
void SetFont(CTFontRef font);
|
||||
void AllocIfNeeded() const;
|
||||
|
||||
@@ -285,43 +245,27 @@ namespace
|
||||
wxFontRefData::wxFontRefData(const wxFontRefData& data)
|
||||
: wxGDIRefData()
|
||||
{
|
||||
Init();
|
||||
m_info = data.m_info;
|
||||
m_ctFont = data.m_ctFont;
|
||||
m_ctFontAttributes = data.m_ctFontAttributes;
|
||||
m_cgFont = data.m_cgFont;
|
||||
}
|
||||
|
||||
void wxFontRefData::Init()
|
||||
wxFontRefData::wxFontRefData(const wxFontInfo& info)
|
||||
{
|
||||
m_info.Init();
|
||||
}
|
||||
|
||||
void wxFontRefData::Init(float size,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
wxFontWeight weight,
|
||||
bool underlined,
|
||||
bool strikethrough,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding)
|
||||
{
|
||||
m_info.Init();
|
||||
if ( !faceName.empty() )
|
||||
SetFaceName(faceName);
|
||||
if ( info.HasFaceName() )
|
||||
SetFaceName(info.GetFaceName());
|
||||
else
|
||||
SetFamily(family);
|
||||
SetPointSize(size < 0 ? wxNORMAL_FONT->GetFractionalPointSize() : size);
|
||||
SetWeight(weight);
|
||||
SetStyle(style);
|
||||
SetUnderlined(underlined);
|
||||
SetStrikethrough(strikethrough);
|
||||
SetEncoding(encoding);
|
||||
}
|
||||
SetFamily(info.GetFamily());
|
||||
|
||||
wxFontRefData::~wxFontRefData()
|
||||
{
|
||||
Free();
|
||||
m_info.SetSizeOrDefault(info.GetFractionalPointSize());
|
||||
SetNumericWeight(info.GetNumericWeight());
|
||||
SetStyle(info.GetStyle());
|
||||
SetUnderlined(info.IsUnderlined());
|
||||
SetStrikethrough(info.IsStrikethrough());
|
||||
SetEncoding(info.GetEncoding());
|
||||
}
|
||||
|
||||
void wxFontRefData::Free()
|
||||
@@ -333,7 +277,6 @@ void wxFontRefData::Free()
|
||||
|
||||
wxFontRefData::wxFontRefData(CTFontRef font)
|
||||
{
|
||||
Init();
|
||||
SetFont(font);
|
||||
m_info.InitFromFont(font);
|
||||
}
|
||||
@@ -550,6 +493,14 @@ wxFont::wxFont(const wxString& fontdesc)
|
||||
(void)Create(info);
|
||||
}
|
||||
|
||||
wxFont::wxFont(const wxFontInfo& info)
|
||||
{
|
||||
m_refData = new wxFontRefData(info);
|
||||
|
||||
if ( info.IsUsingSizeInPixels() )
|
||||
SetPixelSize(info.GetPixelSize());
|
||||
}
|
||||
|
||||
wxFont::wxFont(int size,
|
||||
int family,
|
||||
int style,
|
||||
@@ -562,22 +513,6 @@ wxFont::wxFont(int size,
|
||||
(wxFontWeight)weight, underlined, face, encoding);
|
||||
}
|
||||
|
||||
bool wxFont::Create(float pointSize,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
wxFontWeight weight,
|
||||
bool underlined,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding)
|
||||
{
|
||||
UnRef();
|
||||
|
||||
m_refData = new wxFontRefData(pointSize, family, style, weight,
|
||||
underlined, false, faceName, encoding);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wxFont::Create(int pointSize,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
@@ -586,12 +521,11 @@ bool wxFont::Create(int pointSize,
|
||||
const wxString& faceName,
|
||||
wxFontEncoding encoding)
|
||||
{
|
||||
// wxDEFAULT is a valid value for the font size too so we must treat it
|
||||
// specially here (otherwise the size would be 70 == wxDEFAULT value)
|
||||
if (pointSize == wxDEFAULT)
|
||||
pointSize = -1;
|
||||
m_refData = new wxFontRefData(InfoFromLegacyParams(pointSize, family,
|
||||
style, weight, underlined,
|
||||
faceName, encoding));
|
||||
|
||||
return Create((float)pointSize, family, style, weight, underlined, faceName, encoding);
|
||||
return true;
|
||||
}
|
||||
|
||||
wxFont::~wxFont()
|
||||
@@ -627,14 +561,11 @@ wxGDIRefData* wxFont::CloneGDIRefData(const wxGDIRefData* data) const
|
||||
return new wxFontRefData(*static_cast<const wxFontRefData*>(data));
|
||||
}
|
||||
|
||||
void wxFont::SetPointSize(float pointSize)
|
||||
void wxFont::SetFractionalPointSize(float pointSize)
|
||||
{
|
||||
if (IsOk() && M_FONTDATA->GetFractionalPointSize() == pointSize)
|
||||
return;
|
||||
|
||||
AllocExclusive();
|
||||
|
||||
M_FONTDATA->SetPointSize(pointSize);
|
||||
M_FONTDATA->SetFractionalPointSize(pointSize);
|
||||
}
|
||||
|
||||
void wxFont::SetFamily(wxFontFamily family)
|
||||
@@ -651,13 +582,6 @@ void wxFont::SetStyle(wxFontStyle style)
|
||||
M_FONTDATA->SetStyle(style);
|
||||
}
|
||||
|
||||
void wxFont::SetWeight(wxFontWeight weight)
|
||||
{
|
||||
AllocExclusive();
|
||||
|
||||
M_FONTDATA->SetWeight(weight);
|
||||
}
|
||||
|
||||
void wxFont::SetNumericWeight(int weight)
|
||||
{
|
||||
AllocExclusive();
|
||||
@@ -738,13 +662,6 @@ wxFontStyle wxFont::GetStyle() const
|
||||
return M_FONTDATA->GetStyle();
|
||||
}
|
||||
|
||||
wxFontWeight wxFont::GetWeight() const
|
||||
{
|
||||
wxCHECK_MSG(IsOk(), wxFONTWEIGHT_MAX, wxT("invalid font"));
|
||||
|
||||
return M_FONTDATA->GetWeight();
|
||||
}
|
||||
|
||||
int wxFont::GetNumericWeight() const
|
||||
{
|
||||
wxCHECK_MSG(IsOk(), wxFONTWEIGHT_MAX, wxT("invalid font"));
|
||||
@@ -972,6 +889,7 @@ CGFloat wxNativeFontInfo::GetCTSlant(CTFontDescriptorRef descr)
|
||||
//
|
||||
bool wxNativeFontInfo::FromString(const wxString& s)
|
||||
{
|
||||
double d;
|
||||
long l, version;
|
||||
|
||||
Init();
|
||||
@@ -987,9 +905,16 @@ bool wxNativeFontInfo::FromString(const wxString& s)
|
||||
//
|
||||
|
||||
token = tokenizer.GetNextToken();
|
||||
if ( !token.ToLong(&l) )
|
||||
if ( !token.ToCDouble(&d) )
|
||||
return false;
|
||||
m_ctSize = (int)l;
|
||||
#ifdef __LP64__
|
||||
// CGFloat is just double in this case.
|
||||
m_ctSize = d;
|
||||
#else // !__LP64__
|
||||
m_ctSize = static_cast<CGFloat>(d);
|
||||
if ( static_cast<double>(m_ctSize) != d )
|
||||
return false;
|
||||
#endif // __LP64__/!__LP64__
|
||||
|
||||
token = tokenizer.GetNextToken();
|
||||
if ( !token.ToLong(&l) )
|
||||
@@ -1042,12 +967,12 @@ wxString wxNativeFontInfo::ToString() const
|
||||
{
|
||||
wxString s;
|
||||
|
||||
s.Printf(wxT("%d;%d;%d;%d;%d;%d;%d;%s;%d"),
|
||||
s.Printf(wxT("%d;%f;%d;%d;%d;%d;%d;%s;%d"),
|
||||
1, // version
|
||||
GetPointSize(),
|
||||
GetFractionalPointSize(),
|
||||
GetFamily(),
|
||||
(int)GetStyle(),
|
||||
(int)GetWeight(),
|
||||
GetNumericWeight(),
|
||||
GetUnderlined(),
|
||||
GetStrikethrough(),
|
||||
GetFaceName().GetData(),
|
||||
@@ -1056,11 +981,6 @@ wxString wxNativeFontInfo::ToString() const
|
||||
return s;
|
||||
}
|
||||
|
||||
int wxNativeFontInfo::GetPointSize() const
|
||||
{
|
||||
return wxRound(GetFractionalPointSize());
|
||||
}
|
||||
|
||||
float wxNativeFontInfo::GetFractionalPointSize() const
|
||||
{
|
||||
return m_ctSize;
|
||||
@@ -1141,9 +1061,9 @@ bool wxNativeFontInfo::GetStrikethrough() const
|
||||
|
||||
// changing the font descriptor
|
||||
|
||||
void wxNativeFontInfo::SetPointSize(float pointsize)
|
||||
void wxNativeFontInfo::SetFractionalPointSize(float pointsize)
|
||||
{
|
||||
if (GetPointSize() != pointsize)
|
||||
if (GetFractionalPointSize() != pointsize)
|
||||
{
|
||||
m_ctSize = pointsize;
|
||||
|
||||
|
@@ -2895,17 +2895,7 @@ wxMacCoreGraphicsRenderer::CreateFont(double sizeInPixels,
|
||||
// Notice that under Mac we always use 72 DPI so the font size in pixels is
|
||||
// the same as the font size in points and we can pass it directly to wxFont
|
||||
// ctor.
|
||||
wxFont font((float)sizeInPixels,
|
||||
wxFONTFAMILY_DEFAULT,
|
||||
flags & wxFONTFLAG_ITALIC ? wxFONTSTYLE_ITALIC
|
||||
: wxFONTSTYLE_NORMAL,
|
||||
flags & wxFONTFLAG_BOLD ? wxFONTWEIGHT_BOLD
|
||||
: wxFONTWEIGHT_NORMAL,
|
||||
(flags & wxFONTFLAG_UNDERLINED) != 0,
|
||||
facename);
|
||||
|
||||
if ( flags & wxFONTFLAG_STRIKETHROUGH )
|
||||
font.MakeStrikethrough();
|
||||
wxFont font(wxFontInfo(sizeInPixels).FaceName(facename).AllFlags(flags));
|
||||
|
||||
wxGraphicsFont f;
|
||||
f.SetRefData(new wxMacCoreGraphicsFontData(this, font, col));
|
||||
|
@@ -2056,7 +2056,7 @@ wxWindow* wxPropertyGrid::GenerateEditorButton( const wxPoint& pos, const wxSize
|
||||
|
||||
#ifdef __WXGTK__
|
||||
wxFont font = GetFont();
|
||||
font.SetPointSize(font.GetPointSize()-2);
|
||||
font.SetFractionalPointSize(font.GetFractionalPointSize()-2);
|
||||
but->SetFont(font);
|
||||
#else
|
||||
but->SetFont(GetFont());
|
||||
|
187
src/qt/font.cpp
187
src/qt/font.cpp
@@ -53,29 +53,50 @@ static QFont::StyleHint ConvertFontFamily(wxFontFamily family)
|
||||
return QFont::AnyStyle;
|
||||
}
|
||||
|
||||
static QFont::Weight ConvertFontWeight(int weight)
|
||||
// Helper of ConvertFontWeight() and GetNumericWeight(): if a value lies in
|
||||
// ]fromMin, fromMax] interval, then map it to [toMin, toMax] interval linearly
|
||||
// and return true, otherwise return false and don't modify it.
|
||||
static bool TryToMap(int& x, int fromMin, int fromMax, int toMin, int toMax)
|
||||
{
|
||||
switch (weight)
|
||||
if ( x > fromMin && x <= fromMax )
|
||||
{
|
||||
case wxFONTWEIGHT_NORMAL:
|
||||
return QFont::Normal;
|
||||
x = (toMin*(fromMax - x) + toMax*(x - fromMin))/(fromMax - fromMin);
|
||||
|
||||
case wxFONTWEIGHT_LIGHT:
|
||||
return QFont::Light;
|
||||
|
||||
case wxFONTWEIGHT_BOLD:
|
||||
return QFont::Bold;
|
||||
|
||||
case wxFONTWEIGHT_SEMIBOLD:
|
||||
return QFont::DemiBold;
|
||||
|
||||
case wxFONTWEIGHT_HEAVY:
|
||||
return QFont::Black;
|
||||
|
||||
case wxFONTWEIGHT_MAX:
|
||||
wxFAIL_MSG( "Invalid font weight value" );
|
||||
break;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static int ConvertFontWeight(int w)
|
||||
{
|
||||
// Note that QFont::Thin is 0, so we can't have anything lighter than it.
|
||||
if ( TryToMap(w, wxFONTWEIGHT_INVALID, wxFONTWEIGHT_THIN,
|
||||
QFont::Thin, QFont::Thin) ||
|
||||
TryToMap(w, wxFONTWEIGHT_THIN, wxFONTWEIGHT_EXTRALIGHT,
|
||||
QFont::Thin, QFont::ExtraLight) ||
|
||||
TryToMap(w, wxFONTWEIGHT_EXTRALIGHT, wxFONTWEIGHT_LIGHT,
|
||||
QFont::ExtraLight, QFont::Light) ||
|
||||
TryToMap(w, wxFONTWEIGHT_LIGHT, wxFONTWEIGHT_NORMAL,
|
||||
QFont::Light, QFont::Normal) ||
|
||||
TryToMap(w, wxFONTWEIGHT_NORMAL, wxFONTWEIGHT_MEDIUM,
|
||||
QFont::Normal, QFont::Medium) ||
|
||||
TryToMap(w, wxFONTWEIGHT_MEDIUM, wxFONTWEIGHT_SEMIBOLD,
|
||||
QFont::Medium, QFont::DemiBold) ||
|
||||
TryToMap(w, wxFONTWEIGHT_SEMIBOLD, wxFONTWEIGHT_BOLD,
|
||||
QFont::DemiBold, QFont::Bold) ||
|
||||
TryToMap(w, wxFONTWEIGHT_BOLD, wxFONTWEIGHT_EXTRABOLD,
|
||||
QFont::Bold, QFont::ExtraBold) ||
|
||||
TryToMap(w, wxFONTWEIGHT_EXTRABOLD, wxFONTWEIGHT_HEAVY,
|
||||
QFont::ExtraBold, QFont::Black) ||
|
||||
TryToMap(w, wxFONTWEIGHT_HEAVY, wxFONTWEIGHT_EXTRAHEAVY,
|
||||
QFont::Black, 99) )
|
||||
{
|
||||
return w;
|
||||
}
|
||||
|
||||
wxFAIL_MSG("invalid wxFont weight");
|
||||
|
||||
return QFont::Normal;
|
||||
}
|
||||
|
||||
@@ -84,17 +105,31 @@ class wxFontRefData: public wxGDIRefData
|
||||
public:
|
||||
wxFontRefData() {}
|
||||
|
||||
wxFontRefData(const wxFontInfo& info)
|
||||
{
|
||||
if ( info.HasFaceName() )
|
||||
m_nativeFontInfo.SetFaceName(info.GetFaceName());
|
||||
else
|
||||
m_nativeFontInfo.SetFamily(info.GetFamily());
|
||||
|
||||
if ( info.IsUsingSizeInPixels() )
|
||||
m_nativeFontInfo.SetPixelSize(info.GetPixelSize());
|
||||
else
|
||||
m_nativeFontInfo.SetFractionalPointSize(info.GetFractionalPointSize());
|
||||
|
||||
m_nativeFontInfo.SetStyle(info.GetStyle());
|
||||
m_nativeFontInfo.SetWeight(info.GetWeight());
|
||||
m_nativeFontInfo.SetUnderlined(info.IsUnderlined());
|
||||
m_nativeFontInfo.SetStrikethrough(info.IsStrikethrough());
|
||||
|
||||
}
|
||||
|
||||
wxFontRefData( const wxFontRefData& data )
|
||||
: wxGDIRefData()
|
||||
{
|
||||
m_nativeFontInfo.m_qtFont = data.m_nativeFontInfo.m_qtFont;
|
||||
}
|
||||
|
||||
bool operator == (const wxFontRefData& data) const
|
||||
{
|
||||
return m_nativeFontInfo.m_qtFont == data.m_nativeFontInfo.m_qtFont;
|
||||
}
|
||||
|
||||
wxNativeFontInfo m_nativeFontInfo;
|
||||
};
|
||||
|
||||
@@ -107,20 +142,7 @@ wxFont::wxFont()
|
||||
|
||||
wxFont::wxFont(const wxFontInfo& info)
|
||||
{
|
||||
m_refData = new wxFontRefData();
|
||||
Create(wxSize(0, info.GetPointSize()),
|
||||
info.GetFamily(),
|
||||
info.GetStyle(),
|
||||
info.GetWeight(),
|
||||
info.IsUnderlined(),
|
||||
info.GetFaceName(),
|
||||
info.GetEncoding());
|
||||
|
||||
SetStrikethrough(info.IsStrikethrough());
|
||||
|
||||
wxSize pixelSize = info.GetPixelSize();
|
||||
if ( pixelSize != wxDefaultSize )
|
||||
SetPixelSize(pixelSize);
|
||||
m_refData = new wxFontRefData(info);
|
||||
}
|
||||
|
||||
wxFont::wxFont(const wxString& nativeFontInfoString)
|
||||
@@ -166,7 +188,6 @@ wxFont::wxFont(const wxSize& pixelSize,
|
||||
const wxString& face,
|
||||
wxFontEncoding encoding)
|
||||
{
|
||||
m_refData = new wxFontRefData();
|
||||
Create(pixelSize, family, style, weight, underlined, face, encoding);
|
||||
}
|
||||
|
||||
@@ -178,31 +199,26 @@ wxFont::wxFont(int size,
|
||||
const wxString& face,
|
||||
wxFontEncoding encoding)
|
||||
{
|
||||
m_refData = new wxFontRefData();
|
||||
Create(wxSize(0, size), (wxFontFamily)family, (wxFontStyle)style, (wxFontWeight)weight, underlined, face, encoding);
|
||||
}
|
||||
|
||||
|
||||
bool wxFont::Create(wxSize size, wxFontFamily family, wxFontStyle style,
|
||||
wxFontWeight weight, bool underlined, const wxString& face,
|
||||
wxFontEncoding WXUNUSED(encoding) )
|
||||
wxFontEncoding encoding )
|
||||
{
|
||||
if (!face.empty())
|
||||
M_FONTDATA.SetFaceName(face);
|
||||
else
|
||||
M_FONTDATA.SetFamily(family);
|
||||
UnRef();
|
||||
|
||||
M_FONTDATA.SetStyle(style);
|
||||
M_FONTDATA.SetWeight(weight);
|
||||
M_FONTDATA.SetUnderlined(underlined);
|
||||
M_FONTDATA.SetPointSize(size.GetHeight());
|
||||
m_refData = new wxFontRefData(InfoFromLegacyParams(size.GetHeight(), family,
|
||||
style, weight, underlined,
|
||||
face, encoding));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int wxFont::GetPointSize() const
|
||||
float wxFont::GetFractionalPointSize() const
|
||||
{
|
||||
return M_FONTDATA.GetPointSize();
|
||||
return M_FONTDATA.GetFractionalPointSize();
|
||||
}
|
||||
|
||||
wxFontStyle wxFont::GetStyle() const
|
||||
@@ -210,9 +226,9 @@ wxFontStyle wxFont::GetStyle() const
|
||||
return M_FONTDATA.GetStyle();
|
||||
}
|
||||
|
||||
wxFontWeight wxFont::GetWeight() const
|
||||
int wxFont::GetNumericWeight() const
|
||||
{
|
||||
return M_FONTDATA.GetWeight();
|
||||
return M_FONTDATA.GetNumericWeight();
|
||||
}
|
||||
|
||||
bool wxFont::GetUnderlined() const
|
||||
@@ -235,11 +251,11 @@ const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
|
||||
return &M_FONTDATA;
|
||||
}
|
||||
|
||||
void wxFont::SetPointSize( int pointSize )
|
||||
void wxFont::SetFractionalPointSize(float pointSize)
|
||||
{
|
||||
AllocExclusive();
|
||||
|
||||
M_FONTDATA.SetPointSize(pointSize);
|
||||
M_FONTDATA.SetFractionalPointSize(pointSize);
|
||||
}
|
||||
|
||||
bool wxFont::SetFaceName(const wxString& facename)
|
||||
@@ -263,11 +279,11 @@ void wxFont::SetStyle( wxFontStyle style )
|
||||
M_FONTDATA.SetStyle(style);
|
||||
}
|
||||
|
||||
void wxFont::SetWeight( wxFontWeight weight )
|
||||
void wxFont::SetNumericWeight(int weight)
|
||||
{
|
||||
AllocExclusive();
|
||||
|
||||
M_FONTDATA.SetWeight(weight);
|
||||
M_FONTDATA.SetNumericWeight(weight);
|
||||
}
|
||||
|
||||
void wxFont::SetUnderlined( bool underlined )
|
||||
@@ -312,9 +328,9 @@ void wxNativeFontInfo::Init()
|
||||
{
|
||||
}
|
||||
|
||||
int wxNativeFontInfo::GetPointSize() const
|
||||
float wxNativeFontInfo::GetFractionalPointSize() const
|
||||
{
|
||||
return m_qtFont.pointSize();
|
||||
return m_qtFont.pointSizeF();
|
||||
}
|
||||
|
||||
wxFontStyle wxNativeFontInfo::GetStyle() const
|
||||
@@ -336,24 +352,36 @@ wxFontStyle wxNativeFontInfo::GetStyle() const
|
||||
|
||||
int wxNativeFontInfo::GetNumericWeight() const
|
||||
{
|
||||
switch ( m_qtFont.weight() )
|
||||
int w = m_qtFont.weight();
|
||||
|
||||
// Special case of QFont::Thin == 0.
|
||||
if ( w == QFont::Thin )
|
||||
return wxFONTWEIGHT_THIN;
|
||||
|
||||
if ( TryToMap(w, QFont::Thin, QFont::ExtraLight,
|
||||
wxFONTWEIGHT_THIN, wxFONTWEIGHT_EXTRALIGHT) ||
|
||||
TryToMap(w, QFont::ExtraLight, QFont::Light,
|
||||
wxFONTWEIGHT_EXTRALIGHT, wxFONTWEIGHT_LIGHT) ||
|
||||
TryToMap(w, QFont::Light, QFont::Normal,
|
||||
wxFONTWEIGHT_LIGHT, wxFONTWEIGHT_NORMAL) ||
|
||||
TryToMap(w, QFont::Normal, QFont::Medium,
|
||||
wxFONTWEIGHT_NORMAL, wxFONTWEIGHT_MEDIUM) ||
|
||||
TryToMap(w, QFont::Medium, QFont::DemiBold,
|
||||
wxFONTWEIGHT_MEDIUM, wxFONTWEIGHT_SEMIBOLD) ||
|
||||
TryToMap(w, QFont::DemiBold, QFont::Bold,
|
||||
wxFONTWEIGHT_SEMIBOLD, wxFONTWEIGHT_BOLD) ||
|
||||
TryToMap(w, QFont::Bold, QFont::ExtraBold,
|
||||
wxFONTWEIGHT_BOLD, wxFONTWEIGHT_EXTRABOLD) ||
|
||||
TryToMap(w, QFont::ExtraBold, QFont::Black,
|
||||
wxFONTWEIGHT_EXTRABOLD, wxFONTWEIGHT_HEAVY) ||
|
||||
TryToMap(w, QFont::Black, 99,
|
||||
wxFONTWEIGHT_HEAVY, wxFONTWEIGHT_EXTRAHEAVY) )
|
||||
{
|
||||
case QFont::Normal:
|
||||
return wxFONTWEIGHT_NORMAL;
|
||||
|
||||
case QFont::Light:
|
||||
return wxFONTWEIGHT_LIGHT;
|
||||
|
||||
case QFont::DemiBold:
|
||||
return wxFONTWEIGHT_SEMIBOLD;
|
||||
|
||||
case QFont::Black:
|
||||
return wxFONTWEIGHT_HEAVY;
|
||||
|
||||
case QFont::Bold:
|
||||
return wxFONTWEIGHT_BOLD;
|
||||
return w;
|
||||
}
|
||||
wxFAIL_MSG( "Invalid font weight value" );
|
||||
|
||||
wxFAIL_MSG( "Invalid QFont weight" );
|
||||
|
||||
return wxFONTWEIGHT_NORMAL;
|
||||
}
|
||||
|
||||
@@ -409,9 +437,14 @@ wxFontEncoding wxNativeFontInfo::GetEncoding() const
|
||||
return wxFONTENCODING_MAX;
|
||||
}
|
||||
|
||||
void wxNativeFontInfo::SetPointSize(int pointsize)
|
||||
void wxNativeFontInfo::SetFractionalPointSize(float pointsize)
|
||||
{
|
||||
m_qtFont.setPointSize(pointsize);
|
||||
m_qtFont.setPointSizeF(pointsize);
|
||||
}
|
||||
|
||||
void wxNativeFontInfo::SetPixelSize(const wxSize& size)
|
||||
{
|
||||
m_qtFont.setPixelSize(size.GetHeight());
|
||||
}
|
||||
|
||||
void wxNativeFontInfo::SetStyle(wxFontStyle style)
|
||||
|
@@ -6843,7 +6843,7 @@ bool wxRichTextPlainText::Draw(wxDC& dc, wxRichTextDrawingContext& context, cons
|
||||
{
|
||||
if (textAttr.HasTextEffects() && (textAttr.GetTextEffects() & wxTEXT_ATTR_EFFECT_SMALL_CAPITALS))
|
||||
{
|
||||
textFont.SetPointSize((int) (textFont.GetPointSize()*0.75));
|
||||
textFont.SetFractionalPointSize(textFont.GetFractionalPointSize()*0.75);
|
||||
wxCheckSetFont(dc, textFont);
|
||||
charHeight = dc.GetCharHeight();
|
||||
}
|
||||
@@ -6859,8 +6859,7 @@ bool wxRichTextPlainText::Draw(wxDC& dc, wxRichTextDrawingContext& context, cons
|
||||
}
|
||||
else
|
||||
{
|
||||
double size = static_cast<double>(textFont.GetPointSize()) / wxSCRIPT_MUL_FACTOR;
|
||||
textFont.SetPointSize(static_cast<int>(size));
|
||||
textFont.SetFractionalPointSize(textFont.GetFractionalPointSize() / wxSCRIPT_MUL_FACTOR);
|
||||
x = rect.x;
|
||||
y = rect.y;
|
||||
}
|
||||
@@ -6878,8 +6877,7 @@ bool wxRichTextPlainText::Draw(wxDC& dc, wxRichTextDrawingContext& context, cons
|
||||
}
|
||||
else
|
||||
{
|
||||
double size = static_cast<double>(textFont.GetPointSize()) / wxSCRIPT_MUL_FACTOR;
|
||||
textFont.SetPointSize(static_cast<int>(size));
|
||||
textFont.SetFractionalPointSize(textFont.GetFractionalPointSize() / wxSCRIPT_MUL_FACTOR);
|
||||
x = rect.x;
|
||||
int sub_height = static_cast<int>(static_cast<double>(charHeight) / wxSCRIPT_MUL_FACTOR);
|
||||
y = rect.y + (rect.height - sub_height + (descent - m_descent));
|
||||
@@ -7197,8 +7195,7 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz
|
||||
}
|
||||
else
|
||||
{
|
||||
double textSize = static_cast<double>(textFont.GetPointSize()) / wxSCRIPT_MUL_FACTOR;
|
||||
textFont.SetPointSize(static_cast<int>(textSize));
|
||||
textFont.SetFractionalPointSize(textFont.GetFractionalPointSize() / wxSCRIPT_MUL_FACTOR);
|
||||
}
|
||||
wxCheckSetFont(dc, textFont);
|
||||
bScript = true;
|
||||
@@ -7206,7 +7203,7 @@ bool wxRichTextPlainText::GetRangeSize(const wxRichTextRange& range, wxSize& siz
|
||||
else if (textAttr.HasTextEffects() && (textAttr.GetTextEffects() & wxTEXT_ATTR_EFFECT_SMALL_CAPITALS))
|
||||
{
|
||||
wxFont textFont = font;
|
||||
textFont.SetPointSize((int) (textFont.GetPointSize()*0.75));
|
||||
textFont.SetFractionalPointSize(textFont.GetFractionalPointSize()*0.75);
|
||||
wxCheckSetFont(dc, textFont);
|
||||
bScript = true;
|
||||
}
|
||||
@@ -9264,8 +9261,7 @@ void wxRichTextStdRenderer::SetFontForBullet(wxRichTextBuffer& buffer, wxDC& dc,
|
||||
}
|
||||
else
|
||||
{
|
||||
double size = static_cast<double>(textFont.GetPointSize()) / wxSCRIPT_MUL_FACTOR;
|
||||
textFont.SetPointSize(static_cast<int>(size));
|
||||
textFont.SetFractionalPointSize(textFont.GetFractionalPointSize() / wxSCRIPT_MUL_FACTOR);
|
||||
}
|
||||
wxCheckSetFont(dc, textFont);
|
||||
}
|
||||
@@ -9278,7 +9274,7 @@ void wxRichTextStdRenderer::SetFontForBullet(wxRichTextBuffer& buffer, wxDC& dc,
|
||||
}
|
||||
else
|
||||
{
|
||||
textFont.SetPointSize((int) (textFont.GetPointSize()*0.75));
|
||||
textFont.SetFractionalPointSize(textFont.GetFractionalPointSize()*0.75);
|
||||
}
|
||||
|
||||
wxCheckSetFont(dc, textFont);
|
||||
|
@@ -516,8 +516,7 @@ void wxRichTextFontPreviewCtrl::OnPaint(wxPaintEvent& WXUNUSED(event))
|
||||
|
||||
if ((GetTextEffects() & wxTEXT_ATTR_EFFECT_SUPERSCRIPT) || (GetTextEffects() & wxTEXT_ATTR_EFFECT_SUBSCRIPT))
|
||||
{
|
||||
double fontSize = static_cast<double>(font.GetPointSize()) / wxSCRIPT_MUL_FACTOR;
|
||||
font.SetPointSize( static_cast<int>(fontSize) );
|
||||
font.SetFractionalPointSize(font.GetFractionalPointSize() / wxSCRIPT_MUL_FACTOR);
|
||||
}
|
||||
|
||||
if ( font.IsOk() )
|
||||
|
@@ -35,6 +35,7 @@
|
||||
|
||||
#include "wx/encinfo.h"
|
||||
#include "wx/fontmap.h"
|
||||
#include "wx/math.h"
|
||||
#include "wx/tokenzr.h"
|
||||
#include "wx/fontenum.h"
|
||||
|
||||
@@ -90,11 +91,6 @@ void wxNativeFontInfo::Free()
|
||||
pango_font_description_free(description);
|
||||
}
|
||||
|
||||
int wxNativeFontInfo::GetPointSize() const
|
||||
{
|
||||
return wxRound(GetFractionalPointSize());
|
||||
}
|
||||
|
||||
float wxNativeFontInfo::GetFractionalPointSize() const
|
||||
{
|
||||
return ((float) pango_font_description_get_size( description )) / PANGO_SCALE;
|
||||
@@ -219,9 +215,9 @@ wxFontEncoding wxNativeFontInfo::GetEncoding() const
|
||||
return wxFONTENCODING_SYSTEM;
|
||||
}
|
||||
|
||||
void wxNativeFontInfo::SetPointSize(float pointsize)
|
||||
void wxNativeFontInfo::SetFractionalPointSize(float pointsize)
|
||||
{
|
||||
pango_font_description_set_size( description, pointsize * PANGO_SCALE );
|
||||
pango_font_description_set_size( description, wxRound(pointsize * PANGO_SCALE) );
|
||||
}
|
||||
|
||||
void wxNativeFontInfo::SetStyle(wxFontStyle style)
|
||||
@@ -493,10 +489,10 @@ static wxHashTable *g_fontHash = NULL;
|
||||
|
||||
static bool wxTestFontSpec(const wxString& fontspec);
|
||||
|
||||
static wxNativeFont wxLoadQueryFont(int pointSize,
|
||||
static wxNativeFont wxLoadQueryFont(float pointSize,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
wxFontWeight weight,
|
||||
int weight,
|
||||
bool underlined,
|
||||
const wxString& facename,
|
||||
const wxString& xregistry,
|
||||
@@ -675,18 +671,10 @@ wxNativeFontInfo::SetXFontComponent(wxXLFDField field, const wxString& value)
|
||||
{
|
||||
wxCHECK_RET( field < wxXLFD_MAX, wxT("invalid XLFD field") );
|
||||
|
||||
// this class should be initialized with a valid font spec first and only
|
||||
// then the fields may be modified!
|
||||
wxASSERT_MSG( !IsDefault(), wxT("can't modify an uninitialized XLFD") );
|
||||
|
||||
if ( !HasElements() )
|
||||
{
|
||||
if ( !const_cast<wxNativeFontInfo *>(this)->FromXFontName(xFontName) )
|
||||
{
|
||||
wxFAIL_MSG( wxT("can't set font element for invalid XLFD") );
|
||||
|
||||
return;
|
||||
}
|
||||
for ( int field = 0; field < wxXLFD_MAX; field++ )
|
||||
fontElements[field] = '*';
|
||||
}
|
||||
|
||||
fontElements[field] = value;
|
||||
@@ -705,11 +693,6 @@ void wxNativeFontInfo::SetXFontName(const wxString& xFontName_)
|
||||
m_isDefault = false;
|
||||
}
|
||||
|
||||
int wxNativeFontInfo::GetPointSize() const
|
||||
{
|
||||
return wxRound(GetFractionalPointSize());
|
||||
}
|
||||
|
||||
float wxNativeFontInfo::GetFractionalPointSize() const
|
||||
{
|
||||
const wxString s = GetXFontComponent(wxXLFD_POINTSIZE);
|
||||
@@ -802,9 +785,15 @@ wxFontEncoding wxNativeFontInfo::GetEncoding() const
|
||||
return wxFONTENCODING_MAX;
|
||||
}
|
||||
|
||||
void wxNativeFontInfo::SetPointSize(float pointsize)
|
||||
void wxNativeFontInfo::SetFractionalPointSize(float pointsize)
|
||||
{
|
||||
SetXFontComponent(wxXLFD_POINTSIZE, wxString::Format(wxT("%d"), pointsize));
|
||||
wxString s;
|
||||
if ( pointsize < 0 )
|
||||
s = '*';
|
||||
else
|
||||
s.Printf("%d", wxRound(10*pointsize));
|
||||
|
||||
SetXFontComponent(wxXLFD_POINTSIZE, s);
|
||||
}
|
||||
|
||||
void wxNativeFontInfo::SetStyle(wxFontStyle style)
|
||||
@@ -822,6 +811,7 @@ void wxNativeFontInfo::SetStyle(wxFontStyle style)
|
||||
|
||||
case wxFONTSTYLE_NORMAL:
|
||||
s = wxT('r');
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( wxT("unknown wxFontStyle in wxNativeFontInfo::SetStyle") );
|
||||
@@ -831,28 +821,58 @@ void wxNativeFontInfo::SetStyle(wxFontStyle style)
|
||||
SetXFontComponent(wxXLFD_SLANT, s);
|
||||
}
|
||||
|
||||
void wxNativeFontInfo::SetWeight(wxFontWeight weight)
|
||||
void wxNativeFontInfo::SetNumericWeight(int weight)
|
||||
{
|
||||
wxString s;
|
||||
switch ( weight )
|
||||
switch ( wxFontInfo::GetWeightClosestToNumericValue(weight) )
|
||||
{
|
||||
case wxFONTWEIGHT_BOLD:
|
||||
s = wxT("bold");
|
||||
case wxFONTWEIGHT_THIN:
|
||||
s = "thin";
|
||||
break;
|
||||
|
||||
case wxFONTWEIGHT_EXTRALIGHT:
|
||||
s = "extralight";
|
||||
break;
|
||||
|
||||
case wxFONTWEIGHT_LIGHT:
|
||||
s = wxT("light");
|
||||
s = "light";
|
||||
break;
|
||||
|
||||
case wxFONTWEIGHT_NORMAL:
|
||||
s = wxT("medium");
|
||||
s = "normal";
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG( wxT("unknown wxFontWeight in wxNativeFontInfo::SetWeight") );
|
||||
return;
|
||||
case wxFONTWEIGHT_MEDIUM:
|
||||
s = "medium";
|
||||
break;
|
||||
|
||||
case wxFONTWEIGHT_SEMIBOLD:
|
||||
s = "semibold";
|
||||
break;
|
||||
|
||||
case wxFONTWEIGHT_BOLD:
|
||||
s = "bold";
|
||||
break;
|
||||
|
||||
case wxFONTWEIGHT_EXTRABOLD:
|
||||
s = "extrabold";
|
||||
break;
|
||||
|
||||
case wxFONTWEIGHT_HEAVY:
|
||||
s = "heavy";
|
||||
break;
|
||||
|
||||
case wxFONTWEIGHT_EXTRAHEAVY:
|
||||
s = "extraheavy";
|
||||
break;
|
||||
|
||||
case wxFONTWEIGHT_INVALID:
|
||||
wxFAIL_MSG( "Invalid font weight" );
|
||||
break;
|
||||
}
|
||||
|
||||
wxCHECK_RET( !s.empty(), "unknown weight value" );
|
||||
|
||||
SetXFontComponent(wxXLFD_WEIGHT, s);
|
||||
}
|
||||
|
||||
@@ -872,12 +892,24 @@ bool wxNativeFontInfo::SetFaceName(const wxString& facename)
|
||||
return true;
|
||||
}
|
||||
|
||||
void wxNativeFontInfo::SetFamily(wxFontFamily WXUNUSED(family))
|
||||
void wxNativeFontInfo::SetFamily(wxFontFamily family)
|
||||
{
|
||||
// wxFontFamily -> X foundry, anyone?
|
||||
wxFAIL_MSG( wxT("not implemented") );
|
||||
wxString xfamily;
|
||||
switch (family)
|
||||
{
|
||||
case wxFONTFAMILY_DECORATIVE: xfamily = "lucida"; break;
|
||||
case wxFONTFAMILY_ROMAN: xfamily = "times"; break;
|
||||
case wxFONTFAMILY_MODERN: xfamily = "courier"; break;
|
||||
case wxFONTFAMILY_DEFAULT:
|
||||
case wxFONTFAMILY_SWISS: xfamily = "helvetica"; break;
|
||||
case wxFONTFAMILY_TELETYPE: xfamily = "lucidatypewriter"; break;
|
||||
case wxFONTFAMILY_SCRIPT: xfamily = "utopia"; break;
|
||||
case wxFONTFAMILY_UNKNOWN: break;
|
||||
}
|
||||
|
||||
// SetXFontComponent(wxXLFD_FOUNDRY, ...);
|
||||
wxCHECK_RET( !xfamily.empty(), "Unknown wxFontFamily" );
|
||||
|
||||
SetXFontComponent(wxXLFD_FAMILY, xfamily);
|
||||
}
|
||||
|
||||
void wxNativeFontInfo::SetEncoding(wxFontEncoding encoding)
|
||||
@@ -997,10 +1029,10 @@ bool wxTestFontEncoding(const wxNativeEncodingInfo& info)
|
||||
// X-specific functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxNativeFont wxLoadQueryNearestFont(int pointSize,
|
||||
wxNativeFont wxLoadQueryNearestFont(float pointSize,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
wxFontWeight weight,
|
||||
int weight,
|
||||
bool underlined,
|
||||
const wxString &facename,
|
||||
wxFontEncoding encoding,
|
||||
@@ -1077,7 +1109,7 @@ wxNativeFont wxLoadQueryNearestFont(int pointSize,
|
||||
|
||||
// first round: search for equal, then for smaller and for larger size
|
||||
// with the given weight and style
|
||||
wxFontWeight testweight = weight;
|
||||
int testweight = weight;
|
||||
wxFontStyle teststyle = style;
|
||||
|
||||
for ( round = 0; round < 3; round++ )
|
||||
@@ -1220,26 +1252,16 @@ static bool wxTestFontSpec(const wxString& fontspec)
|
||||
}
|
||||
}
|
||||
|
||||
static wxNativeFont wxLoadQueryFont(int pointSize,
|
||||
static wxNativeFont wxLoadQueryFont(float pointSize,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
wxFontWeight weight,
|
||||
int weight,
|
||||
bool WXUNUSED(underlined),
|
||||
const wxString& facename,
|
||||
const wxString& xregistry,
|
||||
const wxString& xencoding,
|
||||
wxString* xFontName)
|
||||
{
|
||||
wxString xfamily("*");
|
||||
switch (family)
|
||||
{
|
||||
case wxFONTFAMILY_DECORATIVE: xfamily = wxT("lucida"); break;
|
||||
case wxFONTFAMILY_ROMAN: xfamily = wxT("times"); break;
|
||||
case wxFONTFAMILY_MODERN: xfamily = wxT("courier"); break;
|
||||
case wxFONTFAMILY_SWISS: xfamily = wxT("helvetica"); break;
|
||||
case wxFONTFAMILY_TELETYPE: xfamily = wxT("lucidatypewriter"); break;
|
||||
case wxFONTFAMILY_SCRIPT: xfamily = wxT("utopia"); break;
|
||||
}
|
||||
#if wxUSE_NANOX
|
||||
int xweight;
|
||||
switch (weight)
|
||||
@@ -1311,176 +1333,43 @@ static wxNativeFont wxLoadQueryFont(int pointSize,
|
||||
return (wxNativeFont) fontInfo;
|
||||
|
||||
#else
|
||||
wxString fontSpec;
|
||||
wxNativeFontInfo info;
|
||||
info.SetFractionalPointSize(pointSize);
|
||||
|
||||
if ( !facename.empty() )
|
||||
{
|
||||
fontSpec.Printf(wxT("-*-%s-*-*-normal-*-*-*-*-*-*-*-*-*"),
|
||||
facename.c_str());
|
||||
|
||||
if ( wxTestFontSpec(fontSpec) )
|
||||
info.SetFaceName(facename);
|
||||
if ( !wxTestFontSpec(info.GetXFontName()) )
|
||||
{
|
||||
xfamily = facename;
|
||||
// No such face name, use just the family (we assume this will
|
||||
// never fail).
|
||||
info.SetFamily(family);
|
||||
}
|
||||
//else: no such family, use default one instead
|
||||
}
|
||||
|
||||
wxString xstyle;
|
||||
switch (style)
|
||||
{
|
||||
case wxFONTSTYLE_SLANT:
|
||||
fontSpec.Printf(wxT("-*-%s-*-o-*-*-*-*-*-*-*-*-*-*"),
|
||||
xfamily.c_str());
|
||||
if ( wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
xstyle = wxT("o");
|
||||
break;
|
||||
}
|
||||
// fall through - try wxFONTSTYLE_ITALIC now
|
||||
|
||||
case wxFONTSTYLE_ITALIC:
|
||||
fontSpec.Printf(wxT("-*-%s-*-i-*-*-*-*-*-*-*-*-*-*"),
|
||||
xfamily.c_str());
|
||||
if ( wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
xstyle = wxT("i");
|
||||
}
|
||||
else if ( style == wxFONTSTYLE_ITALIC ) // and not wxFONTSTYLE_SLANT
|
||||
{
|
||||
// try wxFONTSTYLE_SLANT
|
||||
fontSpec.Printf(wxT("-*-%s-*-o-*-*-*-*-*-*-*-*-*-*"),
|
||||
xfamily.c_str());
|
||||
if ( wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
xstyle = wxT("o");
|
||||
}
|
||||
else
|
||||
{
|
||||
// no italic, no slant - leave default
|
||||
xstyle = wxT("*");
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG(wxT("unknown font style"));
|
||||
// fall back to normal
|
||||
|
||||
case wxFONTSTYLE_NORMAL:
|
||||
xstyle = wxT("r");
|
||||
break;
|
||||
info.SetFamily(family);
|
||||
}
|
||||
|
||||
wxString xweight;
|
||||
switch (weight)
|
||||
{
|
||||
case wxFONTWEIGHT_BOLD:
|
||||
{
|
||||
fontSpec.Printf(wxT("-*-%s-bold-*-*-*-*-*-*-*-*-*-*-*"),
|
||||
xfamily.c_str());
|
||||
if ( wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
xweight = wxT("bold");
|
||||
break;
|
||||
}
|
||||
fontSpec.Printf(wxT("-*-%s-heavy-*-*-*-*-*-*-*-*-*-*-*"),
|
||||
xfamily.c_str());
|
||||
if ( wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
xweight = wxT("heavy");
|
||||
break;
|
||||
}
|
||||
fontSpec.Printf(wxT("-*-%s-extrabold-*-*-*-*-*-*-*-*-*-*-*"),
|
||||
xfamily.c_str());
|
||||
if ( wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
xweight = wxT("extrabold");
|
||||
break;
|
||||
}
|
||||
fontSpec.Printf(wxT("-*-%s-demibold-*-*-*-*-*-*-*-*-*-*-*"),
|
||||
xfamily.c_str());
|
||||
if ( wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
xweight = wxT("demibold");
|
||||
break;
|
||||
}
|
||||
fontSpec.Printf(wxT("-*-%s-black-*-*-*-*-*-*-*-*-*-*-*"),
|
||||
xfamily.c_str());
|
||||
if ( wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
xweight = wxT("black");
|
||||
break;
|
||||
}
|
||||
fontSpec.Printf(wxT("-*-%s-ultrablack-*-*-*-*-*-*-*-*-*-*-*"),
|
||||
xfamily.c_str());
|
||||
if ( wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
xweight = wxT("ultrablack");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case wxFONTWEIGHT_LIGHT:
|
||||
{
|
||||
fontSpec.Printf(wxT("-*-%s-light-*-*-*-*-*-*-*-*-*-*-*"),
|
||||
xfamily.c_str());
|
||||
if ( wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
xweight = wxT("light");
|
||||
break;
|
||||
}
|
||||
fontSpec.Printf(wxT("-*-%s-thin-*-*-*-*-*-*-*-*-*-*-*"),
|
||||
xfamily.c_str());
|
||||
if ( wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
xweight = wxT("thin");
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case wxFONTWEIGHT_NORMAL:
|
||||
{
|
||||
fontSpec.Printf(wxT("-*-%s-medium-*-*-*-*-*-*-*-*-*-*-*"),
|
||||
xfamily.c_str());
|
||||
if ( wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
xweight = wxT("medium");
|
||||
break;
|
||||
}
|
||||
fontSpec.Printf(wxT("-*-%s-normal-*-*-*-*-*-*-*-*-*-*-*"),
|
||||
xfamily.c_str());
|
||||
if ( wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
xweight = wxT("normal");
|
||||
break;
|
||||
}
|
||||
fontSpec.Printf(wxT("-*-%s-regular-*-*-*-*-*-*-*-*-*-*-*"),
|
||||
xfamily.c_str());
|
||||
if ( wxTestFontSpec(fontSpec) )
|
||||
{
|
||||
xweight = wxT("regular");
|
||||
break;
|
||||
}
|
||||
xweight = wxT("*");
|
||||
}
|
||||
break;
|
||||
default: xweight = wxT("*"); break;
|
||||
}
|
||||
wxNativeFontInfo infoWithStyle(info);
|
||||
infoWithStyle.SetStyle(style);
|
||||
if ( wxTestFontSpec(infoWithStyle.GetXFontName()) )
|
||||
info = infoWithStyle;
|
||||
|
||||
// if pointSize is -1, don't specify any
|
||||
wxString sizeSpec;
|
||||
if ( pointSize == -1 )
|
||||
{
|
||||
sizeSpec = wxT('*');
|
||||
}
|
||||
else
|
||||
{
|
||||
sizeSpec.Printf(wxT("%d"), pointSize);
|
||||
}
|
||||
wxNativeFontInfo infoWithWeight(info);
|
||||
infoWithWeight.SetNumericWeight(weight);
|
||||
if ( wxTestFontSpec(infoWithWeight.GetXFontName()) )
|
||||
info = infoWithWeight;
|
||||
|
||||
// construct the X font spec from our data
|
||||
fontSpec.Printf(wxT("-*-%s-%s-%s-normal-*-*-%s-*-*-*-*-%s-%s"),
|
||||
xfamily.c_str(), xweight.c_str(), xstyle.c_str(),
|
||||
sizeSpec.c_str(), xregistry.c_str(), xencoding.c_str());
|
||||
wxString fontSpec;
|
||||
fontSpec.Printf("-*-%s-%s-%s-normal-*-*-%s-*-*-*-*-%s-%s",
|
||||
info.GetXFontComponent(wxXLFD_FAMILY),
|
||||
info.GetXFontComponent(wxXLFD_WEIGHT),
|
||||
info.GetXFontComponent(wxXLFD_SLANT),
|
||||
info.GetXFontComponent(wxXLFD_POINTSIZE),
|
||||
xregistry,
|
||||
xencoding);
|
||||
|
||||
if( xFontName )
|
||||
*xFontName = fontSpec;
|
||||
|
112
src/x11/font.cpp
112
src/x11/font.cpp
@@ -52,6 +52,28 @@
|
||||
static const int wxDEFAULT_FONT_SIZE = 12;
|
||||
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// helper functions
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static wxFontWeight ParseWeightString(wxString s)
|
||||
{
|
||||
s.MakeUpper();
|
||||
|
||||
if (s == "THIN") return wxFONTWEIGHT_THIN;
|
||||
if (s == "EXTRALIGHT" || s == "ULTRALIGHT") return wxFONTWEIGHT_EXTRALIGHT;
|
||||
if (s == "LIGHT") return wxFONTWEIGHT_LIGHT;
|
||||
if (s == "NORMAL") return wxFONTWEIGHT_NORMAL;
|
||||
if (s == "MEDIUM") return wxFONTWEIGHT_MEDIUM;
|
||||
if (s == "DEMIBOLD" || s == "SEMIBOLD") return wxFONTWEIGHT_SEMIBOLD;
|
||||
if (s == "BOLD") return wxFONTWEIGHT_BOLD;
|
||||
if (s == "EXTRABOLD" || s == "ULTRABOLD") return wxFONTWEIGHT_EXTRABOLD;
|
||||
if (s == "BLACK" || s == "HEAVY") return wxFONTWEIGHT_HEAVY;
|
||||
if (s == "EXTRAHEAVY") return wxFONTWEIGHT_EXTRAHEAVY;
|
||||
|
||||
return wxFONTWEIGHT_NORMAL;
|
||||
}
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
#else
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -116,10 +138,10 @@ public:
|
||||
|
||||
// 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
|
||||
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 SetUnderlined(bool underlined);
|
||||
void SetStrikethrough(bool strikethrough);
|
||||
bool SetFaceName(const wxString& facename);
|
||||
@@ -143,10 +165,10 @@ protected:
|
||||
void InitFromNative();
|
||||
|
||||
// font attributes
|
||||
int m_pointSize;
|
||||
float m_pointSize;
|
||||
wxFontFamily m_family;
|
||||
wxFontStyle m_style;
|
||||
wxFontWeight m_weight;
|
||||
int m_weight;
|
||||
bool m_underlined;
|
||||
bool m_strikethrough;
|
||||
wxString m_faceName;
|
||||
@@ -223,12 +245,12 @@ void wxFontRefData::Init(int pointSize,
|
||||
}
|
||||
|
||||
m_nativeFontInfo.SetFaceName(m_faceName);
|
||||
m_nativeFontInfo.SetWeight((wxFontWeight)m_weight);
|
||||
m_nativeFontInfo.SetNumericWeight(m_weight);
|
||||
m_nativeFontInfo.SetStyle((wxFontStyle)m_style);
|
||||
m_nativeFontInfo.SetUnderlined(underlined);
|
||||
#endif // wxUSE_UNICODE
|
||||
|
||||
SetPointSize(pointSize);
|
||||
SetFractionalPointSize(static_cast<float>(pointSize));
|
||||
}
|
||||
|
||||
void wxFontRefData::InitFromNative()
|
||||
@@ -240,7 +262,7 @@ void wxFontRefData::InitFromNative()
|
||||
// init fields
|
||||
m_faceName = wxGTK_CONV_BACK( pango_font_description_get_family( desc ) );
|
||||
|
||||
m_pointSize = pango_font_description_get_size( desc ) / PANGO_SCALE;
|
||||
m_pointSize = static_cast<float>(pango_font_description_get_size( desc )) / PANGO_SCALE;
|
||||
|
||||
switch (pango_font_description_get_style( desc ))
|
||||
{
|
||||
@@ -255,56 +277,18 @@ void wxFontRefData::InitFromNative()
|
||||
break;
|
||||
}
|
||||
|
||||
// Not defined in some Pango versions
|
||||
#define wxPANGO_WEIGHT_SEMIBOLD 600
|
||||
|
||||
switch (pango_font_description_get_weight( desc ))
|
||||
{
|
||||
case PANGO_WEIGHT_ULTRALIGHT:
|
||||
case PANGO_WEIGHT_LIGHT:
|
||||
m_weight = wxFONTWEIGHT_LIGHT;
|
||||
break;
|
||||
|
||||
default:
|
||||
wxFAIL_MSG(wxT("unknown Pango font weight"));
|
||||
// fall through
|
||||
|
||||
case PANGO_WEIGHT_NORMAL:
|
||||
m_weight = wxFONTWEIGHT_NORMAL;
|
||||
break;
|
||||
|
||||
case wxPANGO_WEIGHT_SEMIBOLD:
|
||||
case PANGO_WEIGHT_BOLD:
|
||||
case PANGO_WEIGHT_ULTRABOLD:
|
||||
case PANGO_WEIGHT_HEAVY:
|
||||
m_weight = wxFONTWEIGHT_BOLD;
|
||||
break;
|
||||
}
|
||||
|
||||
m_weight = pango_font_description_get_weight( desc );
|
||||
#else // X11
|
||||
// get the font parameters from the XLFD
|
||||
// -------------------------------------
|
||||
|
||||
m_faceName = m_nativeFontInfo.GetXFontComponent(wxXLFD_FAMILY);
|
||||
|
||||
m_weight = wxFONTWEIGHT_NORMAL;
|
||||
|
||||
wxString w = m_nativeFontInfo.GetXFontComponent(wxXLFD_WEIGHT).Upper();
|
||||
if ( !w.empty() && w != wxT('*') )
|
||||
{
|
||||
// the test below catches all of BOLD, EXTRABOLD, DEMIBOLD, ULTRABOLD
|
||||
// and BLACK
|
||||
if ( ((w[0u] == wxT('B') && (!wxStrcmp(w.c_str() + 1, wxT("OLD")) ||
|
||||
!wxStrcmp(w.c_str() + 1, wxT("LACK"))))) ||
|
||||
wxStrstr(w.c_str() + 1, wxT("BOLD")) )
|
||||
{
|
||||
m_weight = wxFONTWEIGHT_BOLD;
|
||||
}
|
||||
else if ( w == wxT("LIGHT") || w == wxT("THIN") )
|
||||
{
|
||||
m_weight = wxFONTWEIGHT_LIGHT;
|
||||
}
|
||||
}
|
||||
m_weight = ParseWeightString(w);
|
||||
else
|
||||
m_weight = wxFONTWEIGHT_NORMAL;
|
||||
|
||||
switch ( wxToupper( m_nativeFontInfo.
|
||||
GetXFontComponent(wxXLFD_SLANT)[0u]).GetValue() )
|
||||
@@ -442,14 +426,14 @@ wxFontRefData::~wxFontRefData()
|
||||
// wxFontRefData SetXXX()
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxFontRefData::SetPointSize(int pointSize)
|
||||
void wxFontRefData::SetFractionalPointSize(float pointSize)
|
||||
{
|
||||
// NB: Pango doesn't support point sizes less than 1
|
||||
m_pointSize = pointSize == wxDEFAULT || pointSize < 1 ? wxDEFAULT_FONT_SIZE
|
||||
: pointSize;
|
||||
|
||||
#if wxUSE_UNICODE
|
||||
m_nativeFontInfo.SetPointSize(m_pointSize);
|
||||
m_nativeFontInfo.SetFractionalPointSize(m_pointSize);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -486,7 +470,7 @@ void wxFontRefData::SetStyle(wxFontStyle style)
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxFontRefData::SetWeight(wxFontWeight weight)
|
||||
void wxFontRefData::SetNumericWeight(int weight)
|
||||
{
|
||||
m_weight = weight;
|
||||
}
|
||||
@@ -594,15 +578,7 @@ bool wxFont::Create(const wxString& fontname, wxFontEncoding enc)
|
||||
|
||||
M_FONTDATA->m_faceName = tn.GetNextToken(); // family
|
||||
|
||||
tmp = tn.GetNextToken().MakeUpper(); // weight
|
||||
if (tmp == wxT("BOLD")) M_FONTDATA->m_weight = wxFONTWEIGHT_BOLD;
|
||||
if (tmp == wxT("BLACK")) M_FONTDATA->m_weight = wxFONTWEIGHT_BOLD;
|
||||
if (tmp == wxT("EXTRABOLD")) M_FONTDATA->m_weight = wxFONTWEIGHT_BOLD;
|
||||
if (tmp == wxT("DEMIBOLD")) M_FONTDATA->m_weight = wxFONTWEIGHT_BOLD;
|
||||
if (tmp == wxT("ULTRABOLD")) M_FONTDATA->m_weight = wxFONTWEIGHT_BOLD;
|
||||
|
||||
if (tmp == wxT("LIGHT")) M_FONTDATA->m_weight = wxFONTWEIGHT_LIGHT;
|
||||
if (tmp == wxT("THIN")) M_FONTDATA->m_weight = wxFONTWEIGHT_LIGHT;
|
||||
M_FONTDATA->m_weight = ParseWeightString(tn.GetNextToken()); // weight
|
||||
|
||||
tmp = tn.GetNextToken().MakeUpper(); // slant
|
||||
if (tmp == wxT("I")) M_FONTDATA->m_style = wxFONTSTYLE_ITALIC;
|
||||
@@ -716,11 +692,11 @@ void wxFont::Unshare()
|
||||
// accessors
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int wxFont::GetPointSize() const
|
||||
float wxFont::GetFractionalPointSize() const
|
||||
{
|
||||
wxCHECK_MSG( IsOk(), 0, wxT("invalid font") );
|
||||
|
||||
return M_FONTDATA->m_nativeFontInfo.GetPointSize();
|
||||
return M_FONTDATA->m_nativeFontInfo.GetFractionalPointSize();
|
||||
}
|
||||
|
||||
wxString wxFont::GetFaceName() const
|
||||
@@ -742,7 +718,7 @@ wxFontStyle wxFont::GetStyle() const
|
||||
return M_FONTDATA->m_style;
|
||||
}
|
||||
|
||||
wxFontWeight wxFont::GetWeight() const
|
||||
int wxFont::GetNumericWeight() const
|
||||
{
|
||||
wxCHECK_MSG( IsOk(), wxFONTWEIGHT_MAX, wxT("invalid font") );
|
||||
|
||||
@@ -823,11 +799,11 @@ bool wxFont::IsFixedWidth() const
|
||||
// change font attributes
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxFont::SetPointSize(int pointSize)
|
||||
void wxFont::SetFractionalPointSize(float pointSize)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
M_FONTDATA->SetPointSize(pointSize);
|
||||
M_FONTDATA->SetFractionalPointSize(pointSize);
|
||||
}
|
||||
|
||||
void wxFont::SetFamily(wxFontFamily family)
|
||||
@@ -844,11 +820,11 @@ void wxFont::SetStyle(wxFontStyle style)
|
||||
M_FONTDATA->SetStyle(style);
|
||||
}
|
||||
|
||||
void wxFont::SetWeight(wxFontWeight weight)
|
||||
void wxFont::SetNumericWeight(int weight)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
M_FONTDATA->SetWeight(weight);
|
||||
M_FONTDATA->SetNumericWeight(weight);
|
||||
}
|
||||
|
||||
bool wxFont::SetFaceName(const wxString& faceName)
|
||||
|
@@ -2275,10 +2275,10 @@ wxFont wxXmlResourceHandlerImpl::GetFont(const wxString& param, wxWindow* parent
|
||||
// font attributes:
|
||||
|
||||
// size
|
||||
int isize = -1;
|
||||
float pointSize = -1.0f;
|
||||
bool hasSize = HasParam(wxT("size"));
|
||||
if (hasSize)
|
||||
isize = GetLong(wxT("size"), -1);
|
||||
pointSize = GetFloat(wxT("size"), -1.0f);
|
||||
|
||||
// style
|
||||
wxFontStyle istyle = wxFONTSTYLE_NORMAL;
|
||||
@@ -2301,12 +2301,23 @@ wxFont wxXmlResourceHandlerImpl::GetFont(const wxString& param, wxWindow* parent
|
||||
}
|
||||
|
||||
// weight
|
||||
wxFontWeight iweight = wxFONTWEIGHT_NORMAL;
|
||||
long iweight = wxFONTWEIGHT_NORMAL;
|
||||
bool hasWeight = HasParam(wxT("weight"));
|
||||
if (hasWeight)
|
||||
{
|
||||
wxString weight = GetParamValue(wxT("weight"));
|
||||
if (weight == wxT("thin"))
|
||||
if (weight.ToLong(&iweight))
|
||||
{
|
||||
if (iweight <= wxFONTWEIGHT_INVALID || iweight > wxFONTWEIGHT_MAX)
|
||||
{
|
||||
ReportParamError
|
||||
(
|
||||
param,
|
||||
wxString::Format("invalid font weight value \"%d\"", iweight)
|
||||
);
|
||||
}
|
||||
}
|
||||
else if (weight == wxT("thin"))
|
||||
iweight = wxFONTWEIGHT_THIN;
|
||||
else if (weight == wxT("extralight"))
|
||||
iweight = wxFONTWEIGHT_EXTRALIGHT;
|
||||
@@ -2338,6 +2349,10 @@ wxFont wxXmlResourceHandlerImpl::GetFont(const wxString& param, wxWindow* parent
|
||||
bool hasUnderlined = HasParam(wxT("underlined"));
|
||||
bool underlined = hasUnderlined ? GetBool(wxT("underlined"), false) : false;
|
||||
|
||||
// strikethrough
|
||||
bool hasStrikethrough = HasParam(wxT("strikethrough"));
|
||||
bool strikethrough = hasStrikethrough ? GetBool(wxT("strikethrough"), false) : false;
|
||||
|
||||
// family and facename
|
||||
wxFontFamily ifamily = wxFONTFAMILY_DEFAULT;
|
||||
bool hasFamily = HasParam(wxT("family"));
|
||||
@@ -2433,9 +2448,9 @@ wxFont wxXmlResourceHandlerImpl::GetFont(const wxString& param, wxWindow* parent
|
||||
|
||||
if (font.IsOk())
|
||||
{
|
||||
if (hasSize && isize != -1)
|
||||
if (pointSize > 0)
|
||||
{
|
||||
font.SetPointSize(isize);
|
||||
font.SetFractionalPointSize(pointSize);
|
||||
if (HasParam(wxT("relativesize")))
|
||||
{
|
||||
ReportParamError
|
||||
@@ -2452,9 +2467,11 @@ wxFont wxXmlResourceHandlerImpl::GetFont(const wxString& param, wxWindow* parent
|
||||
if (hasStyle)
|
||||
font.SetStyle(istyle);
|
||||
if (hasWeight)
|
||||
font.SetWeight(iweight);
|
||||
font.SetNumericWeight(iweight);
|
||||
if (hasUnderlined)
|
||||
font.SetUnderlined(underlined);
|
||||
if (hasStrikethrough)
|
||||
font.SetStrikethrough(strikethrough);
|
||||
if (hasFamily)
|
||||
font.SetFamily(ifamily);
|
||||
if (hasFacename)
|
||||
@@ -2464,9 +2481,15 @@ wxFont wxXmlResourceHandlerImpl::GetFont(const wxString& param, wxWindow* parent
|
||||
}
|
||||
else // not based on system font
|
||||
{
|
||||
font = wxFont(isize == -1 ? wxNORMAL_FONT->GetPointSize() : isize,
|
||||
ifamily, istyle, iweight,
|
||||
underlined, facename, enc);
|
||||
font = wxFontInfo(pointSize)
|
||||
.FaceName(facename)
|
||||
.Family(ifamily)
|
||||
.Style(istyle)
|
||||
.Weight(iweight)
|
||||
.Underlined(underlined)
|
||||
.Strikethrough(strikethrough)
|
||||
.Encoding(enc)
|
||||
;
|
||||
}
|
||||
|
||||
m_handler->m_node = oldnode;
|
||||
|
@@ -21,34 +21,16 @@
|
||||
#include "wx/wx.h"
|
||||
#endif // WX_PRECOMP
|
||||
|
||||
#if wxUSE_FONTMAP
|
||||
|
||||
#include "wx/font.h"
|
||||
|
||||
#include "asserthelper.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// test class
|
||||
// local helpers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class FontTestCase : public CppUnit::TestCase
|
||||
{
|
||||
public:
|
||||
FontTestCase() { }
|
||||
|
||||
private:
|
||||
CPPUNIT_TEST_SUITE( FontTestCase );
|
||||
CPPUNIT_TEST( Construct );
|
||||
CPPUNIT_TEST( GetSet );
|
||||
CPPUNIT_TEST( NativeFontInfo );
|
||||
CPPUNIT_TEST( NativeFontInfoUserDesc );
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
void Construct();
|
||||
void GetSet();
|
||||
void NativeFontInfo();
|
||||
void NativeFontInfoUserDesc();
|
||||
|
||||
// Returns a point to an array of fonts and fills the output parameter with the
|
||||
// number of elements in this array.
|
||||
static const wxFont *GetTestFonts(unsigned& numFonts)
|
||||
{
|
||||
static const wxFont testfonts[] =
|
||||
@@ -65,15 +47,6 @@ private:
|
||||
return testfonts;
|
||||
}
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(FontTestCase);
|
||||
};
|
||||
|
||||
// register in the unnamed registry so that these tests are run by default
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION( FontTestCase );
|
||||
|
||||
// also include in its own registry so that these tests can be run alone
|
||||
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( FontTestCase, "FontTestCase" );
|
||||
|
||||
wxString DumpFont(const wxFont *font)
|
||||
{
|
||||
// dumps the internal properties of a wxFont in the same order they
|
||||
@@ -96,13 +69,17 @@ wxString DumpFont(const wxFont *font)
|
||||
return s;
|
||||
}
|
||||
|
||||
void FontTestCase::Construct()
|
||||
// ----------------------------------------------------------------------------
|
||||
// the tests
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
TEST_CASE("wxFont::Construct", "[font][ctor]")
|
||||
{
|
||||
// The main purpose of this test is to verify that the font ctors below
|
||||
// compile because it's easy to introduce ambiguities due to the number of
|
||||
// overloaded wxFont ctors.
|
||||
|
||||
CPPUNIT_ASSERT( wxFont(10, wxFONTFAMILY_DEFAULT,
|
||||
CHECK( wxFont(10, wxFONTFAMILY_DEFAULT,
|
||||
wxFONTSTYLE_NORMAL,
|
||||
wxFONTWEIGHT_NORMAL).IsOk() );
|
||||
|
||||
@@ -118,7 +95,7 @@ void FontTestCase::Construct()
|
||||
|
||||
// Tests relying on the soon-to-be-deprecated ctor taking ints and not
|
||||
// wxFontXXX enum elements.
|
||||
CPPUNIT_ASSERT( wxFont(10, wxDEFAULT, wxNORMAL, wxNORMAL).IsOk() );
|
||||
CHECK( wxFont(10, wxDEFAULT, wxNORMAL, wxNORMAL).IsOk() );
|
||||
|
||||
wxGCC_WARNING_RESTORE(deprecated-declarations)
|
||||
|
||||
@@ -128,7 +105,133 @@ void FontTestCase::Construct()
|
||||
#endif // WXWIN_COMPATIBILITY_3_0
|
||||
}
|
||||
|
||||
void FontTestCase::GetSet()
|
||||
TEST_CASE("wxFont::Size", "[font][size]")
|
||||
{
|
||||
const struct Sizes
|
||||
{
|
||||
int specified; // Size in points specified in the ctor.
|
||||
int expected; // Expected GetPointSize() return value,
|
||||
// -1 here means "same as wxNORMAL_FONT".
|
||||
} sizes[] =
|
||||
{
|
||||
{ 9, 9 },
|
||||
{ 10, 10 },
|
||||
{ 11, 11 },
|
||||
{ -1, -1 },
|
||||
{ 70, -1 }, // 70 == wxDEFAULT, should be handled specially
|
||||
{ 90, 90 }, // 90 == wxNORMAL, should not be handled specially
|
||||
};
|
||||
|
||||
const int sizeDefault = wxFont(wxFontInfo()).GetPointSize();
|
||||
|
||||
for ( size_t n = 0; n < WXSIZEOF(sizes); n++ )
|
||||
{
|
||||
const Sizes& size = sizes[n];
|
||||
|
||||
// Note: use the old-style wxFont ctor as wxFontInfo doesn't implement
|
||||
// any compatibility hacks.
|
||||
const wxFont font(size.specified,
|
||||
wxFONTFAMILY_DEFAULT,
|
||||
wxFONTSTYLE_NORMAL,
|
||||
wxFONTWEIGHT_NORMAL);
|
||||
|
||||
int expected = size.expected;
|
||||
if ( expected == -1 )
|
||||
expected = sizeDefault;
|
||||
|
||||
INFO("specified = " << size.specified <<
|
||||
", expected = " << size.expected);
|
||||
CHECK( font.GetPointSize() == expected );
|
||||
}
|
||||
|
||||
// Note that the compatibility hacks only apply to the old ctors, the newer
|
||||
// one, taking wxFontInfo, doesn't support them.
|
||||
CHECK( wxFont(wxFontInfo(70)).GetPointSize() == 70 );
|
||||
CHECK( wxFont(wxFontInfo(90)).GetPointSize() == 90 );
|
||||
|
||||
// Check fractional point sizes as well.
|
||||
wxFont font(wxFontInfo(12.25));
|
||||
CHECK( font.GetFractionalPointSize() == 12.25 );
|
||||
CHECK( font.GetPointSize() == 12 );
|
||||
|
||||
font = *wxNORMAL_FONT;
|
||||
font.SetFractionalPointSize(9.5);
|
||||
CHECK( font.GetFractionalPointSize() == 9.5 );
|
||||
CHECK( font.GetPointSize() == 10 );
|
||||
}
|
||||
|
||||
TEST_CASE("wxFont::Style", "[font][style]")
|
||||
{
|
||||
#if WXWIN_COMPATIBILITY_3_0
|
||||
// Disable the warning about deprecated wxNORMAL as we use it here
|
||||
// intentionally.
|
||||
#ifdef __VISUALC__
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4996)
|
||||
#endif
|
||||
|
||||
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
|
||||
|
||||
wxFont fontNormal(10, wxDEFAULT, wxNORMAL, wxNORMAL);
|
||||
CHECK( fontNormal.GetStyle() == wxFONTSTYLE_NORMAL );
|
||||
|
||||
wxFont fontItalic(10, wxDEFAULT, wxITALIC, wxNORMAL);
|
||||
CHECK( fontItalic.GetStyle() == wxFONTSTYLE_ITALIC );
|
||||
|
||||
wxFont fontSlant(10, wxDEFAULT, wxSLANT, wxNORMAL);
|
||||
#ifdef __WXMSW__
|
||||
CHECK( fontSlant.GetStyle() == wxFONTSTYLE_ITALIC );
|
||||
#else
|
||||
CHECK( fontSlant.GetStyle() == wxFONTSTYLE_SLANT );
|
||||
#endif
|
||||
|
||||
wxGCC_WARNING_RESTORE(deprecated-declarations)
|
||||
|
||||
#ifdef __VISUALC__
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
#endif // WXWIN_COMPATIBILITY_3_0
|
||||
}
|
||||
|
||||
TEST_CASE("wxFont::Weight", "[font][weight]")
|
||||
{
|
||||
wxFont font;
|
||||
font.SetNumericWeight(123);
|
||||
CHECK( font.GetNumericWeight() == 123 );
|
||||
CHECK( font.GetWeight() == wxFONTWEIGHT_THIN );
|
||||
|
||||
font.SetNumericWeight(wxFONTWEIGHT_SEMIBOLD);
|
||||
CHECK( font.GetNumericWeight() == wxFONTWEIGHT_SEMIBOLD );
|
||||
CHECK( font.GetWeight() == wxFONTWEIGHT_SEMIBOLD );
|
||||
|
||||
#if WXWIN_COMPATIBILITY_3_0
|
||||
// Disable the warning about deprecated wxNORMAL as we use it here
|
||||
// intentionally.
|
||||
#ifdef __VISUALC__
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4996)
|
||||
#endif
|
||||
|
||||
wxGCC_WARNING_SUPPRESS(deprecated-declarations)
|
||||
|
||||
wxFont fontNormal(10, wxDEFAULT, wxNORMAL, wxNORMAL);
|
||||
CHECK( fontNormal.GetWeight() == wxFONTWEIGHT_NORMAL );
|
||||
|
||||
wxFont fontBold(10, wxDEFAULT, wxNORMAL, wxBOLD);
|
||||
CHECK( fontBold.GetWeight() == wxFONTWEIGHT_BOLD );
|
||||
|
||||
wxFont fontLight(10, wxDEFAULT, wxNORMAL, wxLIGHT);
|
||||
CHECK( fontLight.GetWeight() == wxFONTWEIGHT_LIGHT );
|
||||
|
||||
wxGCC_WARNING_RESTORE(deprecated-declarations)
|
||||
|
||||
#ifdef __VISUALC__
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
#endif // WXWIN_COMPATIBILITY_3_0
|
||||
}
|
||||
|
||||
TEST_CASE("wxFont::GetSet", "[font][getters]")
|
||||
{
|
||||
unsigned numFonts;
|
||||
const wxFont *pf = GetTestFonts(numFonts);
|
||||
@@ -137,12 +240,12 @@ void FontTestCase::GetSet()
|
||||
wxFont test(*pf++);
|
||||
|
||||
// remember: getters can only be called when wxFont::IsOk() == true
|
||||
CPPUNIT_ASSERT( test.IsOk() );
|
||||
CHECK( test.IsOk() );
|
||||
|
||||
|
||||
// test Get/SetFaceName()
|
||||
CPPUNIT_ASSERT( !test.SetFaceName("a dummy face name") );
|
||||
CPPUNIT_ASSERT( !test.IsOk() );
|
||||
CHECK( !test.SetFaceName("a dummy face name") );
|
||||
CHECK( !test.IsOk() );
|
||||
|
||||
// if the call to SetFaceName() below fails on your system/port,
|
||||
// consider adding another branch to this #if
|
||||
@@ -159,41 +262,41 @@ void FontTestCase::GetSet()
|
||||
"available on this system)", knownGoodFaceName, n),
|
||||
test.SetFaceName(knownGoodFaceName)
|
||||
);
|
||||
CPPUNIT_ASSERT( test.IsOk() );
|
||||
CHECK( test.IsOk() );
|
||||
|
||||
|
||||
// test Get/SetFamily()
|
||||
|
||||
test.SetFamily( wxFONTFAMILY_ROMAN );
|
||||
CPPUNIT_ASSERT( test.IsOk() );
|
||||
CHECK( test.IsOk() );
|
||||
|
||||
// note that there is always the possibility that GetFamily() returns
|
||||
// wxFONTFAMILY_DEFAULT (meaning "unknown" in this case) so that we
|
||||
// consider it as a valid return value
|
||||
const wxFontFamily family = test.GetFamily();
|
||||
if ( family != wxFONTFAMILY_DEFAULT )
|
||||
CPPUNIT_ASSERT_EQUAL( wxFONTFAMILY_ROMAN, family );
|
||||
CHECK( wxFONTFAMILY_ROMAN == family );
|
||||
|
||||
|
||||
// test Get/SetEncoding()
|
||||
|
||||
//test.SetEncoding( wxFONTENCODING_KOI8 );
|
||||
//CPPUNIT_ASSERT( test.IsOk() );
|
||||
//CPPUNIT_ASSERT_EQUAL( wxFONTENCODING_KOI8 , test.GetEncoding() );
|
||||
//CHECK( test.IsOk() );
|
||||
//CHECK( wxFONTENCODING_KOI8 == test.GetEncoding() );
|
||||
|
||||
|
||||
// test Get/SetPointSize()
|
||||
|
||||
test.SetPointSize(30);
|
||||
CPPUNIT_ASSERT( test.IsOk() );
|
||||
CPPUNIT_ASSERT_EQUAL( 30, test.GetPointSize() );
|
||||
CHECK( test.IsOk() );
|
||||
CHECK( 30 == test.GetPointSize() );
|
||||
|
||||
|
||||
// test Get/SetPixelSize()
|
||||
|
||||
test.SetPixelSize(wxSize(0,30));
|
||||
CPPUNIT_ASSERT( test.IsOk() );
|
||||
CPPUNIT_ASSERT( test.GetPixelSize().GetHeight() <= 30 );
|
||||
CHECK( test.IsOk() );
|
||||
CHECK( test.GetPixelSize().GetHeight() <= 30 );
|
||||
// NOTE: the match found by SetPixelSize() may be not 100% precise; it
|
||||
// only grants that a font smaller than the required height will
|
||||
// be selected
|
||||
@@ -202,43 +305,43 @@ void FontTestCase::GetSet()
|
||||
// test Get/SetStyle()
|
||||
|
||||
test.SetStyle(wxFONTSTYLE_SLANT);
|
||||
CPPUNIT_ASSERT( test.IsOk() );
|
||||
CHECK( test.IsOk() );
|
||||
#ifdef __WXMSW__
|
||||
// on wxMSW wxFONTSTYLE_SLANT==wxFONTSTYLE_ITALIC, so accept the latter
|
||||
// as a valid value too.
|
||||
if ( test.GetStyle() != wxFONTSTYLE_ITALIC )
|
||||
#endif
|
||||
CPPUNIT_ASSERT_EQUAL( wxFONTSTYLE_SLANT, test.GetStyle() );
|
||||
CHECK( wxFONTSTYLE_SLANT == test.GetStyle() );
|
||||
|
||||
// test Get/SetUnderlined()
|
||||
|
||||
test.SetUnderlined(true);
|
||||
CPPUNIT_ASSERT( test.IsOk() );
|
||||
CPPUNIT_ASSERT_EQUAL( true, test.GetUnderlined() );
|
||||
CHECK( test.IsOk() );
|
||||
CHECK( test.GetUnderlined() );
|
||||
|
||||
const wxFont fontBase = test.GetBaseFont();
|
||||
CPPUNIT_ASSERT( fontBase.IsOk() );
|
||||
CPPUNIT_ASSERT( !fontBase.GetUnderlined() );
|
||||
CPPUNIT_ASSERT( !fontBase.GetStrikethrough() );
|
||||
CPPUNIT_ASSERT_EQUAL( wxFONTWEIGHT_NORMAL, fontBase.GetWeight() );
|
||||
CPPUNIT_ASSERT_EQUAL( wxFONTSTYLE_NORMAL, fontBase.GetStyle() );
|
||||
CHECK( fontBase.IsOk() );
|
||||
CHECK( !fontBase.GetUnderlined() );
|
||||
CHECK( !fontBase.GetStrikethrough() );
|
||||
CHECK( wxFONTWEIGHT_NORMAL == fontBase.GetWeight() );
|
||||
CHECK( wxFONTSTYLE_NORMAL == fontBase.GetStyle() );
|
||||
|
||||
// test Get/SetStrikethrough()
|
||||
|
||||
test.SetStrikethrough(true);
|
||||
CPPUNIT_ASSERT( test.IsOk() );
|
||||
CPPUNIT_ASSERT_EQUAL( true, test.GetStrikethrough() );
|
||||
CHECK( test.IsOk() );
|
||||
CHECK( test.GetStrikethrough() );
|
||||
|
||||
|
||||
// test Get/SetWeight()
|
||||
|
||||
test.SetWeight(wxFONTWEIGHT_BOLD);
|
||||
CPPUNIT_ASSERT( test.IsOk() );
|
||||
CPPUNIT_ASSERT_EQUAL( wxFONTWEIGHT_BOLD, test.GetWeight() );
|
||||
CHECK( test.IsOk() );
|
||||
CHECK( wxFONTWEIGHT_BOLD == test.GetWeight() );
|
||||
}
|
||||
}
|
||||
|
||||
void FontTestCase::NativeFontInfo()
|
||||
TEST_CASE("wxFont::NativeFontInfo", "[font][fontinfo]")
|
||||
{
|
||||
unsigned numFonts;
|
||||
const wxFont *pf = GetTestFonts(numFonts);
|
||||
@@ -247,12 +350,12 @@ void FontTestCase::NativeFontInfo()
|
||||
wxFont test(*pf++);
|
||||
|
||||
const wxString& nid = test.GetNativeFontInfoDesc();
|
||||
CPPUNIT_ASSERT( !nid.empty() );
|
||||
CHECK( !nid.empty() );
|
||||
// documented to be never empty
|
||||
|
||||
wxFont temp;
|
||||
CPPUNIT_ASSERT( temp.SetNativeFontInfo(nid) );
|
||||
CPPUNIT_ASSERT( temp.IsOk() );
|
||||
CHECK( temp.SetNativeFontInfo(nid) );
|
||||
CHECK( temp.IsOk() );
|
||||
WX_ASSERT_MESSAGE(
|
||||
("Test #%u failed\ndump of test font: \"%s\"\ndump of temp font: \"%s\"", \
|
||||
n, DumpFont(&test), DumpFont(&temp)),
|
||||
@@ -261,14 +364,14 @@ void FontTestCase::NativeFontInfo()
|
||||
|
||||
// test that clearly invalid font info strings do not work
|
||||
wxFont font;
|
||||
CPPUNIT_ASSERT( !font.SetNativeFontInfo("") );
|
||||
CHECK( !font.SetNativeFontInfo("") );
|
||||
|
||||
// pango_font_description_from_string() used by wxFont in wxGTK and wxX11
|
||||
// never returns an error at all so this assertion fails there -- and as it
|
||||
// doesn't seem to be possible to do anything about it maybe we should
|
||||
// change wxMSW and other ports to also accept any strings?
|
||||
#if !defined(__WXGTK__) && !defined(__WXX11__)
|
||||
CPPUNIT_ASSERT( !font.SetNativeFontInfo("bloordyblop") );
|
||||
CHECK( !font.SetNativeFontInfo("bloordyblop") );
|
||||
#endif
|
||||
|
||||
// Pango font description doesn't have 'underlined' and 'strikethrough'
|
||||
@@ -276,23 +379,23 @@ void FontTestCase::NativeFontInfo()
|
||||
// are properly preserved by wxNativeFontInfo or its string description.
|
||||
font.SetUnderlined(true);
|
||||
font.SetStrikethrough(true);
|
||||
CPPUNIT_ASSERT_EQUAL(font, wxFont(font));
|
||||
CPPUNIT_ASSERT_EQUAL(font, wxFont(*font.GetNativeFontInfo()));
|
||||
CPPUNIT_ASSERT_EQUAL(font, wxFont(font.GetNativeFontInfoDesc()));
|
||||
CHECK(font == wxFont(font));
|
||||
CHECK(font == wxFont(*font.GetNativeFontInfo()));
|
||||
CHECK(font == wxFont(font.GetNativeFontInfoDesc()));
|
||||
font.SetUnderlined(false);
|
||||
CPPUNIT_ASSERT_EQUAL(font, wxFont(font));
|
||||
CPPUNIT_ASSERT_EQUAL(font, wxFont(*font.GetNativeFontInfo()));
|
||||
CPPUNIT_ASSERT_EQUAL(font, wxFont(font.GetNativeFontInfoDesc()));
|
||||
CHECK(font == wxFont(font));
|
||||
CHECK(font == wxFont(*font.GetNativeFontInfo()));
|
||||
CHECK(font == wxFont(font.GetNativeFontInfoDesc()));
|
||||
font.SetUnderlined(true);
|
||||
font.SetStrikethrough(false);
|
||||
CPPUNIT_ASSERT_EQUAL(font, wxFont(font));
|
||||
CPPUNIT_ASSERT_EQUAL(font, wxFont(*font.GetNativeFontInfo()));
|
||||
CPPUNIT_ASSERT_EQUAL(font, wxFont(font.GetNativeFontInfoDesc()));
|
||||
CHECK(font == wxFont(font));
|
||||
CHECK(font == wxFont(*font.GetNativeFontInfo()));
|
||||
CHECK(font == wxFont(font.GetNativeFontInfoDesc()));
|
||||
// note: the GetNativeFontInfoUserDesc() doesn't preserve all attributes
|
||||
// according to docs, so it is not tested.
|
||||
}
|
||||
|
||||
void FontTestCase::NativeFontInfoUserDesc()
|
||||
TEST_CASE("wxFont::NativeFontInfoUserDesc", "[font][fontinfo]")
|
||||
{
|
||||
unsigned numFonts;
|
||||
const wxFont *pf = GetTestFonts(numFonts);
|
||||
@@ -301,12 +404,12 @@ void FontTestCase::NativeFontInfoUserDesc()
|
||||
wxFont test(*pf++);
|
||||
|
||||
const wxString& niud = test.GetNativeFontInfoUserDesc();
|
||||
CPPUNIT_ASSERT( !niud.empty() );
|
||||
CHECK( !niud.empty() );
|
||||
// documented to be never empty
|
||||
|
||||
wxFont temp2;
|
||||
CPPUNIT_ASSERT( temp2.SetNativeFontInfoUserDesc(niud) );
|
||||
CPPUNIT_ASSERT( temp2.IsOk() );
|
||||
CHECK( temp2.SetNativeFontInfoUserDesc(niud) );
|
||||
CHECK( temp2.IsOk() );
|
||||
|
||||
#ifdef __WXGTK__
|
||||
// Pango saves/restores all font info in the user-friendly string:
|
||||
@@ -319,8 +422,8 @@ void FontTestCase::NativeFontInfoUserDesc()
|
||||
// are not granted to save/restore all font info.
|
||||
// In fact e.g. the font family is not saved at all; test only those
|
||||
// info which GetNativeFontInfoUserDesc() does indeed save:
|
||||
CPPUNIT_ASSERT_EQUAL( test.GetWeight(), temp2.GetWeight() );
|
||||
CPPUNIT_ASSERT_EQUAL( test.GetStyle(), temp2.GetStyle() );
|
||||
CHECK( test.GetWeight() == temp2.GetWeight() );
|
||||
CHECK( test.GetStyle() == temp2.GetStyle() );
|
||||
|
||||
// if the original face name was empty, it means that any face name (in
|
||||
// this family) can be used for the new font so we shouldn't be
|
||||
@@ -328,13 +431,11 @@ void FontTestCase::NativeFontInfoUserDesc()
|
||||
const wxString facename = test.GetFaceName();
|
||||
if ( !facename.empty() )
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL( facename.Upper(), temp2.GetFaceName().Upper() );
|
||||
CHECK( facename.Upper() == temp2.GetFaceName().Upper() );
|
||||
}
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL( test.GetPointSize(), temp2.GetPointSize() );
|
||||
CPPUNIT_ASSERT_EQUAL( test.GetEncoding(), temp2.GetEncoding() );
|
||||
CHECK( test.GetPointSize() == temp2.GetPointSize() );
|
||||
CHECK( test.GetEncoding() == temp2.GetEncoding() );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#endif // wxUSE_FONTMAP
|
||||
|
Reference in New Issue
Block a user