From c94f845b1602d44ccd7c7542afffde666adbb2f0 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Wed, 25 Apr 2007 01:49:47 +0000
Subject: [PATCH] changed wxDC::GetTextExtent() and related methods to take
 const wxFont pointer, for consistency with wxWindow::GetTextExtent() and
 because it generally doesn't need a non-const font

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45638 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/latex/wx/dc.tex          | 2 +-
 include/wx/cocoa/dc.h         | 2 +-
 include/wx/dc.h               | 8 ++++----
 include/wx/dcgraph.h          | 2 +-
 include/wx/dcmirror.h         | 2 +-
 include/wx/dcsvg.h            | 2 +-
 include/wx/dfb/dc.h           | 2 +-
 include/wx/generic/dcpsg.h    | 2 +-
 include/wx/gtk/dcclient.h     | 2 +-
 include/wx/gtk/gnome/gprint.h | 6 +++---
 include/wx/gtk1/dcclient.h    | 2 +-
 include/wx/mac/carbon/dc.h    | 2 +-
 include/wx/mgl/dc.h           | 2 +-
 include/wx/motif/dcclient.h   | 2 +-
 include/wx/msw/dc.h           | 2 +-
 include/wx/msw/metafile.h     | 2 +-
 include/wx/os2/metafile.h     | 2 +-
 include/wx/palmos/dc.h        | 2 +-
 include/wx/palmos/metafile.h  | 2 +-
 include/wx/x11/dcclient.h     | 2 +-
 src/cocoa/dc.mm               | 2 +-
 src/common/dcbase.cpp         | 2 +-
 src/common/dcgraph.cpp        | 2 +-
 src/common/dcsvg.cpp          | 2 +-
 src/dfb/dc.cpp                | 2 +-
 src/generic/dcpsg.cpp         | 6 +++---
 src/gtk/dcclient.cpp          | 2 +-
 src/gtk/gnome/gprint.cpp      | 2 +-
 src/gtk1/dcclient.cpp         | 2 +-
 src/mac/carbon/dc.cpp         | 2 +-
 src/mac/carbon/dccg.cpp       | 2 +-
 src/mgl/dc.cpp                | 2 +-
 src/motif/dcclient.cpp        | 2 +-
 src/msw/dc.cpp                | 2 +-
 src/msw/metafile.cpp          | 8 +++++---
 src/os2/metafile.cpp          | 6 +++---
 src/palmos/dc.cpp             | 2 +-
 src/palmos/metafile.cpp       | 3 ++-
 src/x11/dcclient.cpp          | 2 +-
 39 files changed, 53 insertions(+), 50 deletions(-)

diff --git a/docs/latex/wx/dc.tex b/docs/latex/wx/dc.tex
index cffeac284a..c8d929e22a 100644
--- a/docs/latex/wx/dc.tex
+++ b/docs/latex/wx/dc.tex
@@ -793,7 +793,7 @@ Gets the current text background colour (see \helpref{wxDC::SetTextBackground}{w
 \membersection{wxDC::GetTextExtent}\label{wxdcgettextextent}
 
 \constfunc{void}{GetTextExtent}{\param{const wxString\& }{string}, \param{wxCoord *}{w}, \param{wxCoord *}{h},\\
-  \param{wxCoord *}{descent = NULL}, \param{wxCoord *}{externalLeading = NULL}, \param{wxFont *}{font = NULL}}
+  \param{wxCoord *}{descent = NULL}, \param{wxCoord *}{externalLeading = NULL}, \param{const wxFont *}{font = NULL}}
 
 \constfunc{wxSize}{GetTextExtent}{\param{const wxString\& }{string}}
 
diff --git a/include/wx/cocoa/dc.h b/include/wx/cocoa/dc.h
index d04424ba90..db5175bcbf 100644
--- a/include/wx/cocoa/dc.h
+++ b/include/wx/cocoa/dc.h
@@ -98,7 +98,7 @@ public:
                                  wxCoord *x, wxCoord *y,
                                  wxCoord *descent = NULL,
                                  wxCoord *externalLeading = NULL,
-                                 wxFont *theFont = NULL) const;
+                                 const wxFont *theFont = NULL) const;
 
     virtual bool CanDrawBitmap() const;
     virtual bool CanGetTextExtent() const;
