From 3b7e6277be7c6dc21c62f3fa709bd0438df33175 Mon Sep 17 00:00:00 2001 From: Gilles Depeyrot Date: Sat, 20 Jan 2001 19:30:47 +0000 Subject: [PATCH] applied wxNativeFontInfo patch from Derry Bryson (with minor changes) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9134 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/mac/font.h | 11 +++++++++++ src/mac/carbon/font.cpp | 18 +++++++++++++++--- src/mac/carbon/fontenum.cpp | 1 + src/mac/font.cpp | 18 +++++++++++++++--- src/mac/fontenum.cpp | 1 + 5 files changed, 43 insertions(+), 6 deletions(-) diff --git a/include/wx/mac/font.h b/include/wx/mac/font.h index 6b41fc9c61..e65149037e 100644 --- a/include/wx/mac/font.h +++ b/include/wx/mac/font.h @@ -100,6 +100,15 @@ public: (void)Create(size, family, style, weight, underlined, face, encoding); } + wxFont(const wxNativeFontInfo& info) + { + Init(); + + (void)Create(info); + } + + wxFont(const wxString& fontDesc); + bool Create(int size, int family, int style, @@ -108,6 +117,8 @@ public: const wxString& face = wxEmptyString, wxFontEncoding encoding = wxFONTENCODING_DEFAULT); + bool Create(const wxNativeFontInfo& info); + virtual ~wxFont(); // assignment diff --git a/src/mac/carbon/font.cpp b/src/mac/carbon/font.cpp index 4f26c04f91..ecffc9fd94 100644 --- a/src/mac/carbon/font.cpp +++ b/src/mac/carbon/font.cpp @@ -18,13 +18,12 @@ #include "wx/font.h" #include "wx/gdicmn.h" +#include "wx/fontutil.h" + #if !USE_SHARED_LIBRARIES IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject) #endif - - - // ============================================================================ // implementation // ============================================================================ @@ -120,6 +119,13 @@ void wxFont::Init() wxTheFontList->Append(this); } +wxFont::wxFont(const wxString& fontdesc) +{ + wxNativeFontInfo info; + if ( info.FromString(fontdesc) ) + (void)Create(info); +} + bool wxFont::Create(int pointSize, int family, int style, @@ -137,6 +143,12 @@ bool wxFont::Create(int pointSize, return TRUE; } +bool wxFont::Create(const wxNativeFontInfo& info) +{ + return Create(info.pointSize, info.family, info.style, info.weight, + info.underlined, info.faceName, info.encoding); +} + wxFont::~wxFont() { if (wxTheFontList) diff --git a/src/mac/carbon/fontenum.cpp b/src/mac/carbon/fontenum.cpp index f296efd93c..99cd68441a 100644 --- a/src/mac/carbon/fontenum.cpp +++ b/src/mac/carbon/fontenum.cpp @@ -34,6 +34,7 @@ #include "wx/fontenum.h" #include "wx/fontmap.h" +#include "wx/fontutil.h" // ---------------------------------------------------------------------------- // private classes diff --git a/src/mac/font.cpp b/src/mac/font.cpp index 4f26c04f91..ecffc9fd94 100644 --- a/src/mac/font.cpp +++ b/src/mac/font.cpp @@ -18,13 +18,12 @@ #include "wx/font.h" #include "wx/gdicmn.h" +#include "wx/fontutil.h" + #if !USE_SHARED_LIBRARIES IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject) #endif - - - // ============================================================================ // implementation // ============================================================================ @@ -120,6 +119,13 @@ void wxFont::Init() wxTheFontList->Append(this); } +wxFont::wxFont(const wxString& fontdesc) +{ + wxNativeFontInfo info; + if ( info.FromString(fontdesc) ) + (void)Create(info); +} + bool wxFont::Create(int pointSize, int family, int style, @@ -137,6 +143,12 @@ bool wxFont::Create(int pointSize, return TRUE; } +bool wxFont::Create(const wxNativeFontInfo& info) +{ + return Create(info.pointSize, info.family, info.style, info.weight, + info.underlined, info.faceName, info.encoding); +} + wxFont::~wxFont() { if (wxTheFontList) diff --git a/src/mac/fontenum.cpp b/src/mac/fontenum.cpp index f296efd93c..99cd68441a 100644 --- a/src/mac/fontenum.cpp +++ b/src/mac/fontenum.cpp @@ -34,6 +34,7 @@ #include "wx/fontenum.h" #include "wx/fontmap.h" +#include "wx/fontutil.h" // ---------------------------------------------------------------------------- // private classes -- 2.45.2