X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/82a234fbff7fbc174c9459980995b73f37087992..82c126e50158efee5a1f46e1200be380c5199f8d:/src/generic/graphicc.cpp diff --git a/src/generic/graphicc.cpp b/src/generic/graphicc.cpp index 728fc687f2..df232c1db3 100644 --- a/src/generic/graphicc.cpp +++ b/src/generic/graphicc.cpp @@ -735,6 +735,7 @@ void wxCairoFontData::Apply( wxGraphicsContext* context ) // the rest is done using Pango layouts #elif defined(__WXMAC__) cairo_set_font_face(ctext, m_font); + cairo_set_font_size(ctext, m_size ); #else cairo_select_font_face(ctext, m_fontName, m_slant, m_weights ); cairo_set_font_size(ctext, m_size ); @@ -1035,8 +1036,13 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, const wxWindowDC& : wxGraphicsContext(renderer) { #ifdef __WXGTK__ +#if wxUSE_NEW_DC + wxGTKImplDC *impldc = (wxGTKImplDC*) dc.GetImpl(); + Init( gdk_cairo_create( impldc->GetGDKWindow() ) ); +#else Init( gdk_cairo_create( dc.m_window ) ); #endif +#endif #ifdef __WXMAC__ int width, height; dc.GetSize( &width, &height ); @@ -1327,7 +1333,7 @@ void wxCairoContext::DrawText( const wxString &str, wxDouble x, wxDouble y ) return; #ifdef __WXGTK__ - const wxCharBuffer data = wxConvUTF8.cWC2MB( str ); + const wxCharBuffer data = str.utf8_str(); if ( !data ) return; size_t datalen = strlen(data); @@ -1373,7 +1379,7 @@ void wxCairoContext::GetTextExtent( const wxString &str, wxDouble *width, wxDoub PangoLayout *layout = pango_cairo_create_layout (m_context); pango_layout_set_font_description( layout, ((wxCairoFontData*)m_font.GetRefData())->GetFont()); - const wxCharBuffer data = wxConvUTF8.cWC2MB( str ); + const wxCharBuffer data = str.utf8_str(); if ( !data ) { return; @@ -1407,6 +1413,17 @@ void wxCairoContext::GetTextExtent( const wxString &str, wxDouble *width, wxDoub { cairo_font_extents_t fe; cairo_font_extents(m_context, &fe); + + // some backends have negative descents + + if ( fe.descent < 0 ) + fe.descent = -fe.descent; + + if ( fe.height < (fe.ascent + fe.descent ) ) + { + // some backends are broken re height ... (eg currently ATSUI) + fe.height = fe.ascent + fe.descent; + } if (height) *height = fe.height; @@ -1498,6 +1515,9 @@ private : IMPLEMENT_DYNAMIC_CLASS(wxCairoRenderer,wxGraphicsRenderer) static wxCairoRenderer gs_cairoGraphicsRenderer; +// temporary hack to allow creating a cairo context on any platform +extern wxGraphicsRenderer* gCairoRenderer; +wxGraphicsRenderer* gCairoRenderer = &gs_cairoGraphicsRenderer; #ifdef __WXGTK__ wxGraphicsRenderer* wxGraphicsRenderer::GetDefaultRenderer()