diff --git a/include/wx/dc.h b/include/wx/dc.h
index a846442f68..7551b99905 100644
--- a/include/wx/dc.h
+++ b/include/wx/dc.h
@@ -457,7 +457,7 @@ public:
                        wxCoord *x, wxCoord *y,
                        wxCoord *descent = NULL,
                        wxCoord *externalLeading = NULL,
-                       wxFont *theFont = NULL) const
+                       const wxFont *theFont = NULL) const
         { DoGetTextExtent(string, x, y, descent, externalLeading, theFont); }
 
     wxSize GetTextExtent(const wxString& string) const
@@ -472,7 +472,7 @@ public:
                                         wxCoord *width,
                                         wxCoord *height,
                                         wxCoord *heightLine = NULL,
-                                        wxFont *font = NULL) const;
+                                        const wxFont *font = NULL) const;
 
     wxSize GetMultiLineTextExtent(const wxString& string) const
     {
@@ -640,7 +640,7 @@ public:
                        long *x, long *y,
                        long *descent = NULL,
                        long *externalLeading = NULL,
-                       wxFont *theFont = NULL) const
+                       const wxFont *theFont = NULL) const
     {
         wxCoord x2, y2, descent2, externalLeading2;
         DoGetTextExtent(string, &x2, &y2,
@@ -807,7 +807,7 @@ protected:
                                  wxCoord *x, wxCoord *y,
                                  wxCoord *descent = NULL,
                                  wxCoord *externalLeading = NULL,
-                                 wxFont *theFont = NULL) const = 0;
+                                 const wxFont *theFont = NULL) const = 0;
 
     virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
 
diff --git a/include/wx/dcgraph.h b/include/wx/dcgraph.h
index 35fd3f9b14..331331afbe 100755
--- a/include/wx/dcgraph.h
+++ b/include/wx/dcgraph.h
@@ -173,7 +173,7 @@ protected:
         wxCoord *x, wxCoord *y,
         wxCoord *descent = NULL,
         wxCoord *externalLeading = NULL,
-        wxFont *theFont = NULL) const;
+        const wxFont *theFont = NULL) const;
 
     virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
 
diff --git a/include/wx/dcmirror.h b/include/wx/dcmirror.h
index 0bcc54fc59..0a7d430120 100644
--- a/include/wx/dcmirror.h
+++ b/include/wx/dcmirror.h
@@ -269,7 +269,7 @@ protected:
                                  wxCoord *x, wxCoord *y,
                                  wxCoord *descent = NULL,
                                  wxCoord *externalLeading = NULL,
-                                 wxFont *theFont = NULL) const
+                                 const wxFont *theFont = NULL) const
     {
         // never mirrored
         m_dc.DoGetTextExtent(string, x, y, descent, externalLeading, theFont);
diff --git a/include/wx/dcsvg.h b/include/wx/dcsvg.h
index 41a25b8082..db556ab5ae 100644
--- a/include/wx/dcsvg.h
+++ b/include/wx/dcsvg.h
@@ -86,7 +86,7 @@ class WXDLLIMPEXP_CORE wxSVGFileDC : public wxDC
 
         void DoGetSize(int * x, int *y) const { *x = m_width; *y = m_height ; return ; }
 
-        void DoGetTextExtent(const wxString& string, wxCoord *w, wxCoord *h, wxCoord *descent = NULL, wxCoord *externalLeading = NULL, wxFont *font = NULL) const ;
+        void DoGetTextExtent(const wxString& string, wxCoord *w, wxCoord *h, wxCoord *descent = NULL, wxCoord *externalLeading = NULL, const wxFont *font = NULL) const ;
 
         void DoSetClippingRegionAsRegion(const class wxRegion &)
             { wxASSERT_MSG (false, wxT("wxSVGFILEDC::DoSetClippingRegionAsRegion Call not yet implemented")); return  ; }
diff --git a/include/wx/dfb/dc.h b/include/wx/dfb/dc.h
index 7adfd288bb..d78dc83262 100644
--- a/include/wx/dfb/dc.h
+++ b/include/wx/dfb/dc.h
@@ -58,7 +58,7 @@ public:
                                  wxCoord *x, wxCoord *y,
                                  wxCoord *descent = NULL,
                                  wxCoord *externalLeading = NULL,
-                                 wxFont *theFont = NULL) const;
+                                 const wxFont *theFont = NULL) const;
 
     virtual bool CanDrawBitmap() const { return true; }
     virtual bool CanGetTextExtent() const { return true; }
