Skip to content
Myr

render: apply font shaping to the prompt

Before adoption: this commit came in with the history the project adopted, so no landing records it.

If fcft is text-run capable, use fcft_rasterize_text_run_utf32() to shape the prompt. With this, we can now render prompts like 👩🏽‍🚀 correctly.

authored by Daniel Eklöf · committed by Daniel Eklöf · parent a563ee6 · Browse files · 2 files+29 added−1 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+29 added−1 removed

  • other:+29 added−1 removed

2 files+29 added−1 removed

modified:CHANGELOG.md+1 added
52 unmodified lines
53 mode, as long as `--no-run-if-empty` is **not** being used54 ([#106][106]).55* Improved performance of initial rendering of icons ([#124][124]).56* `--terminal` now defaults to `$TERMINAL -e`.57* Font shaping is now applied to the prompt5859[101]: https://codeberg.org/dnkl/fuzzel/issues/10160[106]: https://codeberg.org/dnkl/fuzzel/issues/10661[124]: https://codeberg.org/dnkl/fuzzel/issues/124
318 unmodified lines
modified:render.c+28 added-1 removed
184 unmodified lines
185186 const struct config *conf = render->conf;187188 const char32_t *pprompt = prompt_prompt(prompt);189 const size_t prompt_len = c32len(pprompt);189 size_t prompt_len = c32len(pprompt);190191 const char32_t *ptext = prompt_text(prompt);192 const size_t text_len = c32len(ptext);193
4 unmodified lines
198199 int x = render->border_size + render->x_margin;200 int y = render->border_size + render->y_margin + font->ascent;201202 if (fcft_capabilities() & FCFT_CAPABILITY_TEXT_RUN_SHAPING) {203 struct fcft_text_run *run = fcft_rasterize_text_run_utf32(204 font, prompt_len, pprompt, subpixel);205206 if (run != NULL) {207 for (size_t i = 0; i < run->count; i++) {208 const struct fcft_glyph *glyph = run->glyphs[i];209 render_glyph(buf->pix, glyph, x, y, &render->pix_text_color);210 x += glyph->advance.x;211 }212 fcft_text_run_destroy(run);213214 /* Cursor, if right after the prompt. In all other cases,215 * the cursor will be rendered by the loop below */216 if (prompt_cursor(prompt) == 0) {217 pixman_image_fill_rectangles(218 PIXMAN_OP_SRC, buf->pix, &render->pix_text_color,219 1, &(pixman_rectangle16_t){220 x, y - font->ascent,221 font->underline.thickness, font->ascent + font->descent});222 }223224 /* Prevent loop below from rendering the prompt */;225 prompt_len = 0;226 }227 }228229 char32_t prev = 0;230231 for (size_t i = 0; i < prompt_len + text_len; i++) {232 char32_t wc = i < prompt_len
583 unmodified lines