diff options
author | Dave Davenport <qball@blame.services> | 2022-07-16 13:13:29 +0200 |
---|---|---|
committer | Dave Davenport <qball@blame.services> | 2022-07-16 13:13:29 +0200 |
commit | 52f587a1918a69010e93b0a9c720728f02ed5f79 (patch) | |
tree | 45b31ed8297d06205a7b62c9cf582937451773b5 | |
parent | 386877dd228adb4f4cdb6cb3d8a9900439582e64 (diff) |
[IconFetcher] Add support for font rendering as icon.
Issue: #1132
-rw-r--r-- | doc/rofi.1 | 48 | ||||
-rw-r--r-- | doc/rofi.1.markdown | 28 | ||||
-rw-r--r-- | source/rofi-icon-fetcher.c | 4 |
3 files changed, 78 insertions, 2 deletions
@@ -1328,6 +1328,54 @@ modes are shown, even if the rest of the input text would match results from \fB If no match, the input is handled by the first combined modes. .SH FAQ +.SS What icon formats are supported +.PP +Rofi supports 3 ways of specifying an icon: + +.RS +.IP \(bu 2 +Filename +.IP \(bu 2 +icon-name, this is looked up via the icon-theme. +.IP \(bu 2 +Markup String. It renders a string as an icon. + +.RE + +.PP +For the first two options, GdkPixbuf is used to open and render the icons. +This in general gives support for most required image formats. +For the string option it uses Pango to render the string. The string needs to +start with a \fB\fC<span\fR tag, that allows you to set color and font. + +.PP +Markup string: + +.PP +.RS + +.nf +echo -en "testing\\0icon\\x1f<span color='red'>⏻</span>" | ./rofi -dmenu + +.fi +.RE + +.PP +Getting supported icon formats: + +.PP +.RS + +.nf +G_MESSAGES_DEBUG=Helpers.IconFetcher rofi + +.fi +.RE + +.PP +This uses the debug framework and prints out a list of supported image file +extensions. + .SS The text in the window switcher is not nicely aligned. .PP Try using a mono-space font. diff --git a/doc/rofi.1.markdown b/doc/rofi.1.markdown index 91c844df..8c2c92f9 100644 --- a/doc/rofi.1.markdown +++ b/doc/rofi.1.markdown @@ -857,6 +857,34 @@ If no match, the input is handled by the first combined modes. ## FAQ +### What icon formats are supported + +Rofi supports 3 ways of specifying an icon: + +* Filename +* icon-name, this is looked up via the icon-theme. +* Markup String. It renders a string as an icon. + + +For the first two options, GdkPixbuf is used to open and render the icons. +This in general gives support for most required image formats. +For the string option it uses Pango to render the string. The string needs to +start with a `<span` tag, that allows you to set color and font. + +Markup string: + +```bash +echo -en "testing\0icon\x1f<span color='red'>⏻</span>" | ./rofi -dmenu +``` + +Getting supported icon formats: + +```bash +G_MESSAGES_DEBUG=Helpers.IconFetcher rofi +``` +This uses the debug framework and prints out a list of supported image file +extensions. + ### The text in the window switcher is not nicely aligned. Try using a mono-space font. diff --git a/source/rofi-icon-fetcher.c b/source/rofi-icon-fetcher.c index 03e5ac9c..8e3fe6a7 100644 --- a/source/rofi-icon-fetcher.c +++ b/source/rofi-icon-fetcher.c @@ -294,12 +294,12 @@ static void rofi_icon_fetcher_worker(thread_state *sdata, if (g_path_is_absolute(sentry->entry->name)) { icon_path = sentry->entry->name; - } else if (g_str_has_prefix(sentry->entry->name, "font:")) { + } else if (g_str_has_prefix(sentry->entry->name, "<span")) { cairo_surface_t *surface = cairo_image_surface_create( CAIRO_FORMAT_ARGB32, sentry->wsize, sentry->hsize); cairo_t *cr = cairo_create(surface); PangoLayout *layout = pango_cairo_create_layout(cr); - pango_layout_set_text(layout, &sentry->entry->name[5], -1); + pango_layout_set_markup(layout, sentry->entry->name, -1); int width, height; pango_layout_get_size(layout, &width, &height); |