X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/12028905135250524409f1e7b9bfa9c55e5ce16b..f194560ed883138350643eb556f766814c409afc:/include/wx/fontutil.h?ds=sidebyside

diff --git a/include/wx/fontutil.h b/include/wx/fontutil.h
index 5e9e14c09b..5ff0cded08 100644
--- a/include/wx/fontutil.h
+++ b/include/wx/fontutil.h
@@ -31,6 +31,8 @@
     #include "wx/msw/winundef.h"
 #endif
 
+struct WXDLLEXPORT wxNativeEncodingInfo;
+
 #if defined(_WX_X_FONTLIKE)
 
 // the symbolic names for the XLFD fields (with examples for their value)
@@ -137,6 +139,28 @@ public:
     // reset to the default state
     void Init();
 
+    // init with the parameters of the given font
+    void InitFromFont(const wxFont& font)
+    {
+        // translate all font parameters
+        SetStyle((wxFontStyle)font.GetStyle());
+        SetWeight((wxFontWeight)font.GetWeight());
+        SetUnderlined(font.GetUnderlined());
+        SetPointSize(font.GetPointSize());
+
+        // set the family/facename
+        SetFamily((wxFontFamily)font.GetFamily());
+        const wxString& facename = font.GetFaceName();
+        if ( !facename.empty() )
+        {
+            SetFaceName(facename);
+        }
+
+        // deal with encoding now (it may override the font family and facename
+        // so do it after setting them)
+        SetEncoding(font.GetEncoding());
+    }
+
     // accessors and modifiers for the font elements
     int GetPointSize() const;
     wxFontStyle GetStyle() const;