static wxGraphicsContext* Create( wxWindow* window ) ;
 
+    // create a context that can be used for measuring texts only, no drawing allowed
+    static wxGraphicsContext * Create();
+
     wxGraphicsPath CreatePath() const;
     
     virtual wxGraphicsPen CreatePen(const wxPen& pen) const;
 
     virtual wxGraphicsContext * CreateContext( wxWindow* window ) = 0;
 
+    // create a context that can be used for measuring texts only, no drawing allowed
+    virtual wxGraphicsContext * CreateMeasuringContext() = 0;
+
     // Path
     
     virtual wxGraphicsPath CreatePath() = 0;
 
 
     wxPrintData& GetPrintData() { return m_printData; }
     virtual wxSize GetPPI() const;
-#if wxMAC_USE_CORE_GRAPHICS
-    void MacSetCGContext( void * cg ) ;
-#endif    
  protected:
     virtual void DoGetSize( int *width, int *height ) const;
     wxPrintData   m_printData ;
 
         m_ok = true;
         // apply the stored transformations to the passed in context
         ComputeScaleAndOrigin();
+        m_graphicContext->SetFont( m_font , m_textForegroundColour );
+        m_graphicContext->SetPen( m_pen );
+        m_graphicContext->SetBrush( m_brush);
     }
 }
 
 {
     Init();
     SetGraphicsContext( wxGraphicsContext::Create(dc) );
-    if ( dc.GetFont().Ok())
-        m_graphicContext->SetFont( m_graphicContext->CreateFont(dc.GetFont(),dc.GetTextForeground()));
-    if ( dc.GetPen().Ok())
-        m_graphicContext->SetPen( m_graphicContext->CreatePen(dc.GetPen()));
-    if ( dc.GetBrush().Ok())
-        m_graphicContext->SetBrush( m_graphicContext->CreateBrush(dc.GetBrush()));
 }
 
 void wxGCDC::Init()
 
 
 void wxGraphicsContext::SetPen( const wxPen& pen )
 {
-    if ( pen.GetStyle() == wxTRANSPARENT )
+    if ( !pen.Ok() || pen.GetStyle() == wxTRANSPARENT )
         SetPen( wxNullGraphicsPen );
     else
         SetPen( CreatePen( pen ) );
 
 void wxGraphicsContext::SetBrush( const wxBrush& brush )
 {
-    if ( brush.GetStyle() == wxTRANSPARENT )
+    if ( !brush.Ok() || brush.GetStyle() == wxTRANSPARENT )
         SetBrush( wxNullGraphicsBrush );
     else
         SetBrush( CreateBrush( brush ) );
     return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(window);
 }
 
+wxGraphicsContext* wxGraphicsContext::Create()
+{
+    return wxGraphicsRenderer::GetDefaultRenderer()->CreateMeasuringContext();
+}
+
 //-----------------------------------------------------------------------------
 // wxGraphicsRenderer
 //-----------------------------------------------------------------------------
 
 
         SetGraphicsContext( wxGraphicsContext::CreateFromNative( cg ) );
     }
-    m_graphicContext->SetPen( m_pen ) ;
-    m_graphicContext->SetBrush( m_brush ) ;
     SetClippingRegion( 0 , 0 , m_width , m_height ) ;
 #else
     int x , y ;
 
             CGContextScaleCTM( bmCtx , 1 , -1 ) ;
 
                        SetGraphicsContext( wxGraphicsContext::CreateFromNative( bmCtx ) );
-            m_graphicContext->SetPen( m_pen ) ;
-            m_graphicContext->SetBrush( m_brush ) ;
-            m_graphicContext->SetFont( m_font , m_textForegroundColour) ;
         }
         m_ok = (m_graphicContext != NULL) ;
 
 
         m_err = noErr ;
     }
 #if wxMAC_USE_CORE_GRAPHICS
-    dc->MacSetCGContext(pageContext) ;
+    dc->SetGraphicsContext( wxGraphicsContext::CreateFromNative( pageContext ) );
 #endif
 }
 
         PMSessionEndDocument(native->m_macPrintSession);
     }
 #if wxMAC_USE_CORE_GRAPHICS
-    dc->MacSetCGContext(NULL) ;
+    // the cg context we got when starting the page isn't valid anymore, so replace it
+    dc->SetGraphicsContext( wxGraphicsContext::Create() );
 #endif
 }
 
             m_mm_to_pix_y = mm2inches * sz.y;        
         }
 #if wxMAC_USE_CORE_GRAPHICS
-/*
-        // the cgContext will only be handed over page by page
-        m_graphicContext = new wxMacCGContext() ;
-               */
+        // we need at least a measuring context because people start measuring before a page
+        // gets printed at all
+        SetGraphicsContext( wxGraphicsContext::Create() );
 #endif
     }
 }
 
 wxPrinterDC::~wxPrinterDC(void)
 {
-#if wxMAC_USE_CORE_GRAPHICS
-/*
-    // this context was borrowed
-    ((wxMacCGContext*)(m_graphicContext))->SetNativeContext( NULL ) ;
-       */
-#endif
     delete m_nativePrinterDC ;
 }
 
-#if wxMAC_USE_CORE_GRAPHICS
-void wxPrinterDC::MacSetCGContext( void * cg )
-{
-    SetGraphicsContext( wxGraphicsContext::CreateFromNative( cg ) );
-    m_graphicContext->SetPen( m_pen ) ;
-    m_graphicContext->SetBrush( m_brush ) ;
-}
-#endif
 bool wxPrinterDC::StartDoc( const wxString& message )
 {
     wxASSERT_MSG( Ok() , wxT("Called wxPrinterDC::StartDoc from an invalid object") ) ;
 
     virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window );
 
     virtual wxGraphicsContext * CreateContext( wxWindow* window );
+    
+    virtual wxGraphicsContext * CreateMeasuringContext();
 
     // Path
 
     return new wxMacCoreGraphicsContext(this, window );
 }
 
+wxGraphicsContext * wxMacCoreGraphicsRenderer::CreateMeasuringContext()
+{
+    return new wxMacCoreGraphicsContext(this);
+}
+
 // Path
 
 wxGraphicsPath wxMacCoreGraphicsRenderer::CreatePath()
 
 
 void wxOverlayImpl::BeginDrawing( wxWindowDC* dc)
 {
-// TODO CS
     dc->SetGraphicsContext( wxGraphicsContext::CreateFromNative( m_overlayContext ) );
-    // triggers an application of the already set device origins to the native context
-    dc->SetUserScale(1,1);
     wxSize size = dc->GetSize() ;
     dc->SetClippingRegion( 0 , 0 , size.x , size.y ) ;
 }