static int _vte_gl_get_char_width(struct _vte_draw *draw, gunichar c, int columns) { struct _vte_gl_data *data = draw->impl_data; const struct _vte_glyph *glyph; glyph = _vte_glyph_get(data->cache, c); if (glyph == NULL) return 0; return glyph->width; }
static int _vte_gl_get_char_width(struct _vte_draw *draw, gunichar c, int columns) { struct _vte_gl_data *data; const struct _vte_glyph *glyph; data = (struct _vte_gl_data*) draw->impl_data; glyph = _vte_glyph_get(data->cache, c); if (glyph != NULL) { return glyph->width; } return _vte_gl_get_text_width(draw) * columns; }
static void _vte_gl_draw_text(struct _vte_draw *draw, struct _vte_draw_text_request *requests, gsize n_requests, GdkColor *color, guchar alpha) { struct _vte_gl_data *data = draw->impl_data; const struct _vte_glyph *glyph; guint16 a, r, g, b; guint i, j; int k, x, y, w, pad, rows, columns, src, dest; guchar *pixels; glXMakeCurrent(data->display, data->glwindow, data->context); r = color->red >> 8; g = color->green >> 8; b = color->blue >> 8; rows = 0; columns = 0; for (i = 0; i < n_requests; i++) { glyph = _vte_glyph_get(data->cache, requests[i].c); columns += (requests[i].columns * data->cache->width); if ((glyph == NULL) || (glyph->width == 0) || (glyph->height == 0)) { continue; } rows = MAX(rows, glyph->skip + glyph->height); } _vte_buffer_set_minimum_size(data->buffer, rows * columns * 4); pixels = data->buffer->bytes; memset(pixels, 0, rows * columns * 4); for (k = 0; k < rows * columns; k++) { pixels[k * 4 + 0] = r; pixels[k * 4 + 1] = g; pixels[k * 4 + 2] = b; } for (i = j = 0; i < n_requests; i++) { glyph = _vte_glyph_get(data->cache, requests[i].c); w = requests[i].columns * data->cache->width; if ((glyph == NULL) || (glyph->width == 0) || (glyph->height == 0)) { j += w; continue; } pad = (w - glyph->width) / 2; for (y = 0; y < glyph->height; y++) for (x = 0; x < glyph->width; x++) { src = (y * glyph->width + x) * glyph->bytes_per_pixel; a = glyph->bytes[src]; if (a == 0) { continue; } if (alpha != VTE_DRAW_OPAQUE) { a = (a * alpha) >> 8; } if (a == 0) { continue; } dest = (y + glyph->skip) * columns * 4 + (j + pad + x) * 4 + 3; pixels[dest] = a; } j += w; }