diff --git a/src/generic/dcpsg.cpp b/src/generic/dcpsg.cpp index 25c72a2a11..446555dc51 100644 --- a/src/generic/dcpsg.cpp +++ b/src/generic/dcpsg.cpp @@ -254,7 +254,7 @@ static char wxPostScriptHeaderReencodeISO2[] = IMPLEMENT_DYNAMIC_CLASS(wxPostScriptDC, wxDC) -float wxPostScriptDC::ms_PSScaleFactor = 10.0; +float wxPostScriptDC::ms_PSScaleFactor = 1.0; void wxPostScriptDC::SetResolution(int ppi) { @@ -1220,16 +1220,20 @@ void draw_bezier_outline(FILE *file, fprintf(file, "gsave\n"); fprintf(file, "%d %d translate\n", pos_x, pos_y ); - // FT2 scales outlines to 26.6 pixels so the code below - // should read 26600 instead of the 60000. - fprintf(file, "%d 60000 div %d 60000 div scale\n", scale_x, scale_y ); - fprintf(file, "0 0 0 setrgbcolor\n"); + + // We have to replace the "," from the German + // locale with the Englich "." for PostScript + char buf[100]; + sprintf(buf, "%.8f %.8f scale\n", scale_x, scale_y ); + for (size_t i = 0; i < strlen(buf); i++) + if (buf[i] == ',') buf[i] = '.'; + fprintf(file, buf); FT_Load_Glyph(face, glyph_index, load_flags); FT_Get_Glyph (face->glyph, &glyph); FT_Outline_Decompose (&(((FT_OutlineGlyph)glyph)->outline), &outlinefunc, &outline_info); - fprintf(file, "closepath fill grestore \n"); + fprintf(file, "closepath fill grestore\n"); FT_Done_Glyph (glyph); } @@ -1240,78 +1244,6 @@ void wxPostScriptDC::DoDrawText( const wxString& text, wxCoord x, wxCoord y ) { wxCHECK_RET( m_ok && m_pstream, wxT("invalid postscript dc") ); -#if wxUSE_PANGO - int dpi = GetResolution(); - dpi = 300; - PangoContext *context = pango_ft2_get_context ( dpi, dpi ); - - pango_context_set_language (context, pango_language_from_string ("en_US")); - pango_context_set_base_dir (context, PANGO_DIRECTION_LTR ); - - pango_context_set_font_description (context, m_font.GetNativeFontInfo()->description ); - - PangoLayout *layout = pango_layout_new (context); -#if wxUSE_UNICODE - wxCharBuffer buffer = wxConvUTF8.cWC2MB( text ); -#else - wxCharBuffer buffer = wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( text ) ); -#endif - pango_layout_set_text( layout, (const char*) buffer, strlen(buffer) ); - - PangoRectangle rect; - pango_layout_get_extents(layout, NULL, &rect); - - int xx = x * PANGO_SCALE; - int yy = y * PANGO_SCALE + (rect.height*2/3); - - int scale_x = LogicalToDeviceXRel( 1000 ); - int scale_y = LogicalToDeviceYRel( 1000 ); - - // Loop over lines in layout - int num_lines = pango_layout_get_line_count( layout ); - for (int i = 0; i < num_lines; i++) - { - PangoLayoutLine *line = pango_layout_get_line( layout, i ); - - // Loop over runs in line - GSList *runs_list = line->runs; - while (runs_list) - { - PangoLayoutRun *run = (PangoLayoutRun*) runs_list->data; - PangoItem *item = run->item; - PangoGlyphString *glyphs = run->glyphs; - PangoAnalysis *analysis = &item->analysis; - PangoFont *font = analysis->font; - FT_Face ft_face = pango_ft2_font_get_face(font); - - int num_glyphs = glyphs->num_glyphs; - for (int glyph_idx = 0; glyph_idx < num_glyphs; glyph_idx++) - { - PangoGlyphGeometry geometry = glyphs->glyphs[glyph_idx].geometry; - int pos_x = xx + geometry.x_offset; - int pos_y = yy - geometry.y_offset; - xx += geometry.width; - - draw_bezier_outline( m_pstream, ft_face, - (FT_UInt)(glyphs->glyphs[glyph_idx].glyph), - LogicalToDeviceX( pos_x / PANGO_SCALE ), - LogicalToDeviceY( pos_y / PANGO_SCALE ), - scale_x, scale_y ); - } - runs_list = runs_list->next; - } - } - - g_object_unref( G_OBJECT( layout ) ); -#else - wxCoord text_w, text_h, text_descent; - - GetTextExtent(text, &text_w, &text_h, &text_descent); - - // VZ: this seems to be unnecessary, so taking it out for now, if it - // doesn't create any problems, remove this comment entirely - //SetFont( m_font ); - if (m_textForegroundColour.Ok()) { unsigned char red = m_textForegroundColour.Red(); @@ -1352,6 +1284,90 @@ void wxPostScriptDC::DoDrawText( const wxString& text, wxCoord x, wxCoord y ) } } +#if wxUSE_PANGO + int ps_dpi = 72; + int pango_dpi = 600; + PangoContext *context = pango_ft2_get_context ( pango_dpi, pango_dpi ); + + double scale = (double)pango_dpi / (double)ps_dpi; + scale /= m_userScaleY; + + pango_context_set_language (context, pango_language_from_string ("en_US")); + pango_context_set_base_dir (context, PANGO_DIRECTION_LTR ); + + pango_context_set_font_description (context, m_font.GetNativeFontInfo()->description ); + + PangoLayout *layout = pango_layout_new (context); +#if wxUSE_UNICODE + wxCharBuffer buffer = wxConvUTF8.cWC2MB( text ); +#else + wxCharBuffer buffer = wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( text ) ); +#endif + pango_layout_set_text( layout, (const char*) buffer, strlen(buffer) ); + + fprintf( m_pstream, "%%%% %s\n", (const char*)buffer ); + + PangoRectangle rect; + pango_layout_get_extents(layout, NULL, &rect); + + int xx = LogicalToDeviceX( x ); + int yy = LogicalToDeviceY( y ); + + int xxx = xx * PANGO_SCALE; + int yyy = yy * PANGO_SCALE - (int)(rect.height * 0.66 / scale); // Move down by estimated baseline. HACK. + +#define ps_kludge_factor 2.8 + + // Loop over lines in layout + int num_lines = pango_layout_get_line_count( layout ); + for (int i = 0; i < num_lines; i++) + { + PangoLayoutLine *line = pango_layout_get_line( layout, i ); + + // width of glyphs already printed + int all_width = 0; + + // Loop over runs in line + GSList *runs_list = line->runs; + while (runs_list) + { + PangoLayoutRun *run = (PangoLayoutRun*) runs_list->data; + PangoItem *item = run->item; + PangoGlyphString *glyphs = run->glyphs; + PangoAnalysis *analysis = &item->analysis; + PangoFont *font = analysis->font; + FT_Face ft_face = pango_ft2_font_get_face(font); + + int num_glyphs = glyphs->num_glyphs; + for (int glyph_idx = 0; glyph_idx < num_glyphs; glyph_idx++) + { + PangoGlyphGeometry geometry = glyphs->glyphs[glyph_idx].geometry; + int pos_x = xxx + (int)((double)(all_width+geometry.x_offset) / scale); + int pos_y = yyy + (int)((double)geometry.y_offset / scale ); + all_width += geometry.width; + + draw_bezier_outline( m_pstream, ft_face, + (FT_UInt)(glyphs->glyphs[glyph_idx].glyph), + pos_x / PANGO_SCALE, + pos_y / PANGO_SCALE, + 1.0/(ps_kludge_factor * scale * 26.6), + 1.0/(ps_kludge_factor * scale * 26.6) ); + } + runs_list = runs_list->next; + } + } + + g_object_unref( G_OBJECT( layout ) ); + g_object_unref( G_OBJECT( context ) ); +#else + wxCoord text_w, text_h, text_descent; + + GetTextExtent(text, &text_w, &text_h, &text_descent); + + // VZ: this seems to be unnecessary, so taking it out for now, if it + // doesn't create any problems, remove this comment entirely + //SetFont( m_font ); + int size = m_font.GetPointSize(); // wxCoord by = y + (wxCoord)floor( double(size) * 2.0 / 3.0 ); // approximate baseline @@ -1981,8 +1997,12 @@ void wxPostScriptDC::DoGetTextExtent(const wxString& string, } #if wxUSE_PANGO - int dpi = GetResolution(); - PangoContext *context = pango_ft2_get_context ( dpi, dpi ); + int wx_dpi = GetResolution(); + int pango_dpi = 600; + PangoContext *context = pango_ft2_get_context ( pango_dpi, pango_dpi ); + + double scale = pango_dpi / wx_dpi; + scale /= m_userScaleY; pango_context_set_language (context, pango_language_from_string ("en_US")); pango_context_set_base_dir (context, PANGO_DIRECTION_LTR ); @@ -1992,20 +2012,19 @@ void wxPostScriptDC::DoGetTextExtent(const wxString& string, PangoFontDescription *desc = fontToUse->GetNativeFontInfo()->description; pango_layout_set_font_description(layout, desc); #if wxUSE_UNICODE - const wxCharBuffer data = wxConvUTF8.cWC2MB( string ); - pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data )); + const wxCharBuffer data = wxConvUTF8.cWC2MB( string ); #else - const wxWCharBuffer wdata = wxConvLocal.cMB2WC( string ); - const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); - pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data )); + const wxWCharBuffer wdata = wxConvLocal.cMB2WC( string ); + const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); #endif + pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data )); PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data; PangoRectangle rect; pango_layout_line_get_extents(line, NULL, &rect); - if (x) (*x) = (wxCoord) ( m_scaleX * rect.width / PANGO_SCALE ); - if (y) (*y) = (wxCoord) ( m_scaleY * rect.height / PANGO_SCALE ); + if (x) (*x) = (wxCoord) ( rect.width / PANGO_SCALE / scale ); + if (y) (*y) = (wxCoord) ( rect.height / PANGO_SCALE / scale ); if (descent) { // Do something about metrics here diff --git a/src/gtk/choice.cpp b/src/gtk/choice.cpp index c9e3cceac2..9b3b464160 100644 --- a/src/gtk/choice.cpp +++ b/src/gtk/choice.cpp @@ -448,14 +448,11 @@ wxSize wxChoice::DoGetBestSize() const ret.x = 0; if ( m_widget ) { - GdkFont *font = m_font.GetInternalFont(); - - wxCoord width; + int width; size_t count = GetCount(); for ( size_t n = 0; n < count; n++ ) { - // FIXME GTK 2.0 - width = (wxCoord)gdk_string_width(font, wxGTK_CONV( GetString(n) ) ); + GetTextExtent( GetString(n), &width, NULL, NULL, NULL, &m_font ); if ( width > ret.x ) ret.x = width; } @@ -477,7 +474,7 @@ wxSize wxChoice::DoGetBestSize() const if ( ret.x < 80 ) ret.x = 80; - ret.y = 16 + gdk_char_height(GET_STYLE_FONT( m_widget->style ), 'H' ); + ret.y = 16 + GetCharHeight(); return ret; } diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index ee0cc2e8d5..8ed30aed10 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -750,13 +750,11 @@ wxSize wxComboBox::DoGetBestSize() const ret.x = 0; if ( m_widget ) { - GdkFont *font = m_font.GetInternalFont(); - - wxCoord width; - size_t count = Number(); + int width; + size_t count = GetCount(); for ( size_t n = 0; n < count; n++ ) { - width = (wxCoord)gdk_string_width(font, wxGTK_CONV( GetString(n) ) ); + GetTextExtent( GetString(n), &width, NULL, NULL, NULL, &m_font ); if ( width > ret.x ) ret.x = width; } diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index a1a1b15680..2ef77d4f3b 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -1436,27 +1436,56 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) #ifdef __WXGTK20__ // TODO: the layout engine should be abstracted at a higher level! PangoLayout *layout = pango_layout_new(m_context); - pango_layout_set_font_description(layout, m_fontdesc); - { -#if wxUSE_UNICODE - const wxCharBuffer data = wxConvUTF8.cWC2MB( text ); - pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data )); -#else - const wxWCharBuffer wdata = wxConvLocal.cMB2WC( text ); - const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); - pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data )); -#endif - } - // Measure layout. +#if wxUSE_UNICODE + const wxCharBuffer data = wxConvUTF8.cWC2MB( text ); +#else + const wxWCharBuffer wdata = wxConvLocal.cMB2WC( text ); + const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); +#endif + + pango_layout_set_text( layout, (const char*)data, strlen((const char*)data) ); + + if (m_scaleY != 1.0) + { + // If there is a user or actually any scale applied to + // the device context, scale the font. + + // scale font description + gint oldSize = pango_font_description_get_size( m_fontdesc ); + double size = oldSize; + size = size * m_scaleY; + pango_font_description_set_size( m_fontdesc, (gint)size ); + + // actually apply scaled font + pango_layout_set_font_description( layout, m_fontdesc ); + + // Draw layout. + gdk_draw_layout( m_window, m_textGC, x, y, layout ); + + // reset unscaled size + pango_font_description_set_size( m_fontdesc, oldSize ); + } + else + { + // actually apply font + pango_layout_set_font_description( layout, m_fontdesc ); + + // Draw layout. + gdk_draw_layout( m_window, m_textGC, x, y, layout ); + } + +#if 0 + // Measure layout int w,h; - pango_layout_get_pixel_size(layout, &w, &h); + pango_layout_get_pixel_size( m_layout, &w, &h ); +#else + int w = 10; + int h = 10; +#endif wxCoord width = w; wxCoord height = h; - - // Draw layout. - gdk_draw_layout( m_window, m_textGC, x, y, layout ); - + g_object_unref( G_OBJECT( layout ) ); #else // GTK+ 1.x wxCoord width = gdk_string_width( font, text.mbc_str() ); @@ -1614,25 +1643,24 @@ void wxWindowDC::DoGetTextExtent(const wxString &string, #ifdef __WXGTK20__ // Create layout and set font description - PangoLayout *layout = pango_layout_new(m_context); + PangoLayout *layout = pango_layout_new( m_context ); if (theFont) pango_layout_set_font_description( layout, theFont->GetNativeFontInfo()->description ); else - pango_layout_set_font_description(layout, m_fontdesc); + pango_layout_set_font_description( layout, m_fontdesc ); // Set layout's text #if wxUSE_UNICODE - const wxCharBuffer data = wxConvUTF8.cWC2MB( string ); - pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data )); + const wxCharBuffer data = wxConvUTF8.cWC2MB( string ); #else - const wxWCharBuffer wdata = wxConvLocal.cMB2WC( string ); - const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); - pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data )); + const wxWCharBuffer wdata = wxConvLocal.cMB2WC( string ); + const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); #endif + pango_layout_set_text( layout, (const char*) data, strlen((const char*)data) ); // Measure text. int w,h; - pango_layout_get_pixel_size(layout, &w, &h); + pango_layout_get_pixel_size( layout, &w, &h ); if (width) (*width) = (wxCoord) w; if (height) (*height) = (wxCoord) h; @@ -1681,7 +1709,7 @@ wxCoord wxWindowDC::GetCharHeight() const // There should be an easier way. PangoLayout *layout = pango_layout_new(m_context); pango_layout_set_font_description(layout, m_fontdesc); - pango_layout_set_text(layout, "H", 1 ); + pango_layout_set_text(layout, "H", 1); int w,h; pango_layout_get_pixel_size(layout, &w, &h); g_object_unref( G_OBJECT( layout ) ); diff --git a/src/gtk/fontdlg.cpp b/src/gtk/fontdlg.cpp index 3dfb008131..244094a850 100644 --- a/src/gtk/fontdlg.cpp +++ b/src/gtk/fontdlg.cpp @@ -64,6 +64,8 @@ void gtk_fontdialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFontDialog *dial wxapp_install_idle_handler(); GtkFontSelectionDialog *fontdlg = GTK_FONT_SELECTION_DIALOG(dialog->m_widget); + +#ifndef __WXGTK20__ GdkFont *gfont = gtk_font_selection_dialog_get_font(fontdlg); if (!gfont) @@ -72,13 +74,10 @@ void gtk_fontdialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFontDialog *dial wxOK | wxICON_ERROR); return; } +#endif - gchar *fontname = gtk_font_selection_dialog_get_font_name(fontdlg); - - // printf( "font %s\n", fontname ); - + gchar *fontname = gtk_font_selection_dialog_get_font_name( fontdlg ); dialog->SetChosenFont( fontname); - g_free( fontname ); wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK); diff --git a/src/gtk/menu.cpp b/src/gtk/menu.cpp index af7bc81726..35a39ee5b7 100644 --- a/src/gtk/menu.cpp +++ b/src/gtk/menu.cpp @@ -145,7 +145,7 @@ static wxString wxReplaceUnderscore( const wxString& title ) #endif else { -#if __WXGTK12__ +#ifdef __WXGTK12__ if ( *pc == wxT('_') ) { // underscores must be doubled to prevent them from being @@ -907,7 +907,7 @@ void wxMenuItem::DoSetText( const wxString& str ) #if GTK_CHECK_VERSION(2, 0, 0) else if ( *pc == wxT('_') ) // escape underscores { - // m_text << wxT("__"); doesn't work + m_text << wxT("__"); } else if (*pc == wxT('/')) // we have to escape slashes { @@ -1010,8 +1010,12 @@ wxString wxMenuItem::GetFactoryPath() const { if ( *pc == wxT('_') ) { +#ifdef __WXGTK20__ + pc++; +#else // remove '_' unconditionally continue; +#endif } // don't remove ampersands '&' since if we have them in the menu item title diff --git a/src/gtk/minifram.cpp b/src/gtk/minifram.cpp index 2e98dd832e..c23782237b 100644 --- a/src/gtk/minifram.cpp +++ b/src/gtk/minifram.cpp @@ -82,28 +82,28 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g 0, 0, win->m_width, win->m_height ); - if (!win->m_title.IsEmpty() && + if (!win->GetTitle().IsEmpty() && ((win->GetWindowStyle() & wxCAPTION) || (win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) || (win->GetWindowStyle() & wxTINY_CAPTION_VERT))) { + wxClientDC dc(win); + dc.SetFont( *wxSMALL_FONT ); + int height = dc.GetCharHeight(); + GdkGC *gc = gdk_gc_new( pizza->bin_window ); - GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0); - gdk_gc_set_foreground( gc, &widget->style->bg[GTK_STATE_SELECTED] ); gdk_draw_rectangle( pizza->bin_window, gc, TRUE, 3, 3, win->m_width - 7, - font->ascent + font->descent+1 ); - - gdk_gc_set_foreground( gc, &widget->style->fg[GTK_STATE_SELECTED] ); - gdk_draw_string( pizza->bin_window, font, gc, - 6, - 3+font->ascent, - wxGTK_CONV( win->m_title ) ); - + height+1 ); gdk_gc_unref( gc ); + + // Hack alert + dc.m_window = pizza->bin_window; + dc.SetTextForeground( *wxWHITE ); + dc.DrawText( win->GetTitle(), 6, 3 ); } } @@ -111,6 +111,7 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g // "draw" of m_mainWidget //----------------------------------------------------------------------------- +#ifndef __WXGTK20__ static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNUSED(rect), wxFrame *win ) { if (g_isIdle) wxapp_install_idle_handler(); @@ -131,25 +132,26 @@ static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNU (win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) || (win->GetWindowStyle() & wxTINY_CAPTION_VERT))) { + wxClientDC dc(win); + dc.SetFont( *wxSMALL_FONT ); + int height = dc.GetCharHeight(); + GdkGC *gc = gdk_gc_new( pizza->bin_window ); - GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0); - gdk_gc_set_foreground( gc, &widget->style->bg[GTK_STATE_SELECTED] ); gdk_draw_rectangle( pizza->bin_window, gc, TRUE, 3, 3, win->m_width - 7, - font->ascent + font->descent+1 ); - - gdk_gc_set_foreground( gc, &widget->style->fg[GTK_STATE_SELECTED] ); - gdk_draw_string( pizza->bin_window, font, gc, - 6, - 3+font->ascent, - wxGTK_CONV( win->m_title ) ); - + height+1 ); gdk_gc_unref( gc ); + + // Hack alert + dc.m_window = pizza->bin_window; + dc.SetTextForeground( *wxWHITE ); + dc.DrawText( win->GetTitle(), 6, 3 ); } } +#endif //----------------------------------------------------------------------------- // "button_press_event" of m_mainWidget @@ -167,9 +169,11 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton GtkPizza *pizza = GTK_PIZZA(widget); if (gdk_event->window != pizza->bin_window) return TRUE; + + wxClientDC dc(win); + dc.SetFont( *wxSMALL_FONT ); + int height = dc.GetCharHeight() + 1; - GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0); - int height = font->ascent + font->descent+1; if (gdk_event->y > height) return TRUE; gdk_window_raise( win->m_widget->window ); @@ -364,8 +368,10 @@ bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title gtk_signal_connect( GTK_OBJECT(m_mainWidget), "expose_event", GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this ); +#ifndef __WXGTK20__ gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw", GTK_SIGNAL_FUNC(gtk_window_own_draw_callback), (gpointer)this ); +#endif /* these are required for dragging the mini frame around */ gtk_signal_connect( GTK_OBJECT(m_mainWidget), "button_press_event", diff --git a/src/gtk/settings.cpp b/src/gtk/settings.cpp index 736ed76aba..227599ef0b 100644 --- a/src/gtk/settings.cpp +++ b/src/gtk/settings.cpp @@ -328,21 +328,8 @@ wxFont wxSystemSettingsNative::GetFont( wxSystemFont index ) if (!g_systemFont) { #ifdef __WXGTK20__ - GtkWidget *widget = gtk_button_new(); - GtkStyle *def = gtk_rc_get_style( widget ); - if (!def) - def = gtk_widget_get_default_style(); - if (def) - { - wxNativeFontInfo info; - info.description = def->font_desc; - g_systemFont = new wxFont(info); - } - else - { - g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); - } - gtk_widget_destroy( widget ); + const gchar *font_name = _gtk_rc_context_get_default_font_name (gtk_settings_get_default ()); + g_systemFont = new wxFont( wxString::FromAscii( font_name ) ); #else g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); #endif diff --git a/src/gtk/tbargtk.cpp b/src/gtk/tbargtk.cpp index d05f2cddfb..2ce4bc754c 100644 --- a/src/gtk/tbargtk.cpp +++ b/src/gtk/tbargtk.cpp @@ -343,8 +343,6 @@ bool wxToolBar::Create( wxWindow *parent, g_style->bg[GTK_STATE_NORMAL] = *m_bg; - SET_STYLE_FONT(g_style, GtkGetDefaultGuiFont()); - gtk_widget_set_style( GTK_TOOLBAR(m_toolbar)->tooltips->tip_window, g_style ); m_parent->DoAddChild( this ); diff --git a/src/gtk/tooltip.cpp b/src/gtk/tooltip.cpp index d6577bfb93..a8e42e4d07 100644 --- a/src/gtk/tooltip.cpp +++ b/src/gtk/tooltip.cpp @@ -76,8 +76,6 @@ void wxToolTip::Apply( wxWindow *win ) g_style->fg[GTK_STATE_NORMAL] = ss_fg; g_style->bg[GTK_STATE_NORMAL] = ss_bg; - SET_STYLE_FONT( g_style, GtkGetDefaultGuiFont() ); - gtk_widget_set_style( ss_tooltips->tip_window, g_style ); #else // GTK+ 1.0 gtk_tooltips_set_colors( ss_tooltips, &ss_bg, &ss_fg ); diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 36b4fbc8e9..fcf2a95580 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -1695,6 +1695,20 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, wxPrintf( wxT(".\n") ); */ +#ifndef __WXGTK20__ + if (event_type == wxEVT_LEFT_DCLICK) + { + // GTK 1.2 crashes when intercepting double + // click events from both wxSpinButton and + // wxSpinCtrl + if (GTK_IS_SPIN_BUTTON(win->m_widget)) + { + // Just disable this event for now. + return FALSE; + } + } +#endif + if (win->GetEventHandler()->ProcessEvent( event )) { gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_press_event" ); @@ -3406,9 +3420,31 @@ int wxWindowGTK::GetCharHeight() const wxCHECK_MSG( m_font.Ok(), 12, wxT("invalid font") ); +#ifdef __WXGTK20__ + PangoContext *context = NULL; + if (m_widget) + context = gtk_widget_get_pango_context( m_widget ); + + if (!context) + return 0; + + PangoFontDescription *desc = m_font.GetNativeFontInfo()->description; + PangoLayout *layout = pango_layout_new(context); + pango_layout_set_font_description(layout, desc); + pango_layout_set_text(layout, "H", 1); + PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data; + + PangoRectangle rect; + pango_layout_line_get_extents(line, NULL, &rect); + + g_object_unref( G_OBJECT( layout ) ); + + return (int) (rect.height / PANGO_SCALE); +#else GdkFont *font = m_font.GetInternalFont( 1.0 ); return font->ascent + font->descent; +#endif } int wxWindowGTK::GetCharWidth() const @@ -3417,9 +3453,31 @@ int wxWindowGTK::GetCharWidth() const wxCHECK_MSG( m_font.Ok(), 8, wxT("invalid font") ); +#ifdef __WXGTK20__ + PangoContext *context = NULL; + if (m_widget) + context = gtk_widget_get_pango_context( m_widget ); + + if (!context) + return 0; + + PangoFontDescription *desc = m_font.GetNativeFontInfo()->description; + PangoLayout *layout = pango_layout_new(context); + pango_layout_set_font_description(layout, desc); + pango_layout_set_text(layout, "H", 1); + PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data; + + PangoRectangle rect; + pango_layout_line_get_extents(line, NULL, &rect); + + g_object_unref( G_OBJECT( layout ) ); + + return (int) (rect.width / PANGO_SCALE); +#else GdkFont *font = m_font.GetInternalFont( 1.0 ); return gdk_string_width( font, "H" ); +#endif } void wxWindowGTK::GetTextExtent( const wxString& string, @@ -4089,7 +4147,13 @@ void wxWindowGTK::SetWidgetStyle() if (m_font != wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT )) { - SET_STYLE_FONT(style, m_font.GetInternalFont( 1.0 )); +#ifdef __WXGTK20__ + pango_font_description_free( style->font_desc ); + pango_font_description_copy( m_font.GetNativeFontInfo()->description ); +#else + gdk_font_unref( style->font ); + style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) ); +#endif } if (m_foregroundColour.Ok()) diff --git a/src/gtk1/choice.cpp b/src/gtk1/choice.cpp index c9e3cceac2..9b3b464160 100644 --- a/src/gtk1/choice.cpp +++ b/src/gtk1/choice.cpp @@ -448,14 +448,11 @@ wxSize wxChoice::DoGetBestSize() const ret.x = 0; if ( m_widget ) { - GdkFont *font = m_font.GetInternalFont(); - - wxCoord width; + int width; size_t count = GetCount(); for ( size_t n = 0; n < count; n++ ) { - // FIXME GTK 2.0 - width = (wxCoord)gdk_string_width(font, wxGTK_CONV( GetString(n) ) ); + GetTextExtent( GetString(n), &width, NULL, NULL, NULL, &m_font ); if ( width > ret.x ) ret.x = width; } @@ -477,7 +474,7 @@ wxSize wxChoice::DoGetBestSize() const if ( ret.x < 80 ) ret.x = 80; - ret.y = 16 + gdk_char_height(GET_STYLE_FONT( m_widget->style ), 'H' ); + ret.y = 16 + GetCharHeight(); return ret; } diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp index ee0cc2e8d5..8ed30aed10 100644 --- a/src/gtk1/combobox.cpp +++ b/src/gtk1/combobox.cpp @@ -750,13 +750,11 @@ wxSize wxComboBox::DoGetBestSize() const ret.x = 0; if ( m_widget ) { - GdkFont *font = m_font.GetInternalFont(); - - wxCoord width; - size_t count = Number(); + int width; + size_t count = GetCount(); for ( size_t n = 0; n < count; n++ ) { - width = (wxCoord)gdk_string_width(font, wxGTK_CONV( GetString(n) ) ); + GetTextExtent( GetString(n), &width, NULL, NULL, NULL, &m_font ); if ( width > ret.x ) ret.x = width; } diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index a1a1b15680..2ef77d4f3b 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -1436,27 +1436,56 @@ void wxWindowDC::DoDrawText( const wxString &text, wxCoord x, wxCoord y ) #ifdef __WXGTK20__ // TODO: the layout engine should be abstracted at a higher level! PangoLayout *layout = pango_layout_new(m_context); - pango_layout_set_font_description(layout, m_fontdesc); - { -#if wxUSE_UNICODE - const wxCharBuffer data = wxConvUTF8.cWC2MB( text ); - pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data )); -#else - const wxWCharBuffer wdata = wxConvLocal.cMB2WC( text ); - const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); - pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data )); -#endif - } - // Measure layout. +#if wxUSE_UNICODE + const wxCharBuffer data = wxConvUTF8.cWC2MB( text ); +#else + const wxWCharBuffer wdata = wxConvLocal.cMB2WC( text ); + const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); +#endif + + pango_layout_set_text( layout, (const char*)data, strlen((const char*)data) ); + + if (m_scaleY != 1.0) + { + // If there is a user or actually any scale applied to + // the device context, scale the font. + + // scale font description + gint oldSize = pango_font_description_get_size( m_fontdesc ); + double size = oldSize; + size = size * m_scaleY; + pango_font_description_set_size( m_fontdesc, (gint)size ); + + // actually apply scaled font + pango_layout_set_font_description( layout, m_fontdesc ); + + // Draw layout. + gdk_draw_layout( m_window, m_textGC, x, y, layout ); + + // reset unscaled size + pango_font_description_set_size( m_fontdesc, oldSize ); + } + else + { + // actually apply font + pango_layout_set_font_description( layout, m_fontdesc ); + + // Draw layout. + gdk_draw_layout( m_window, m_textGC, x, y, layout ); + } + +#if 0 + // Measure layout int w,h; - pango_layout_get_pixel_size(layout, &w, &h); + pango_layout_get_pixel_size( m_layout, &w, &h ); +#else + int w = 10; + int h = 10; +#endif wxCoord width = w; wxCoord height = h; - - // Draw layout. - gdk_draw_layout( m_window, m_textGC, x, y, layout ); - + g_object_unref( G_OBJECT( layout ) ); #else // GTK+ 1.x wxCoord width = gdk_string_width( font, text.mbc_str() ); @@ -1614,25 +1643,24 @@ void wxWindowDC::DoGetTextExtent(const wxString &string, #ifdef __WXGTK20__ // Create layout and set font description - PangoLayout *layout = pango_layout_new(m_context); + PangoLayout *layout = pango_layout_new( m_context ); if (theFont) pango_layout_set_font_description( layout, theFont->GetNativeFontInfo()->description ); else - pango_layout_set_font_description(layout, m_fontdesc); + pango_layout_set_font_description( layout, m_fontdesc ); // Set layout's text #if wxUSE_UNICODE - const wxCharBuffer data = wxConvUTF8.cWC2MB( string ); - pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data )); + const wxCharBuffer data = wxConvUTF8.cWC2MB( string ); #else - const wxWCharBuffer wdata = wxConvLocal.cMB2WC( string ); - const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); - pango_layout_set_text(layout, (const char*) data, strlen( (const char*) data )); + const wxWCharBuffer wdata = wxConvLocal.cMB2WC( string ); + const wxCharBuffer data = wxConvUTF8.cWC2MB( wdata ); #endif + pango_layout_set_text( layout, (const char*) data, strlen((const char*)data) ); // Measure text. int w,h; - pango_layout_get_pixel_size(layout, &w, &h); + pango_layout_get_pixel_size( layout, &w, &h ); if (width) (*width) = (wxCoord) w; if (height) (*height) = (wxCoord) h; @@ -1681,7 +1709,7 @@ wxCoord wxWindowDC::GetCharHeight() const // There should be an easier way. PangoLayout *layout = pango_layout_new(m_context); pango_layout_set_font_description(layout, m_fontdesc); - pango_layout_set_text(layout, "H", 1 ); + pango_layout_set_text(layout, "H", 1); int w,h; pango_layout_get_pixel_size(layout, &w, &h); g_object_unref( G_OBJECT( layout ) ); diff --git a/src/gtk1/fontdlg.cpp b/src/gtk1/fontdlg.cpp index 3dfb008131..244094a850 100644 --- a/src/gtk1/fontdlg.cpp +++ b/src/gtk1/fontdlg.cpp @@ -64,6 +64,8 @@ void gtk_fontdialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFontDialog *dial wxapp_install_idle_handler(); GtkFontSelectionDialog *fontdlg = GTK_FONT_SELECTION_DIALOG(dialog->m_widget); + +#ifndef __WXGTK20__ GdkFont *gfont = gtk_font_selection_dialog_get_font(fontdlg); if (!gfont) @@ -72,13 +74,10 @@ void gtk_fontdialog_ok_callback( GtkWidget *WXUNUSED(widget), wxFontDialog *dial wxOK | wxICON_ERROR); return; } +#endif - gchar *fontname = gtk_font_selection_dialog_get_font_name(fontdlg); - - // printf( "font %s\n", fontname ); - + gchar *fontname = gtk_font_selection_dialog_get_font_name( fontdlg ); dialog->SetChosenFont( fontname); - g_free( fontname ); wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK); diff --git a/src/gtk1/menu.cpp b/src/gtk1/menu.cpp index af7bc81726..35a39ee5b7 100644 --- a/src/gtk1/menu.cpp +++ b/src/gtk1/menu.cpp @@ -145,7 +145,7 @@ static wxString wxReplaceUnderscore( const wxString& title ) #endif else { -#if __WXGTK12__ +#ifdef __WXGTK12__ if ( *pc == wxT('_') ) { // underscores must be doubled to prevent them from being @@ -907,7 +907,7 @@ void wxMenuItem::DoSetText( const wxString& str ) #if GTK_CHECK_VERSION(2, 0, 0) else if ( *pc == wxT('_') ) // escape underscores { - // m_text << wxT("__"); doesn't work + m_text << wxT("__"); } else if (*pc == wxT('/')) // we have to escape slashes { @@ -1010,8 +1010,12 @@ wxString wxMenuItem::GetFactoryPath() const { if ( *pc == wxT('_') ) { +#ifdef __WXGTK20__ + pc++; +#else // remove '_' unconditionally continue; +#endif } // don't remove ampersands '&' since if we have them in the menu item title diff --git a/src/gtk1/minifram.cpp b/src/gtk1/minifram.cpp index 2e98dd832e..c23782237b 100644 --- a/src/gtk1/minifram.cpp +++ b/src/gtk1/minifram.cpp @@ -82,28 +82,28 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g 0, 0, win->m_width, win->m_height ); - if (!win->m_title.IsEmpty() && + if (!win->GetTitle().IsEmpty() && ((win->GetWindowStyle() & wxCAPTION) || (win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) || (win->GetWindowStyle() & wxTINY_CAPTION_VERT))) { + wxClientDC dc(win); + dc.SetFont( *wxSMALL_FONT ); + int height = dc.GetCharHeight(); + GdkGC *gc = gdk_gc_new( pizza->bin_window ); - GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0); - gdk_gc_set_foreground( gc, &widget->style->bg[GTK_STATE_SELECTED] ); gdk_draw_rectangle( pizza->bin_window, gc, TRUE, 3, 3, win->m_width - 7, - font->ascent + font->descent+1 ); - - gdk_gc_set_foreground( gc, &widget->style->fg[GTK_STATE_SELECTED] ); - gdk_draw_string( pizza->bin_window, font, gc, - 6, - 3+font->ascent, - wxGTK_CONV( win->m_title ) ); - + height+1 ); gdk_gc_unref( gc ); + + // Hack alert + dc.m_window = pizza->bin_window; + dc.SetTextForeground( *wxWHITE ); + dc.DrawText( win->GetTitle(), 6, 3 ); } } @@ -111,6 +111,7 @@ static void gtk_window_own_expose_callback( GtkWidget *widget, GdkEventExpose *g // "draw" of m_mainWidget //----------------------------------------------------------------------------- +#ifndef __WXGTK20__ static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNUSED(rect), wxFrame *win ) { if (g_isIdle) wxapp_install_idle_handler(); @@ -131,25 +132,26 @@ static void gtk_window_own_draw_callback( GtkWidget *widget, GdkRectangle *WXUNU (win->GetWindowStyle() & wxTINY_CAPTION_HORIZ) || (win->GetWindowStyle() & wxTINY_CAPTION_VERT))) { + wxClientDC dc(win); + dc.SetFont( *wxSMALL_FONT ); + int height = dc.GetCharHeight(); + GdkGC *gc = gdk_gc_new( pizza->bin_window ); - GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0); - gdk_gc_set_foreground( gc, &widget->style->bg[GTK_STATE_SELECTED] ); gdk_draw_rectangle( pizza->bin_window, gc, TRUE, 3, 3, win->m_width - 7, - font->ascent + font->descent+1 ); - - gdk_gc_set_foreground( gc, &widget->style->fg[GTK_STATE_SELECTED] ); - gdk_draw_string( pizza->bin_window, font, gc, - 6, - 3+font->ascent, - wxGTK_CONV( win->m_title ) ); - + height+1 ); gdk_gc_unref( gc ); + + // Hack alert + dc.m_window = pizza->bin_window; + dc.SetTextForeground( *wxWHITE ); + dc.DrawText( win->GetTitle(), 6, 3 ); } } +#endif //----------------------------------------------------------------------------- // "button_press_event" of m_mainWidget @@ -167,9 +169,11 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton GtkPizza *pizza = GTK_PIZZA(widget); if (gdk_event->window != pizza->bin_window) return TRUE; + + wxClientDC dc(win); + dc.SetFont( *wxSMALL_FONT ); + int height = dc.GetCharHeight() + 1; - GdkFont *font = wxSMALL_FONT->GetInternalFont(1.0); - int height = font->ascent + font->descent+1; if (gdk_event->y > height) return TRUE; gdk_window_raise( win->m_widget->window ); @@ -364,8 +368,10 @@ bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title gtk_signal_connect( GTK_OBJECT(m_mainWidget), "expose_event", GTK_SIGNAL_FUNC(gtk_window_own_expose_callback), (gpointer)this ); +#ifndef __WXGTK20__ gtk_signal_connect( GTK_OBJECT(m_mainWidget), "draw", GTK_SIGNAL_FUNC(gtk_window_own_draw_callback), (gpointer)this ); +#endif /* these are required for dragging the mini frame around */ gtk_signal_connect( GTK_OBJECT(m_mainWidget), "button_press_event", diff --git a/src/gtk1/settings.cpp b/src/gtk1/settings.cpp index 736ed76aba..227599ef0b 100644 --- a/src/gtk1/settings.cpp +++ b/src/gtk1/settings.cpp @@ -328,21 +328,8 @@ wxFont wxSystemSettingsNative::GetFont( wxSystemFont index ) if (!g_systemFont) { #ifdef __WXGTK20__ - GtkWidget *widget = gtk_button_new(); - GtkStyle *def = gtk_rc_get_style( widget ); - if (!def) - def = gtk_widget_get_default_style(); - if (def) - { - wxNativeFontInfo info; - info.description = def->font_desc; - g_systemFont = new wxFont(info); - } - else - { - g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); - } - gtk_widget_destroy( widget ); + const gchar *font_name = _gtk_rc_context_get_default_font_name (gtk_settings_get_default ()); + g_systemFont = new wxFont( wxString::FromAscii( font_name ) ); #else g_systemFont = new wxFont( 12, wxSWISS, wxNORMAL, wxNORMAL ); #endif diff --git a/src/gtk1/tbargtk.cpp b/src/gtk1/tbargtk.cpp index d05f2cddfb..2ce4bc754c 100644 --- a/src/gtk1/tbargtk.cpp +++ b/src/gtk1/tbargtk.cpp @@ -343,8 +343,6 @@ bool wxToolBar::Create( wxWindow *parent, g_style->bg[GTK_STATE_NORMAL] = *m_bg; - SET_STYLE_FONT(g_style, GtkGetDefaultGuiFont()); - gtk_widget_set_style( GTK_TOOLBAR(m_toolbar)->tooltips->tip_window, g_style ); m_parent->DoAddChild( this ); diff --git a/src/gtk1/tooltip.cpp b/src/gtk1/tooltip.cpp index d6577bfb93..a8e42e4d07 100644 --- a/src/gtk1/tooltip.cpp +++ b/src/gtk1/tooltip.cpp @@ -76,8 +76,6 @@ void wxToolTip::Apply( wxWindow *win ) g_style->fg[GTK_STATE_NORMAL] = ss_fg; g_style->bg[GTK_STATE_NORMAL] = ss_bg; - SET_STYLE_FONT( g_style, GtkGetDefaultGuiFont() ); - gtk_widget_set_style( ss_tooltips->tip_window, g_style ); #else // GTK+ 1.0 gtk_tooltips_set_colors( ss_tooltips, &ss_bg, &ss_fg ); diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 36b4fbc8e9..fcf2a95580 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -1695,6 +1695,20 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, wxPrintf( wxT(".\n") ); */ +#ifndef __WXGTK20__ + if (event_type == wxEVT_LEFT_DCLICK) + { + // GTK 1.2 crashes when intercepting double + // click events from both wxSpinButton and + // wxSpinCtrl + if (GTK_IS_SPIN_BUTTON(win->m_widget)) + { + // Just disable this event for now. + return FALSE; + } + } +#endif + if (win->GetEventHandler()->ProcessEvent( event )) { gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "button_press_event" ); @@ -3406,9 +3420,31 @@ int wxWindowGTK::GetCharHeight() const wxCHECK_MSG( m_font.Ok(), 12, wxT("invalid font") ); +#ifdef __WXGTK20__ + PangoContext *context = NULL; + if (m_widget) + context = gtk_widget_get_pango_context( m_widget ); + + if (!context) + return 0; + + PangoFontDescription *desc = m_font.GetNativeFontInfo()->description; + PangoLayout *layout = pango_layout_new(context); + pango_layout_set_font_description(layout, desc); + pango_layout_set_text(layout, "H", 1); + PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data; + + PangoRectangle rect; + pango_layout_line_get_extents(line, NULL, &rect); + + g_object_unref( G_OBJECT( layout ) ); + + return (int) (rect.height / PANGO_SCALE); +#else GdkFont *font = m_font.GetInternalFont( 1.0 ); return font->ascent + font->descent; +#endif } int wxWindowGTK::GetCharWidth() const @@ -3417,9 +3453,31 @@ int wxWindowGTK::GetCharWidth() const wxCHECK_MSG( m_font.Ok(), 8, wxT("invalid font") ); +#ifdef __WXGTK20__ + PangoContext *context = NULL; + if (m_widget) + context = gtk_widget_get_pango_context( m_widget ); + + if (!context) + return 0; + + PangoFontDescription *desc = m_font.GetNativeFontInfo()->description; + PangoLayout *layout = pango_layout_new(context); + pango_layout_set_font_description(layout, desc); + pango_layout_set_text(layout, "H", 1); + PangoLayoutLine *line = (PangoLayoutLine *)pango_layout_get_lines(layout)->data; + + PangoRectangle rect; + pango_layout_line_get_extents(line, NULL, &rect); + + g_object_unref( G_OBJECT( layout ) ); + + return (int) (rect.width / PANGO_SCALE); +#else GdkFont *font = m_font.GetInternalFont( 1.0 ); return gdk_string_width( font, "H" ); +#endif } void wxWindowGTK::GetTextExtent( const wxString& string, @@ -4089,7 +4147,13 @@ void wxWindowGTK::SetWidgetStyle() if (m_font != wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT )) { - SET_STYLE_FONT(style, m_font.GetInternalFont( 1.0 )); +#ifdef __WXGTK20__ + pango_font_description_free( style->font_desc ); + pango_font_description_copy( m_font.GetNativeFontInfo()->description ); +#else + gdk_font_unref( style->font ); + style->font = gdk_font_ref( m_font.GetInternalFont( 1.0 ) ); +#endif } if (m_foregroundColour.Ok()) diff --git a/src/unix/fontutil.cpp b/src/unix/fontutil.cpp index 5cb5e28a95..66e893e602 100644 --- a/src/unix/fontutil.cpp +++ b/src/unix/fontutil.cpp @@ -132,26 +132,30 @@ wxFontEncoding wxNativeFontInfo::GetEncoding() const return wxFONTENCODING_SYSTEM; } -bool wxNativeFontInfo::FromString(const wxString& s) +bool wxNativeFontInfo::FromString( const wxString& str ) { if (description) pango_font_description_free( description ); - description = pango_font_description_from_string( wxGTK_CONV( s ) ); + description = pango_font_description_from_string( wxGTK_CONV( str ) ); + + // wxPrintf( L"FromString result: %s\n", ToString().c_str() ); return TRUE; } wxString wxNativeFontInfo::ToString() const { - wxString tmp = wxGTK_CONV_BACK( pango_font_description_to_string( description ) ); + char *str = pango_font_description_to_string( description ); + wxString tmp = wxGTK_CONV_BACK( str ); + g_free( str ); return tmp; } -bool wxNativeFontInfo::FromUserString(const wxString& s) +bool wxNativeFontInfo::FromUserString( const wxString& str ) { - return FromString( s ); + return FromString( str ); } wxString wxNativeFontInfo::ToUserString() const