summaryrefslogtreecommitdiff
path: root/app/wlib/gtklib/font.c
diff options
context:
space:
mode:
Diffstat (limited to 'app/wlib/gtklib/font.c')
-rw-r--r--app/wlib/gtklib/font.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/app/wlib/gtklib/font.c b/app/wlib/gtklib/font.c
index c54f7de..68ba87b 100644
--- a/app/wlib/gtklib/font.c
+++ b/app/wlib/gtklib/font.c
@@ -86,7 +86,7 @@ static void fontSelectionDialogCallback(GtkFontSelectionDialog
*fontSelectionDialog, gint response, gpointer data)
{
if (response == GTK_RESPONSE_APPLY || response == GTK_RESPONSE_OK) {
- gchar *fontName;
+ gchar *fontName;
fontName = gtk_font_selection_dialog_get_font_name(fontSelectionDialog);
wPrefSetString("font", "name", fontName);
@@ -215,12 +215,14 @@ PangoLayout *wlibFontCreatePangoLayout(GtkWidget *widget,
pango_layout_set_font_description(layout, fontDescription);
/* get layout measures */
pango_layout_get_pixel_size(layout, width_p, height_p);
- context = gtk_widget_get_pango_context(widget);
+ context = gtk_widget_create_pango_context(widget);
metrics = pango_context_get_metrics(context, fontDescription,
pango_context_get_language(context));
*ascent_p = PANGO_PIXELS(pango_font_metrics_get_ascent(metrics));
*descent_p = PANGO_PIXELS(pango_font_metrics_get_descent(metrics));
pango_font_metrics_unref(metrics);
+ g_object_ref_sink(context);
+ g_object_unref(context);
#if WLIB_FONT_DEBUG >= 3
fprintf(stderr, "font layout created:\n");
fprintf(stderr, " widget: %p\n", widget);
@@ -242,7 +244,8 @@ PangoLayout *wlibFontCreatePangoLayout(GtkWidget *widget,
void wlibFontDestroyPangoLayout(PangoLayout *layout)
{
- g_object_unref(G_OBJECT(layout));
+ g_object_ref_sink(layout);
+ g_object_unref(layout);
}
/**
@@ -286,7 +289,7 @@ void wSelectFont(
gtk_window_set_title(GTK_WINDOW(fontSelectionDialog), title);
if (curFont != NULL) {
- gchar *fontName;
+ gchar *fontName;
/* the curFont description contains the latest font info
* which is depended on the current scale