1
0
Fork 0
mirror of https://github.com/davatorium/rofi.git synced 2024-11-18 13:54:36 -05:00

[IconFetcher] Add support for font rendering as icon.

Issue: #1132
This commit is contained in:
Dave Davenport 2022-07-16 13:13:29 +02:00
parent 386877dd22
commit 52f587a191
3 changed files with 78 additions and 2 deletions

View file

@ -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.

View file

@ -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.

View file

@ -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);