diff --git a/include/wx/generic/dcpsg.h b/include/wx/generic/dcpsg.h
index e303d406c4..1958c18278 100644
--- a/include/wx/generic/dcpsg.h
+++ b/include/wx/generic/dcpsg.h
@@ -124,7 +124,7 @@ protected:
     void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
                          wxCoord *descent = NULL,
                          wxCoord *externalLeading = NULL,
-                         wxFont *theFont = NULL) const;
+                         const wxFont *theFont = NULL) const;
     void DoGetSize(int* width, int* height) const;
     void DoGetSizeMM(int *width, int *height) const;
 
diff --git a/include/wx/gtk/dcclient.h b/include/wx/gtk/dcclient.h
index de91b5c126..3873241c17 100644
--- a/include/wx/gtk/dcclient.h
+++ b/include/wx/gtk/dcclient.h
@@ -68,7 +68,7 @@ protected:
                                 wxCoord *width, wxCoord *height,
                                 wxCoord *descent = (wxCoord *) NULL,
                                 wxCoord *externalLeading = (wxCoord *) NULL,
-                                wxFont *theFont = (wxFont *) NULL) const;
+                                const wxFont *theFont = (wxFont *) NULL) const;
     virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
     virtual void DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height );
     virtual void DoSetClippingRegionAsRegion( const wxRegion &region );
diff --git a/include/wx/gtk/gnome/gprint.h b/include/wx/gtk/gnome/gprint.h
index 60b1c7bea5..0b7b36a313 100644
--- a/include/wx/gtk/gnome/gprint.h
+++ b/include/wx/gtk/gnome/gprint.h
@@ -258,7 +258,7 @@ protected:
     void DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
                      wxCoord *descent = (wxCoord *) NULL,
                      wxCoord *externalLeading = (wxCoord *) NULL,
-                     wxFont *theFont = (wxFont *) NULL ) const;
+                     const wxFont *theFont = (wxFont *) NULL ) const;
     void DoGetSize(int* width, int* height) const;
     void DoGetSizeMM(int *width, int *height) const;
 
@@ -277,7 +277,7 @@ private:
     unsigned char           m_currentRed;
     unsigned char           m_currentGreen;
     unsigned char           m_currentBlue;
-    
+
     int                     m_deviceOffsetY;
 
     wxGnomePrinter         *m_printer;
@@ -285,7 +285,7 @@ private:
     GnomePrintJob*          m_job; // only used and destroyed when created with wxPrintData
 
     void makeEllipticalPath(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
-    
+
 private:
     wxCoord XDEV2LOG(wxCoord x) const
     {
diff --git a/include/wx/gtk1/dcclient.h b/include/wx/gtk1/dcclient.h
index c1654ba42a..6e001e5c78 100644
--- a/include/wx/gtk1/dcclient.h
+++ b/include/wx/gtk1/dcclient.h
@@ -74,7 +74,7 @@ protected:
                                 wxCoord *width, wxCoord *height,
                                 wxCoord *descent = (wxCoord *) NULL,
                                 wxCoord *externalLeading = (wxCoord *) NULL,
-                                wxFont *theFont = (wxFont *) NULL) const;
+                                const wxFont *theFont = (wxFont *) NULL) const;
 
 public:
     virtual wxCoord GetCharWidth() const;
diff --git a/include/wx/mac/carbon/dc.h b/include/wx/mac/carbon/dc.h
index b0e83d67d2..b7945f9575 100644
--- a/include/wx/mac/carbon/dc.h
+++ b/include/wx/mac/carbon/dc.h
@@ -211,7 +211,7 @@ protected:
         wxCoord *x, wxCoord *y,
         wxCoord *descent = NULL,
         wxCoord *externalLeading = NULL,
-        wxFont *theFont = NULL) const;
+        const wxFont *theFont = NULL) const;
 
     virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
 
diff --git a/include/wx/mgl/dc.h b/include/wx/mgl/dc.h
index eafae45054..94bd65c9f6 100644
--- a/include/wx/mgl/dc.h
+++ b/include/wx/mgl/dc.h
@@ -79,7 +79,7 @@ public:
                                  wxCoord *x, wxCoord *y,
                                  wxCoord *descent = NULL,
                                  wxCoord *externalLeading = NULL,
-                                 wxFont *theFont = NULL) const;
+                                 const wxFont *theFont = NULL) const;
 
     virtual bool CanDrawBitmap() const;
     virtual bool CanGetTextExtent() const;
