Extending wxFont API & OSX Core Text Implementation (#877)
* Switch to pure Core Text Implementation, Start extended Font API * mac fixes * First msw implementation * Fixing paste error * fixing typo * Rearranging lines to former fallthrough order * Blind fixes for covering new abstract methods * Blind gtk implementations * Fixing according to travis .. * Removing method defined in base * formatting adaptions * Extending the schema definition for new weights * fixing typo, using wxRound, other fixes according to comments * changes according to suggestions * fixing init order, before the init of m_info was overridden by Init() * redo * redo * redo * Cleanup Removing obsolete code snippets, proper traces for font names * Moving common code Only the Get/SetNumericWeight calls should now be implemented in the native part, the ‚old‘ Get/SetWeight are common code and use the numeric counterparts. * Updating docs * commit wa missing changes.txt * Doc fixes * Full stops added
This commit is contained in:
@@ -59,10 +59,18 @@ enum wxFontStyle
|
||||
// font weights
|
||||
enum wxFontWeight
|
||||
{
|
||||
wxFONTWEIGHT_NORMAL = wxNORMAL,
|
||||
wxFONTWEIGHT_LIGHT = wxLIGHT,
|
||||
wxFONTWEIGHT_BOLD = wxBOLD,
|
||||
wxFONTWEIGHT_MAX
|
||||
wxFONTWEIGHT_INVALID = 0,
|
||||
wxFONTWEIGHT_THIN = 100,
|
||||
wxFONTWEIGHT_EXTRALIGHT = 200,
|
||||
wxFONTWEIGHT_LIGHT = 300,
|
||||
wxFONTWEIGHT_NORMAL = 400,
|
||||
wxFONTWEIGHT_MEDIUM = 500,
|
||||
wxFONTWEIGHT_SEMIBOLD = 600,
|
||||
wxFONTWEIGHT_BOLD = 700,
|
||||
wxFONTWEIGHT_EXTRABOLD = 800,
|
||||
wxFONTWEIGHT_HEAVY = 900,
|
||||
wxFONTWEIGHT_EXTRAHEAVY = 1000,
|
||||
wxFONTWEIGHT_MAX = wxFONTWEIGHT_EXTRAHEAVY
|
||||
};
|
||||
|
||||
// Symbolic font sizes as defined in CSS specification.
|
||||
@@ -338,12 +346,14 @@ public:
|
||||
bool operator!=(const wxFont& font) const { return !(*this == font); }
|
||||
|
||||
// accessors: get the font characteristics
|
||||
virtual int GetPointSize() const = 0;
|
||||
virtual int GetPointSize() const;
|
||||
virtual float GetFractionalPointSize() const = 0;
|
||||
virtual wxSize GetPixelSize() const;
|
||||
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; }
|
||||
virtual wxString GetFaceName() const = 0;
|
||||
@@ -356,11 +366,12 @@ public:
|
||||
wxString GetNativeFontInfoUserDesc() const;
|
||||
|
||||
// change the font characteristics
|
||||
virtual void SetPointSize( int pointSize ) = 0;
|
||||
virtual void SetPointSize( 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;
|
||||
virtual void SetStrikethrough( bool WXUNUSED(strikethrough) ) {}
|
||||
|
@@ -29,6 +29,10 @@
|
||||
#include <QtGui/QFont>
|
||||
#endif
|
||||
|
||||
#if defined(__WXOSX__)
|
||||
#include "wx/osx/core/cfref.h"
|
||||
#endif
|
||||
|
||||
class WXDLLIMPEXP_FWD_BASE wxArrayString;
|
||||
struct WXDLLIMPEXP_FWD_CORE wxNativeEncodingInfo;
|
||||
|
||||
@@ -120,20 +124,7 @@ public:
|
||||
#elif defined(__WXOSX__)
|
||||
public:
|
||||
wxNativeFontInfo(const wxNativeFontInfo& info) { Init(info); }
|
||||
wxNativeFontInfo( 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);
|
||||
}
|
||||
|
||||
|
||||
~wxNativeFontInfo() { Free(); }
|
||||
|
||||
wxNativeFontInfo& operator=(const wxNativeFontInfo& info)
|
||||
@@ -146,30 +137,44 @@ public:
|
||||
return *this;
|
||||
}
|
||||
|
||||
void Init(CTFontDescriptorRef descr);
|
||||
void InitFromFont(CTFontRef font);
|
||||
void InitFromFontDescriptor(CTFontDescriptorRef font);
|
||||
void Init(const wxNativeFontInfo& info);
|
||||
void Init(int size,
|
||||
wxFontFamily family,
|
||||
wxFontStyle style,
|
||||
wxFontWeight weight,
|
||||
bool underlined,
|
||||
bool strikethrough,
|
||||
const wxString& faceName ,
|
||||
wxFontEncoding encoding);
|
||||
|
||||
void Free();
|
||||
|
||||
wxString GetFamilyName() const;
|
||||
wxString GetStyleName() const;
|
||||
|
||||
static void UpdateNamesMap(const wxString& familyname, CTFontDescriptorRef descr);
|
||||
static void UpdateNamesMap(const wxString& familyname, CTFontRef font);
|
||||
|
||||
int m_pointSize;
|
||||
wxFontFamily m_family;
|
||||
static CGFloat GetCTWeight( CTFontRef font );
|
||||
static CGFloat GetCTWeight( CTFontDescriptorRef font );
|
||||
static CGFloat GetCTSlant( CTFontDescriptorRef font );
|
||||
|
||||
|
||||
CTFontDescriptorRef GetCTFontDescriptor() const;
|
||||
private:
|
||||
// attributes for regenerating a CTFontDescriptor, stay close to native values
|
||||
// for better roundtrip fidelity
|
||||
CGFloat m_ctWeight;
|
||||
wxFontStyle m_style;
|
||||
wxFontWeight m_weight;
|
||||
CGFloat m_ctSize;
|
||||
wxFontFamily m_family;
|
||||
|
||||
wxString m_styleName;
|
||||
wxString m_familyName;
|
||||
|
||||
// native font description
|
||||
wxCFRef<CTFontDescriptorRef> m_descriptor;
|
||||
void CreateCTFontDescriptor();
|
||||
|
||||
// these attributes are not part of a CTFont
|
||||
bool m_underlined;
|
||||
bool m_strikethrough;
|
||||
wxString m_faceName;
|
||||
wxFontEncoding m_encoding;
|
||||
|
||||
public :
|
||||
#elif defined(__WXQT__)
|
||||
QFont m_qtFont;
|
||||
@@ -219,7 +224,7 @@ public:
|
||||
// init with the parameters of the given font
|
||||
void InitFromFont(const wxFont& font)
|
||||
{
|
||||
#if wxUSE_PANGO
|
||||
#if wxUSE_PANGO || defined(__WXOSX__)
|
||||
Init(*font.GetNativeFontInfo());
|
||||
#else
|
||||
// translate all font parameters
|
||||
@@ -252,18 +257,21 @@ public:
|
||||
|
||||
// accessors and modifiers for the font elements
|
||||
int GetPointSize() const;
|
||||
float GetFractionalPointSize() const;
|
||||
wxSize GetPixelSize() const;
|
||||
wxFontStyle GetStyle() const;
|
||||
wxFontWeight GetWeight() const;
|
||||
int GetNumericWeight() const;
|
||||
bool GetUnderlined() const;
|
||||
bool GetStrikethrough() const;
|
||||
wxString GetFaceName() const;
|
||||
wxFontFamily GetFamily() const;
|
||||
wxFontEncoding GetEncoding() const;
|
||||
|
||||
void SetPointSize(int pointsize);
|
||||
void SetPointSize(float pointsize);
|
||||
void SetPixelSize(const wxSize& pixelSize);
|
||||
void SetStyle(wxFontStyle style);
|
||||
void SetNumericWeight(int weight);
|
||||
void SetWeight(wxFontWeight weight);
|
||||
void SetUnderlined(bool underlined);
|
||||
void SetStrikethrough(bool strikethrough);
|
||||
|
@@ -64,9 +64,10 @@ public:
|
||||
virtual ~wxFont();
|
||||
|
||||
// implement base class pure virtuals
|
||||
virtual int GetPointSize() const wxOVERRIDE;
|
||||
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;
|
||||
virtual bool GetStrikethrough() const wxOVERRIDE;
|
||||
@@ -74,10 +75,11 @@ public:
|
||||
virtual const wxNativeFontInfo *GetNativeFontInfo() const wxOVERRIDE;
|
||||
virtual bool IsFixedWidth() const wxOVERRIDE;
|
||||
|
||||
virtual void SetPointSize( int pointSize ) wxOVERRIDE;
|
||||
virtual void SetPointSize(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;
|
||||
virtual void SetStrikethrough(bool strikethrough) wxOVERRIDE;
|
||||
|
@@ -85,22 +85,24 @@ public:
|
||||
virtual ~wxFont();
|
||||
|
||||
// implement base class pure virtuals
|
||||
virtual int GetPointSize() const wxOVERRIDE;
|
||||
virtual float GetFractionalPointSize() const wxOVERRIDE;
|
||||
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;
|
||||
virtual wxString GetFaceName() const wxOVERRIDE;
|
||||
virtual wxFontEncoding GetEncoding() const wxOVERRIDE;
|
||||
virtual const wxNativeFontInfo *GetNativeFontInfo() const wxOVERRIDE;
|
||||
|
||||
virtual void SetPointSize(int pointSize) wxOVERRIDE;
|
||||
virtual void SetPointSize(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;
|
||||
virtual void SetStrikethrough(bool strikethrough) wxOVERRIDE;
|
||||
|
@@ -79,12 +79,17 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
explicit wxCFDictionaryRef(CFDictionaryRef r)
|
||||
wxCFDictionaryRef(CFDictionaryRef r)
|
||||
: wxCFDictionaryRefCommon(r)
|
||||
{
|
||||
}
|
||||
|
||||
wxCFDictionaryRef& operator=(const wxCFMutableDictionaryRef& other);
|
||||
|
||||
CFDictionaryRef CreateCopy() const
|
||||
{
|
||||
return CFDictionaryCreateCopy(kCFAllocatorDefault, this->m_ptr);
|
||||
}
|
||||
};
|
||||
|
||||
class wxCFMutableDictionaryRef : public wxCFDictionaryRefCommon<CFMutableDictionaryRef>
|
||||
@@ -95,7 +100,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
explicit wxCFMutableDictionaryRef(CFMutableDictionaryRef r)
|
||||
wxCFMutableDictionaryRef(CFMutableDictionaryRef r)
|
||||
: wxCFDictionaryRefCommon(r)
|
||||
{
|
||||
}
|
||||
@@ -109,6 +114,11 @@ public:
|
||||
{
|
||||
SetValue(key, wxCFNumberRef(v));
|
||||
}
|
||||
|
||||
CFMutableDictionaryRef CreateCopy() const
|
||||
{
|
||||
return CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, this->m_ptr);
|
||||
}
|
||||
|
||||
friend class wxCFDictionaryRef;
|
||||
};
|
||||
|
@@ -51,6 +51,7 @@ public:
|
||||
}
|
||||
|
||||
wxFont( wxOSXSystemFont systemFont );
|
||||
wxFont(CTFontRef font);
|
||||
|
||||
#if wxOSX_USE_COCOA
|
||||
wxFont(WX_NSFont nsfont);
|
||||
@@ -67,6 +68,17 @@ 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,
|
||||
@@ -87,6 +99,14 @@ 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);
|
||||
@@ -99,26 +119,28 @@ public:
|
||||
virtual ~wxFont();
|
||||
|
||||
// implement base class pure virtuals
|
||||
virtual int GetPointSize() const;
|
||||
virtual wxSize GetPixelSize() const;
|
||||
virtual wxFontStyle GetStyle() const;
|
||||
virtual wxFontWeight GetWeight() const;
|
||||
virtual bool GetUnderlined() const;
|
||||
virtual bool GetStrikethrough() const;
|
||||
virtual wxString GetFaceName() const;
|
||||
virtual wxFontEncoding GetEncoding() const;
|
||||
virtual const wxNativeFontInfo *GetNativeFontInfo() const;
|
||||
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;
|
||||
virtual wxString GetFaceName() const wxOVERRIDE;
|
||||
virtual wxFontEncoding GetEncoding() const wxOVERRIDE;
|
||||
virtual const wxNativeFontInfo *GetNativeFontInfo() const wxOVERRIDE;
|
||||
|
||||
virtual bool IsFixedWidth() const;
|
||||
virtual bool IsFixedWidth() const wxOVERRIDE;
|
||||
|
||||
virtual void SetPointSize(int pointSize);
|
||||
virtual void SetFamily(wxFontFamily family);
|
||||
virtual void SetStyle(wxFontStyle style);
|
||||
virtual void SetWeight(wxFontWeight weight);
|
||||
virtual bool SetFaceName(const wxString& faceName);
|
||||
virtual void SetUnderlined(bool underlined);
|
||||
virtual void SetStrikethrough(bool strikethrough);
|
||||
virtual void SetEncoding(wxFontEncoding encoding);
|
||||
virtual void SetPointSize(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;
|
||||
virtual void SetStrikethrough(bool strikethrough) wxOVERRIDE;
|
||||
virtual void SetEncoding(wxFontEncoding encoding) wxOVERRIDE;
|
||||
|
||||
wxDECLARE_COMMON_FONT_METHODS();
|
||||
|
||||
@@ -148,7 +170,6 @@ public:
|
||||
|
||||
#if wxOSX_USE_COCOA
|
||||
WX_NSFont OSXGetNSFont() const;
|
||||
static void SetNativeInfoFromNSFont(WX_NSFont nsfont, wxNativeFontInfo* info);
|
||||
#endif
|
||||
|
||||
#if wxOSX_USE_IPHONE
|
||||
@@ -156,11 +177,11 @@ public:
|
||||
#endif
|
||||
|
||||
protected:
|
||||
virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info);
|
||||
virtual wxFontFamily DoGetFamily() const;
|
||||
virtual void DoSetNativeFontInfo(const wxNativeFontInfo& info) wxOVERRIDE;
|
||||
virtual wxFontFamily DoGetFamily() const wxOVERRIDE;
|
||||
|
||||
virtual wxGDIRefData *CreateGDIRefData() const;
|
||||
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const;
|
||||
virtual wxGDIRefData *CreateGDIRefData() const wxOVERRIDE;
|
||||
virtual wxGDIRefData *CloneGDIRefData(const wxGDIRefData *data) const wxOVERRIDE;
|
||||
|
||||
private:
|
||||
|
||||
|
Reference in New Issue
Block a user