aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2019-02-01 15:33:44 +0100
committerGerd Hoffmann <kraxel@redhat.com>2019-02-01 15:33:44 +0100
commit0e322a1ab05d5a2bfd35a01592b6bb2303c1cd97 (patch)
tree0f323f4740feffc0b86521547457f93b5b49f172
parent8d5f8b066782f9ac8a95946c8e02bfdcd63a4a36 (diff)
downloadfbida-0e322a1ab05d5a2bfd35a01592b6bb2303c1cd97.tar.gz
dirty fix, parse font name
-rw-r--r--fb-gui.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/fb-gui.c b/fb-gui.c
index 654e369..f8447b7 100644
--- a/fb-gui.c
+++ b/fb-gui.c
@@ -123,7 +123,9 @@ void shadow_set_dirty_range(int y, int h)
{
int i;
- for (i = y; i < y + h; i++)
+ if (y < 0)
+ y = 0;
+ for (i = y; i < y + h && i < sheight; i++)
sdirty[i]++;
}
@@ -302,11 +304,22 @@ void shadow_draw_text_box(int x, int y, int percent, char *lines[], unsigned int
cairo_font_extents_t *shadow_font_init(char *font)
{
- /* TODO: parse font */
- cairo_select_font_face(context, "monospace",
+ char fontname[64];
+ int fontsize, rc;
+
+ rc = sscanf(font, "%63[^-]-%d", fontname, &fontsize);
+ if (rc != 2) {
+ rc = sscanf(font, "%63[^:]:size=%d", fontname, &fontsize);
+ if (rc != 2) {
+ strncpy(fontname, font, sizeof(fontname));
+ fontsize = 16;
+ }
+ }
+
+ cairo_select_font_face(context, fontname,
CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
- cairo_set_font_size(context, 16);
+ cairo_set_font_size(context, fontsize);
cairo_font_extents(context, &extents);
return &extents;
}