diff --git a/include/wx/motif/dcclient.h b/include/wx/motif/dcclient.h
index dccf727b89..54bffa81ff 100644
--- a/include/wx/motif/dcclient.h
+++ b/include/wx/motif/dcclient.h
@@ -63,7 +63,7 @@ public:
         wxCoord *x, wxCoord *y,
         wxCoord *descent = NULL,
         wxCoord *externalLeading = NULL,
-        wxFont *theFont = NULL) const;
+        const wxFont *theFont = NULL) const;
 
     virtual bool CanDrawBitmap() const;
     virtual bool CanGetTextExtent() const;
diff --git a/include/wx/msw/dc.h b/include/wx/msw/dc.h
index 9e6f7fcab8..ee1ab8d4ec 100644
--- a/include/wx/msw/dc.h
+++ b/include/wx/msw/dc.h
@@ -166,7 +166,7 @@ protected:
                                  wxCoord *x, wxCoord *y,
                                  wxCoord *descent = NULL,
                                  wxCoord *externalLeading = NULL,
-                                 wxFont *theFont = NULL) const;
+                                 const wxFont *theFont = NULL) const;
     virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
 
     virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
diff --git a/include/wx/msw/metafile.h b/include/wx/msw/metafile.h
index 3fb6377b42..de7eda4124 100644
--- a/include/wx/msw/metafile.h
+++ b/include/wx/msw/metafile.h
@@ -90,7 +90,7 @@ public:
     virtual void SetMapMode(int mode);
     virtual void GetTextExtent(const wxString& string, long *x, long *y,
             long *descent = NULL, long *externalLeading = NULL,
-            wxFont *theFont = NULL, bool use16bit = false) const;
+            const wxFont *theFont = NULL, bool use16bit = false) const;
 
     // Implementation
     wxMetafile *GetMetaFile() const { return m_metaFile; }
diff --git a/include/wx/os2/metafile.h b/include/wx/os2/metafile.h
index 66f2899ddf..d75be165e5 100644
--- a/include/wx/os2/metafile.h
+++ b/include/wx/os2/metafile.h
@@ -88,7 +88,7 @@ public:
     virtual void SetMapMode(int mode);
     virtual void GetTextExtent(const wxString& string, long *x, long *y,
                                long *descent = NULL, long *externalLeading = NULL,
-                               wxFont *theFont = NULL, bool use16bit = false) const;
+                               const wxFont *theFont = NULL, bool use16bit = false) const;
 
     // Implementation
     inline wxMetafile *GetMetaFile(void) const { return m_metaFile; }
diff --git a/include/wx/palmos/dc.h b/include/wx/palmos/dc.h
index ce2fc9a905..cd85d57973 100644
--- a/include/wx/palmos/dc.h
+++ b/include/wx/palmos/dc.h
@@ -75,7 +75,7 @@ public:
                                  wxCoord *x, wxCoord *y,
                                  wxCoord *descent = NULL,
                                  wxCoord *externalLeading = NULL,
-                                 wxFont *theFont = NULL) const;
+                                 const wxFont *theFont = NULL) const;
     virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const;
 
     virtual bool CanDrawBitmap() const;
diff --git a/include/wx/palmos/metafile.h b/include/wx/palmos/metafile.h
index 71a94deb7a..0ca14ac864 100644
--- a/include/wx/palmos/metafile.h
+++ b/include/wx/palmos/metafile.h
@@ -90,7 +90,7 @@ public:
     virtual void SetMapMode(int mode);
     virtual void GetTextExtent(const wxString& string, long *x, long *y,
             long *descent = NULL, long *externalLeading = NULL,
-            wxFont *theFont = NULL, bool use16bit = FALSE) const;
+            const wxFont *theFont = NULL, bool use16bit = FALSE) const;
 
     // Implementation
     wxMetafile *GetMetaFile() const { return m_metaFile; }
diff --git a/include/wx/x11/dcclient.h b/include/wx/x11/dcclient.h
index 0d9ffbcb6b..6ae4962b32 100644
--- a/include/wx/x11/dcclient.h
+++ b/include/wx/x11/dcclient.h
@@ -116,7 +116,7 @@ protected:
         wxCoord *x, wxCoord *y,
         wxCoord *descent = NULL,
         wxCoord *externalLeading = NULL,
