]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/font.cpp
Override GetPixelSize on OS X as the base impl creates a wxScreenDC each time, which...
[wxWidgets.git] / src / mac / carbon / font.cpp
index e2c9d4f9a0bcb11b1fa35192d57d94c584ffeedd..75ea3f918ada154f72e5fc9e6464d07c7f51e6f3 100644 (file)
@@ -21,7 +21,7 @@
 #endif
 
 #include "wx/fontutil.h"
-#include "wx/fontutil.h"
+#include "wx/graphics.h"
 
 #include "wx/mac/private.h"
 
@@ -528,6 +528,20 @@ int wxFont::GetPointSize() const
     return M_FONTDATA->m_pointSize;
 }
 
+wxSize wxFont::GetPixelSize() const
+{
+#if wxUSE_GRAPHICS_CONTEXT
+    // TODO: consider caching the value
+    wxGraphicsContext* dc = wxGraphicsContext::CreateFromNative((CGContextRef) NULL);
+    dc->SetFont(*(wxFont *)this);
+    wxDouble width, height = 0;
+    dc->GetTextExtent( wxT("g"), &width, &height, NULL, NULL); 
+    return wxSize(width, height);
+#else
+    wxFontBase::GetPixelSize();
+#endif
+}
+
 int wxFont::GetFamily() const
 {
     wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );