[gnome-builder] editor: use custom BuilderBlocks font for overview map



commit ee8b7af50b9df3aa9ae47976e8b56e6b95c3119b
Author: Christian Hergert <chergert redhat com>
Date:   Sun Oct 11 16:14:56 2015 -0400

    editor: use custom BuilderBlocks font for overview map

 Makefile.am                                        |    4 ++
 configure.ac                                       |    1 +
 data/Makefile.am                                   |    2 +-
 data/fonts/BuilderBlocks.ttf                       |  Bin 0 -> 388 bytes
 .../{builder-blocks.ttx => BuilderBlocks.ttx}      |    6 +++
 data/fonts/Makefile.am                             |    6 +++
 data/fonts/builder-blocks.ttf                      |  Bin 340 -> 0 bytes
 src/editor/gb-editor-map-bin.c                     |   34 +++++++++++++++++++-
 8 files changed, 51 insertions(+), 2 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 78d1047..48e783e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -72,18 +72,21 @@ dist-hook:
 
 run:
        GB_IN_TREE_PLUGINS=1 \
+       GB_IN_TREE_FONTS=1 \
        GI_TYPELIB_PATH="libide:src:$(GI_TYPELIB_PATH)" \
        GOBJECT_DEBUG=instance-count \
        $(LIBTOOL) --mode=execute gdb -ex run --args src/gnome-builder -vvvv -s
 
 strace:
        GB_IN_TREE_PLUGINS=1 \
+       GB_IN_TREE_FONTS=1 \
        GI_TYPELIB_PATH="libide:src:$(GI_TYPELIB_PATH)" \
        GOBJECT_DEBUG=instance-count \
        $(LIBTOOL) --mode=execute strace -T src/gnome-builder -vvvv -s
 
 debug:
        GB_IN_TREE_PLUGINS=1 \
+       GB_IN_TREE_FONTS=1 \
        GI_TYPELIB_PATH="libide:src:$(GI_TYPELIB_PATH)" \
        G_DEBUG=fatal-criticals \
        GOBJECT_DEBUG=instance-count \
@@ -91,6 +94,7 @@ debug:
 
 valgrind:
        GB_IN_TREE_PLUGINS=1 \
+       GB_IN_TREE_FONTS=1 \
        GI_TYPELIB_PATH="libide:src:$(GI_TYPELIB_PATH)" \
        G_DEBUG=fatal-criticals \
        G_SLICE=always-malloc \
diff --git a/configure.ac b/configure.ac
index 9a5a229..b72c2aa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -427,6 +427,7 @@ AC_CONFIG_FILES([
        plugins/fallback/Makefile
 
        data/Makefile
+       data/fonts/Makefile
        data/gsettings/org.gnome.builder.code-insight.gschema.xml
        data/gsettings/Makefile
        data/icons/Makefile
diff --git a/data/Makefile.am b/data/Makefile.am
index f558603..24e4bc7 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -1,4 +1,4 @@
-SUBDIRS = gsettings icons style-schemes .
+SUBDIRS = gsettings icons style-schemes fonts .
 
 appdatadir = $(datadir)/appdata
 appdata_DATA = org.gnome.Builder.appdata.xml
diff --git a/data/fonts/BuilderBlocks.ttf b/data/fonts/BuilderBlocks.ttf
new file mode 100644
index 0000000..e7538a8
Binary files /dev/null and b/data/fonts/BuilderBlocks.ttf differ
diff --git a/data/fonts/builder-blocks.ttx b/data/fonts/BuilderBlocks.ttx
similarity index 95%
rename from data/fonts/builder-blocks.ttx
rename to data/fonts/BuilderBlocks.ttx
index 8922146..e3f7b29 100644
--- a/data/fonts/builder-blocks.ttx
+++ b/data/fonts/BuilderBlocks.ttx
@@ -91,6 +91,12 @@
     </TTGlyph>
   </glyf>
 
+  <name>
+    <namerecord nameID="0" platformID="1" platEncID="0" langID="0x0" unicode="True">
+      BuilderBlocks
+    </namerecord>
+  </name>
+
   <cmap ERROR="">
     <!-- Hand-coded format13 table mapping all Unicode
          characters to glyph00001. -->
diff --git a/data/fonts/Makefile.am b/data/fonts/Makefile.am
new file mode 100644
index 0000000..fe07ec3
--- /dev/null
+++ b/data/fonts/Makefile.am
@@ -0,0 +1,6 @@
+fontdir = $(datadir)/gnome-builder/fonts
+dist_font_DATA = \
+       BuilderBlocks.ttf \
+       $(NULL)
+
+-include $(top_srcdir)/git.mk
diff --git a/src/editor/gb-editor-map-bin.c b/src/editor/gb-editor-map-bin.c
index fe10a9e..23c9730 100644
--- a/src/editor/gb-editor-map-bin.c
+++ b/src/editor/gb-editor-map-bin.c
@@ -18,6 +18,7 @@
 
 #include <glib/gi18n.h>
 #include <ide.h>
+#include <pango/pangofc-fontmap.h>
 
 #include "gb-editor-map-bin.h"
 
@@ -38,6 +39,7 @@ enum {
   LAST_PROP
 };
 
+static FcConfig *gLocalFontConfig;
 static GParamSpec *gParamSpecs [LAST_PROP];
 
 static void
@@ -106,7 +108,22 @@ gb_editor_map_bin_add (GtkContainer *container,
   GbEditorMapBin *self = (GbEditorMapBin *)container;
 
   if (IDE_IS_SOURCE_MAP (child) && (self->separator != NULL))
-    gtk_widget_show (GTK_WIDGET (self->separator));
+    {
+      PangoFontMap *font_map;
+      PangoFontDescription *font_desc;
+
+      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), gLocalFontConfig);
+      gtk_widget_set_font_map (child, font_map);
+
+      font_desc = pango_font_description_from_string ("Builder Blocks 1");
+      g_object_set (child, "font-desc", font_desc, NULL);
+
+      g_object_unref (font_map);
+      pango_font_description_free (font_desc);
+
+      gtk_widget_show (GTK_WIDGET (self->separator));
+    }
 
   GTK_CONTAINER_CLASS (gb_editor_map_bin_parent_class)->add (container, child);
 }
@@ -175,6 +192,19 @@ gb_editor_map_bin_set_property (GObject      *object,
 }
 
 static void
+gb_editor_map_bin_load_font (void)
+{
+  const gchar *font_path = PACKAGE_DATADIR"/gnome-builder/fonts/BuilderBlocks.ttf";
+
+  gLocalFontConfig = FcInitLoadConfigAndFonts ();
+
+  if (g_getenv ("GB_IN_TREE_FONTS") != NULL)
+    font_path = "data/fonts/BuilderBlocks.ttf";
+
+  FcConfigAppFontAddFile (gLocalFontConfig, (const FcChar8 *)font_path);
+}
+
+static void
 gb_editor_map_bin_class_init (GbEditorMapBinClass *klass)
 {
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
@@ -198,6 +228,8 @@ gb_editor_map_bin_class_init (GbEditorMapBinClass *klass)
                          (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
   g_object_class_install_properties (object_class, LAST_PROP, gParamSpecs);
+
+  gb_editor_map_bin_load_font ();
 }
 
 static void


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