better native font support for wxGTK
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13642 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -36,7 +36,10 @@ class WXDLLEXPORT wxFont;
|
||||
// font constants
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// standard font families
|
||||
// standard font families: these may be used only for the font creation, it
|
||||
// doesn't make sense to query an existing font for its font family as,
|
||||
// especially if the font had been created from a native font description, it
|
||||
// may be unknown
|
||||
enum wxFontFamily
|
||||
{
|
||||
wxFONTFAMILY_DEFAULT = wxDEFAULT,
|
||||
@@ -46,7 +49,8 @@ enum wxFontFamily
|
||||
wxFONTFAMILY_SWISS = wxSWISS,
|
||||
wxFONTFAMILY_MODERN = wxMODERN,
|
||||
wxFONTFAMILY_TELETYPE = wxTELETYPE,
|
||||
wxFONTFAMILY_MAX
|
||||
wxFONTFAMILY_MAX,
|
||||
wxFONTFAMILY_UNKNOWN = wxFONTFAMILY_MAX
|
||||
};
|
||||
|
||||
// font styles
|
||||
|
@@ -34,6 +34,9 @@
|
||||
#if defined(_WX_X_FONTLIKE)
|
||||
|
||||
// the symbolic names for the XLFD fields (with examples for their value)
|
||||
//
|
||||
// NB: we suppose that the font always starts with the empty token (font name
|
||||
// registry field) as we never use nor generate it anyhow
|
||||
enum wxXLFDField
|
||||
{
|
||||
wxXLFD_FOUNDRY, // adobe
|
||||
@@ -70,24 +73,39 @@ enum wxXLFDField
|
||||
struct WXDLLEXPORT wxNativeFontInfo
|
||||
{
|
||||
#if defined(_WX_X_FONTLIKE)
|
||||
// the fonts array can't be accessed directly as we only parse the
|
||||
// xFontName when needed
|
||||
// the members can't be accessed directly as we only parse the
|
||||
// xFontName on demand
|
||||
private:
|
||||
// the components of the XLFD
|
||||
wxString fontElements[wxXLFD_MAX];
|
||||
|
||||
public:
|
||||
// the full XLFD
|
||||
wxString xFontName;
|
||||
|
||||
// true until SetXFontName() is called
|
||||
bool m_isDefault;
|
||||
|
||||
// return true if we have already initialized fontElements
|
||||
inline bool HasElements() const;
|
||||
|
||||
public:
|
||||
// init the elements from an XLFD, return TRUE if ok
|
||||
bool FromXFontName(const wxString& xFontName);
|
||||
|
||||
// generate an XLFD using the fontElements
|
||||
// return false if we were never initialized with a valid XLFD
|
||||
bool IsDefault() const { return m_isDefault; }
|
||||
|
||||
// return the XLFD (using the fontElements if necessary)
|
||||
wxString GetXFontName() const;
|
||||
|
||||
// get the given XFLD component
|
||||
wxString GetXFontComponent(wxXLFDField field) const;
|
||||
|
||||
// change the font component
|
||||
void SetXFontComponent(wxXLFDField field, const wxString& value);
|
||||
|
||||
// set the XFLD
|
||||
void SetXFontName(const wxString& xFontName);
|
||||
#elif defined(__WXMSW__)
|
||||
LOGFONT lf;
|
||||
#elif defined(__WXPM__)
|
||||
|
@@ -36,12 +36,13 @@ public:
|
||||
// ctors and such
|
||||
wxFont() { Init(); }
|
||||
wxFont(const wxFont& font) : wxFontBase() { Init(); Ref(font); }
|
||||
wxFont(const wxString& fontname,
|
||||
wxFontEncoding fontenc = wxFONTENCODING_DEFAULT)
|
||||
|
||||
// wxGTK-specific
|
||||
wxFont(const wxString& fontname)
|
||||
{
|
||||
Init();
|
||||
|
||||
Create(fontname, fontenc);
|
||||
Create(fontname);
|
||||
}
|
||||
|
||||
wxFont(const wxNativeFontInfo& info);
|
||||
@@ -68,9 +69,7 @@ public:
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
||||
|
||||
// wxGTK-specific
|
||||
bool Create(const wxString& fontname,
|
||||
wxFontEncoding fontenc = wxFONTENCODING_DEFAULT);
|
||||
bool Create(const wxNativeFontInfo& fontinfo);
|
||||
bool Create(const wxString& fontname);
|
||||
|
||||
~wxFont();
|
||||
|
||||
@@ -108,9 +107,6 @@ protected:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
// do we have the XFLD for this font (or just wxWin description)?
|
||||
inline bool HasNativeFont() const;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxFont)
|
||||
};
|
||||
|
@@ -36,12 +36,13 @@ public:
|
||||
// ctors and such
|
||||
wxFont() { Init(); }
|
||||
wxFont(const wxFont& font) : wxFontBase() { Init(); Ref(font); }
|
||||
wxFont(const wxString& fontname,
|
||||
wxFontEncoding fontenc = wxFONTENCODING_DEFAULT)
|
||||
|
||||
// wxGTK-specific
|
||||
wxFont(const wxString& fontname)
|
||||
{
|
||||
Init();
|
||||
|
||||
Create(fontname, fontenc);
|
||||
Create(fontname);
|
||||
}
|
||||
|
||||
wxFont(const wxNativeFontInfo& info);
|
||||
@@ -68,9 +69,7 @@ public:
|
||||
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
|
||||
|
||||
// wxGTK-specific
|
||||
bool Create(const wxString& fontname,
|
||||
wxFontEncoding fontenc = wxFONTENCODING_DEFAULT);
|
||||
bool Create(const wxNativeFontInfo& fontinfo);
|
||||
bool Create(const wxString& fontname);
|
||||
|
||||
~wxFont();
|
||||
|
||||
@@ -108,9 +107,6 @@ protected:
|
||||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
// do we have the XFLD for this font (or just wxWin description)?
|
||||
inline bool HasNativeFont() const;
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxFont)
|
||||
};
|
||||
|
@@ -31,4 +31,7 @@ wxLoadQueryNearestFont(int pointSize,
|
||||
wxFontEncoding encoding,
|
||||
wxString* xFontName = (wxString *)NULL);
|
||||
|
||||
// returns the font specified by the given XLFD
|
||||
extern inline wxNativeFont wxLoadFont(const wxString& fontSpec);
|
||||
|
||||
#endif // _WX_UNIX_FONTUTIL_H_
|
||||
|
Reference in New Issue
Block a user