-        wxFont *theFont = NULL) const;
+        const wxFont *theFont = NULL) const;
 
     void Init();
 
diff --git a/src/cocoa/dc.mm b/src/cocoa/dc.mm
index 7541eaf8c3..53581c4f74 100644
--- a/src/cocoa/dc.mm
+++ b/src/cocoa/dc.mm
@@ -230,7 +230,7 @@ void wxDC::DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
     [bezpath stroke];
 }
 
-void wxDC::DoGetTextExtent(const wxString& text, wxCoord *x, wxCoord *y, wxCoord *descent, wxCoord *externalLeading, wxFont *theFont) const
+void wxDC::DoGetTextExtent(const wxString& text, wxCoord *x, wxCoord *y, wxCoord *descent, wxCoord *externalLeading, const wxFont *theFont) const
 {
     wxAutoNSAutoreleasePool pool;
 // FIXME: Cache this so it can be used for DoDrawText
diff --git a/src/common/dcbase.cpp b/src/common/dcbase.cpp
index b17d055a63..8f08d60562 100644
--- a/src/common/dcbase.cpp
+++ b/src/common/dcbase.cpp
@@ -507,7 +507,7 @@ void wxDCBase::GetMultiLineTextExtent(const wxString& text,
                                       wxCoord *x,
                                       wxCoord *y,
                                       wxCoord *h,
-                                      wxFont *font) const
+                                      const wxFont *font) const
 {
     wxCoord widthTextMax = 0, widthLine,
             heightTextTotal = 0, heightLineDefault = 0, heightLine = 0;
diff --git a/src/common/dcgraph.cpp b/src/common/dcgraph.cpp
index 93ee03514d..420e9039bb 100644
--- a/src/common/dcgraph.cpp
+++ b/src/common/dcgraph.cpp
@@ -830,7 +830,7 @@ bool wxGCDC::CanGetTextExtent() const
 
 void wxGCDC::DoGetTextExtent( const wxString &str, wxCoord *width, wxCoord *height,
                               wxCoord *descent, wxCoord *externalLeading ,
-                              wxFont *theFont ) const
+                              const wxFont *theFont ) const
 {
     wxCHECK_RET( Ok(), wxT("wxGCDC(cg)::DoGetTextExtent - invalid DC") );
 
diff --git a/src/common/dcsvg.cpp b/src/common/dcsvg.cpp
index 5b1bdcbb69..79e0e48297 100644
--- a/src/common/dcsvg.cpp
+++ b/src/common/dcsvg.cpp
@@ -458,7 +458,7 @@ void wxSVGFileDC::DoDrawEllipticArc(wxCoord x,wxCoord y,wxCoord w,wxCoord h,doub
 }
 
 
-void wxSVGFileDC::DoGetTextExtent(const wxString& string, wxCoord *w, wxCoord *h, wxCoord *descent , wxCoord *externalLeading , wxFont *font) const
+void wxSVGFileDC::DoGetTextExtent(const wxString& string, wxCoord *w, wxCoord *h, wxCoord *descent , wxCoord *externalLeading , const wxFont *font) const
 
 {
     wxScreenDC sDC ;
diff --git a/src/dfb/dc.cpp b/src/dfb/dc.cpp
index 8093bec3d2..3415cc1806 100644
--- a/src/dfb/dc.cpp
+++ b/src/dfb/dc.cpp
@@ -480,7 +480,7 @@ wxCoord wxDC::GetCharWidth() const
 
 void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
                            wxCoord *descent, wxCoord *externalLeading,
-                           wxFont *theFont) const
+                           const wxFont *theFont) const
 {
     wxCHECK_RET( Ok(), wxT("invalid dc") );
     wxCHECK_RET( m_font.Ok(), wxT("no font selected") );
diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp
index e676e49896..9aeca2e1c4 100644
--- a/src/generic/dcpsg.cpp
+++ b/src/generic/dcpsg.cpp
@@ -1835,11 +1835,11 @@ wxCoord wxPostScriptDC::GetCharHeight() const
 void wxPostScriptDC::DoGetTextExtent(const wxString& string,
                                      wxCoord *x, wxCoord *y,
                                      wxCoord *descent, wxCoord *externalLeading,
-                                     wxFont *theFont ) const
+                                     const wxFont *theFont ) const
 {
-    wxFont *fontToUse = theFont;
+    const wxFont *fontToUse = theFont;
 
-    if (!fontToUse) fontToUse = (wxFont*) &m_font;
+    if (!fontToUse) fontToUse = &m_font;
 
     wxCHECK_RET( fontToUse, wxT("GetTextExtent: no font defined") );
 
diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp
index 52a36301f1..3ffd2a1776 100644
--- a/src/gtk/dcclient.cpp
+++ b/src/gtk/dcclient.cpp
@@ -1719,7 +1719,7 @@ void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y,
 void wxWindowDC::DoGetTextExtent(const wxString &string,
                                  wxCoord *width, wxCoord *height,
                                  wxCoord *descent, wxCoord *externalLeading,
-                                 wxFont *theFont) const
+                                 const wxFont *theFont) const
 {
     if ( width )
         *width = 0;
diff --git a/src/gtk/gnome/gprint.cpp b/src/gtk/gnome/gprint.cpp
index 672823aac5..6c947a9664 100644
--- a/src/gtk/gnome/gprint.cpp
+++ b/src/gtk/gnome/gprint.cpp
@@ -1718,7 +1718,7 @@ wxCoord wxGnomePrintDC::GetCharWidth() const
 void wxGnomePrintDC::DoGetTextExtent(const wxString& string, wxCoord *width, wxCoord *height,
                      wxCoord *descent,
                      wxCoord *externalLeading,
-                     wxFont *theFont ) const
+                     const wxFont *theFont ) const
 {
     if ( width )
         *width = 0;
diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp
index 329d62d9eb..c344069423 100644
--- a/src/gtk1/dcclient.cpp
+++ b/src/gtk1/dcclient.cpp
@@ -1606,7 +1606,7 @@ void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y,
 void wxWindowDC::DoGetTextExtent(const wxString &string,
                                  wxCoord *width, wxCoord *height,
                                  wxCoord *descent, wxCoord *externalLeading,
-                                 wxFont *theFont) const
+                                 const wxFont *theFont) const
 {
     if ( width )
         *width = 0;
diff --git a/src/mac/carbon/dc.cpp b/src/mac/carbon/dc.cpp
index fbd3f8f89a..761ab396fd 100644
--- a/src/mac/carbon/dc.cpp
+++ b/src/mac/carbon/dc.cpp
@@ -1601,7 +1601,7 @@ bool wxDC::CanGetTextExtent() const
 
 void wxDC::DoGetTextExtent( const wxString &str, wxCoord *width, wxCoord *height,
                             wxCoord *descent, wxCoord *externalLeading ,
-                            wxFont *theFont ) const
+                            const wxFont *theFont ) const
 {
     wxCHECK_RET(Ok(), wxT("wxDC::DoGetTextExtent - invalid DC"));
 
diff --git a/src/mac/carbon/dccg.cpp b/src/mac/carbon/dccg.cpp
index abd909dede..353e7c10f8 100755
--- a/src/mac/carbon/dccg.cpp
+++ b/src/mac/carbon/dccg.cpp
@@ -2139,7 +2139,7 @@ bool wxDC::CanGetTextExtent() const
 
 void wxDC::DoGetTextExtent( const wxString &str, wxCoord *width, wxCoord *height,
                             wxCoord *descent, wxCoord *externalLeading ,
-                            wxFont *theFont ) const
+                            const wxFont *theFont ) const
 {
     wxCHECK_RET( Ok(), wxT("wxDC(cg)::DoGetTextExtent - invalid DC") );
 
diff --git a/src/mgl/dc.cpp b/src/mgl/dc.cpp
index 8eabf06310..08c78c6a1d 100644
--- a/src/mgl/dc.cpp
+++ b/src/mgl/dc.cpp
@@ -1221,7 +1221,7 @@ wxCoord wxDC::GetCharWidth() const
 
 void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
                            wxCoord *descent, wxCoord *externalLeading,
-                           wxFont *theFont) const
+                           const wxFont *theFont) const
 {
     wxFont oldFont;
 
diff --git a/src/motif/dcclient.cpp b/src/motif/dcclient.cpp
index 56ad7af018..fa5f8beb89 100644
--- a/src/motif/dcclient.cpp
+++ b/src/motif/dcclient.cpp
@@ -1297,7 +1297,7 @@ bool wxWindowDC::CanGetTextExtent() const
 
 void wxWindowDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *height,
                                 wxCoord *descent, wxCoord *externalLeading,
-                                wxFont *font ) const
+                                const wxFont *font ) const
 {
     wxCHECK_RET( Ok(), "invalid dc" );
 
diff --git a/src/msw/dc.cpp b/src/msw/dc.cpp
index 3828683e73..3605e4a5b1 100644
--- a/src/msw/dc.cpp
+++ b/src/msw/dc.cpp
@@ -1731,7 +1731,7 @@ wxCoord wxDC::GetCharWidth() const
 
 void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
                            wxCoord *descent, wxCoord *externalLeading,
-                           wxFont *font) const
+                           const wxFont *font) const
 {
 #ifdef __WXMICROWIN__
     if (!GetHDC())
diff --git a/src/msw/metafile.cpp b/src/msw/metafile.cpp
index f1eb74391e..5b3e574c4d 100644
--- a/src/msw/metafile.cpp
+++ b/src/msw/metafile.cpp
@@ -210,11 +210,13 @@ wxMetafileDC::~wxMetafileDC()
 }
 
 void wxMetafileDC::GetTextExtent(const wxString& string, long *x, long *y,
-                                 long *descent, long *externalLeading, wxFont *theFont, bool WXUNUSED(use16bit)) const
+                                 long *descent, long *externalLeading,
+                                 const wxFont *theFont,
+                                 bool WXUNUSED(use16bit)) const
 {
-    wxFont *fontToUse = theFont;
+    const wxFont *fontToUse = theFont;
     if (!fontToUse)
-        fontToUse = (wxFont*) &m_font;
+        fontToUse = &m_font;
 
     HDC dc = GetDC(NULL);
 
diff --git a/src/os2/metafile.cpp b/src/os2/metafile.cpp
index 020041396f..82709b4ccb 100644
--- a/src/os2/metafile.cpp
+++ b/src/os2/metafile.cpp
@@ -188,12 +188,12 @@ void wxMetafileDC::GetTextExtent(const wxString& WXUNUSED(string),
                                  long *WXUNUSED(y),
                                  long *WXUNUSED(descent),
                                  long *WXUNUSED(externalLeading),
-                                 wxFont *theFont,
+                                 const wxFont *theFont,
                                  bool WXUNUSED(use16bit) ) const
 {
-    wxFont *fontToUse = theFont;
+    const wxFont *fontToUse = theFont;
     if (!fontToUse)
-        fontToUse = (wxFont*) &m_font;
+        fontToUse = &m_font;
 
     // TODO:
 /*
diff --git a/src/palmos/dc.cpp b/src/palmos/dc.cpp
index eddc16efc4..3dbbc7b11d 100644
--- a/src/palmos/dc.cpp
+++ b/src/palmos/dc.cpp
@@ -330,7 +330,7 @@ wxCoord wxDC::GetCharWidth() const
 
 void wxDC::DoGetTextExtent(const wxString& string, wxCoord *x, wxCoord *y,
                            wxCoord *descent, wxCoord *externalLeading,
-                           wxFont *font) const
+                           const wxFont *font) const
 {
 }
 
diff --git a/src/palmos/metafile.cpp b/src/palmos/metafile.cpp
index 5c6880d9b9..6d98ac45bb 100644
--- a/src/palmos/metafile.cpp
+++ b/src/palmos/metafile.cpp
@@ -119,7 +119,8 @@ wxMetafileDC::~wxMetafileDC()
 }
 
 void wxMetafileDC::GetTextExtent(const wxString& string, long *x, long *y,
-                                 long *descent, long *externalLeading, wxFont *theFont, bool WXUNUSED(use16bit)) const
+                                 long *descent, long *externalLeading,
+                                 const wxFont *theFont, bool WXUNUSED(use16bit)) const
 {
 }
 
diff --git a/src/x11/dcclient.cpp b/src/x11/dcclient.cpp
index 4ab1920f7e..cd0ed5f6a3 100644
--- a/src/x11/dcclient.cpp
+++ b/src/x11/dcclient.cpp
@@ -1612,7 +1612,7 @@ void wxWindowDC::DoDrawRotatedText( const wxString &text, wxCoord x, wxCoord y,
 
 void wxWindowDC::DoGetTextExtent( const wxString &string, wxCoord *width, wxCoord *height,
                                 wxCoord *descent, wxCoord *externalLeading,
-                                wxFont *font ) const
+                                const wxFont *font ) const
 {
     wxCHECK_RET( Ok(), wxT("invalid dc") );
 
-- 
2.50.0

