[gnome-builder] editor: fix loading of Builder Blocks font



commit 9fd2ff4bf4bf03e55ceec8fe0109f2fec17e2200
Author: Christian Hergert <chergert redhat com>
Date:   Sat Jul 1 02:42:45 2017 -0700

    editor: fix loading of Builder Blocks font

 libide/editor/ide-editor-view.c |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/libide/editor/ide-editor-view.c b/libide/editor/ide-editor-view.c
index 6d7478c..0a60797 100644
--- a/libide/editor/ide-editor-view.c
+++ b/libide/editor/ide-editor-view.c
@@ -60,13 +60,16 @@ ide_editor_view_load_fonts (IdeEditorView *self)
 
   if (g_once_init_enter (&localFontConfig))
     {
-      const gchar *font_path = PACKAGE_DATADIR"/gnome-builder/fonts/BuilderBlocks.ttf";
+      const gchar *font_path = PACKAGE_DATADIR "/gnome-builder/fonts/BuilderBlocks.ttf";
       FcConfig *config = FcInitLoadConfigAndFonts ();
 
       if (g_getenv ("GB_IN_TREE_FONTS") != NULL)
         font_path = "data/fonts/BuilderBlocks.ttf";
 
-      FcConfigAppFontAddFile (localFontConfig, (const FcChar8 *)font_path);
+      if (!g_file_test (font_path, G_FILE_TEST_IS_REGULAR))
+        g_warning ("Failed to locate \"%s\"", font_path);
+
+      FcConfigAppFontAddFile (config, (const FcChar8 *)font_path);
 
       g_once_init_leave (&localFontConfig, config);
     }
@@ -74,12 +77,16 @@ ide_editor_view_load_fonts (IdeEditorView *self)
   font_map = pango_cairo_font_map_new_for_font_type (CAIRO_FONT_TYPE_FT);
   pango_fc_font_map_set_config (PANGO_FC_FONT_MAP (font_map), localFontConfig);
   gtk_widget_set_font_map (GTK_WIDGET (self->map), font_map);
-
   font_desc = pango_font_description_from_string ("Builder Blocks 1");
+
+  g_assert (localFontConfig != NULL);
+  g_assert (font_map != NULL);
+  g_assert (font_desc != NULL);
+
   g_object_set (self->map, "font-desc", font_desc, NULL);
 
-  g_object_unref (font_map);
   pango_font_description_free (font_desc);
+  g_object_unref (font_map);
 }
 
 static void
@@ -394,6 +401,8 @@ ide_editor_view_constructed (GObject *object)
                             "motion-notify-event",
                             G_CALLBACK (ide_editor_view_source_view_event),
                             self);
+
+  ide_editor_view_load_fonts (self);
 }
 
 static void
@@ -586,7 +595,6 @@ ide_editor_view_init (IdeEditorView *self)
     gtk_target_list_add_uri_targets (target_list, DND_TARGET_URI_LIST);
 
   /* Load our custom font for the overview map. */
-  ide_editor_view_load_fonts (self);
   gtk_source_map_set_view (self->map, GTK_SOURCE_VIEW (self->source_view));
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]