diff options
author | Gerd Hoffmann <kraxel@redhat.com> | 2019-02-01 15:33:44 +0100 |
---|---|---|
committer | Gerd Hoffmann <kraxel@redhat.com> | 2019-02-01 15:33:44 +0100 |
commit | 0e322a1ab05d5a2bfd35a01592b6bb2303c1cd97 (patch) | |
tree | 0f323f4740feffc0b86521547457f93b5b49f172 | |
parent | 8d5f8b066782f9ac8a95946c8e02bfdcd63a4a36 (diff) | |
download | fbida-0e322a1ab05d5a2bfd35a01592b6bb2303c1cd97.tar.gz |
dirty fix, parse font name
-rw-r--r-- | fb-gui.c | 21 |
1 files changed, 17 insertions, 4 deletions
@@ -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; } |