Skip to content
Myr

Merge branch 'text-shaping'

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

Closes #20

authored by Daniel Eklöf · committed by Daniel Eklöf · parents 3e20f5e, bff1475 · Browse files · 5 files+66 added−15 removed
This commit

State

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

Diff stats

5 files+66 added−15 removed

  • other:+66 added−15 removed

5 files+66 added−15 removed

modified:application.c+2 added
244 unmodified lines
245 g_object_unref(app->icon.svg);246#endif247 break;248 }249250 fcft_text_run_destroy(app->shaped);251 }252 free(apps->v);253 free(apps);254}
modified:application.h+3 added
5 unmodified lines
6#if defined(FUZZEL_ENABLE_SVG)7 #include <librsvg/rsvg.h>8#endif910#include <fcft/fcft.h>1112#include "prompt.h"1314enum icon_type { ICON_NONE, ICON_PNG, ICON_SVG };15
16 unmodified lines
32 wchar_t *title;33 wchar_t *comment;34 struct icon icon;35 unsigned count;36 struct fcft_text_run *shaped;37};3839bool application_execute(40 const struct application *app, const struct prompt *prompt);
8 unmodified lines
modified:CHANGELOG.md+8 added
modified:meson.build+1 added-1 removed
76 unmodified lines
77 add_project_arguments('-DFUZZEL_ENABLE_SVG=1', language: 'c')78endif7980tllist = dependency('tllist', version: '>=1.0.1', fallback: 'tllist')81fcft = dependency('fcft', version: ['>=2.3.90', '<3.0.0'], fallback: 'fcft')81fcft = dependency('fcft', version: ['>=2.4.0Q', '<3.0.0'], fallback: 'fcft')8283wayland_protocols_datadir = wayland_protocols.get_pkgconfig_variable('pkgdatadir')8485wscanner = dependency('wayland-scanner', native: true)
75 unmodified lines
modified:render.c+52 added-14 removed
203 unmodified lines
204render_match_text(struct buffer *buf, double *_x, double _y,205 const wchar_t *text, ssize_t start, size_t length,206 struct fcft_font *font, enum fcft_subpixel subpixel,207 int letter_spacing,208 pixman_color_t regular_color, pixman_color_t match_color)208 pixman_color_t regular_color, pixman_color_t match_color,209 struct fcft_text_run **run)210{211 int x = *_x;212 int y = _y;213213 for (size_t i = 0; i < wcslen(text); i++) {214 const struct fcft_glyph *glyph = fcft_glyph_rasterize(font, text[i], subpixel);215 if (glyph == NULL)216 continue;214 const struct fcft_glyph **glyphs = NULL;215 int *clusters = NULL;216 long *kern = NULL;217 size_t count = 0;218218 long x_kern = 0, y_kern = 0;219 if (i > 0)220 fcft_kerning(font, text[i - 1], text[i], &x_kern, &y_kern);219 if (*run == NULL &&220 (fcft_capabilities() & FCFT_CAPABILITY_TEXT_RUN_SHAPING))221 {222 *run = fcft_text_run_rasterize(font, wcslen(text), text, subpixel);223 }224222 bool is_match = start >= 0 && i >= start && i < start + length;223 x += x_kern;224 render_glyph(buf->pix, glyph, x, y + y_kern, is_match ? &match_color : &regular_color);225 x += glyph->advance.x;226 x += letter_spacing;225 if (*run != NULL) {226 glyphs = (*run)->glyphs;227 clusters = (*run)->cluster;228 count = (*run)->count;229 } else {230 count = wcslen(text);231 glyphs = malloc(count * sizeof(glyphs[0]));232 clusters = malloc(count * sizeof(clusters[0]));233 kern = malloc(count * sizeof(kern[0]));234235 for (size_t i = 0; i < count; i++) {236 const struct fcft_glyph *glyph = fcft_glyph_rasterize(font, text[i], subpixel);237 if (glyph == NULL) {238 glyphs[i] = NULL;239 continue;240 }241242 if (i > 0)243 fcft_kerning(font, text[i - 1], text[i], &kern[i], NULL);244 else245 kern[i] = 0;246247 glyphs[i] = glyph;248 clusters[i] = i;249 }250 }251252 for (size_t i = 0; i < count; i++) {253 bool is_match = start >= 0 && clusters[i] >= start && clusters[i] < start + length;254 x += kern != NULL ? kern[i] : 0;255 render_glyph(buf->pix, glyphs[i], x, y, is_match ? &match_color : &regular_color);256 x += glyphs[i]->advance.x + letter_spacing;257 y += glyphs[i]->advance.y;258 }259260 if (*run == NULL) {261 free(kern);262 free(clusters);263 free(glyphs);264 }265266 *_x = x;267}268269void
205 unmodified lines
475 buf, &cur_x, y,476 match->application->title, match->start_title, wcslen(prompt_text(prompt)),477 font, subpixel,478 pt_or_px_as_pixels(&render->options.letter_spacing, render->dpi),442 render->options.pix_text_color, render->options.pix_match_color);479 render->options.pix_text_color, render->options.pix_match_color,480 &match->application->shaped);481482 y += row_height;483 }484}
97 unmodified lines