Skip to content

Instantly share code, notes, and snippets.

@pfpacket
Last active August 29, 2015 14:05
Show Gist options
  • Save pfpacket/164f553c79653be4f206 to your computer and use it in GitHub Desktop.
Save pfpacket/164f553c79653be4f206 to your computer and use it in GitHub Desktop.
weston: title fonts
diff --git a/man/weston.ini.man b/man/weston.ini.man
index ccd7185..c0f5101 100644
--- a/man/weston.ini.man
+++ b/man/weston.ini.man
@@ -260,6 +260,9 @@ sets the path to lock screen background image (string). (tablet shell only)
.TP 7
.BI "homescreen=" path
sets the path to home screen background image (string). (tablet shell only)
+.TP 7
+.BI "font=" fontname
+set the font family name. Title font only supported now.
.RE
.SH "LAUNCHER SECTION"
There can be multiple launcher sections, one for each launcher.
diff --git a/shared/cairo-util.c b/shared/cairo-util.c
index 26286c5..f5baa56 100644
--- a/shared/cairo-util.c
+++ b/shared/cairo-util.c
@@ -337,6 +337,18 @@ theme_set_background_source(struct theme *t, cairo_t *cr, uint32_t flags)
}
}
+char *
+config_get_font_name()
+{
+ char *font_name;
+ struct weston_config *config
+ = weston_config_parse("weston.ini");
+ struct weston_config_section *section
+ = weston_config_get_section(config, "shell", NULL, NULL);
+ weston_config_section_get_string(section, "font", &font_name, "sans");
+ return font_name;
+}
+
struct theme *
theme_create(void)
{
@@ -350,6 +362,7 @@ theme_create(void)
t->margin = 32;
t->width = 6;
t->titlebar_height = 27;
+ t->title_font = config_get_font_name();
t->frame_radius = 3;
t->shadow = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 128, 128);
cr = cairo_create(t->shadow);
@@ -408,6 +421,7 @@ theme_destroy(struct theme *t)
cairo_surface_destroy(t->active_frame);
cairo_surface_destroy(t->inactive_frame);
cairo_surface_destroy(t->shadow);
+ free(t->title_font);
free(t);
}
@@ -458,7 +472,7 @@ theme_render_frame(struct theme *t,
cairo_clip(cr);
cairo_set_operator(cr, CAIRO_OPERATOR_OVER);
- cairo_select_font_face(cr, "sans",
+ cairo_select_font_face(cr, t->title_font,
CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size(cr, 14);
diff --git a/shared/cairo-util.h b/shared/cairo-util.h
index fb25c34..060e01b 100644
--- a/shared/cairo-util.h
+++ b/shared/cairo-util.h
@@ -53,6 +53,7 @@ struct theme {
int margin;
int width;
int titlebar_height;
+ char *title_font;
};
struct theme *
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment