Fix unicode support (wrong lengths).
This commit is contained in:
parent
356e3945e9
commit
5e51f361ee
@ -106,13 +106,11 @@ int __guac_terminal_encode_utf8(int codepoint, char* utf8) {
|
|||||||
/* Otherwise, invalid codepoint */
|
/* Otherwise, invalid codepoint */
|
||||||
else {
|
else {
|
||||||
*(utf8++) = '?';
|
*(utf8++) = '?';
|
||||||
*(utf8++) = 0;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Offset buffer by size */
|
/* Offset buffer by size */
|
||||||
utf8 += bytes;
|
utf8 += bytes - 1;
|
||||||
*(utf8--) = 0;
|
|
||||||
|
|
||||||
/* Add trailing bytes, if any */
|
/* Add trailing bytes, if any */
|
||||||
for (i=1; i<bytes; i++) {
|
for (i=1; i<bytes; i++) {
|
||||||
@ -139,7 +137,8 @@ int __guac_terminal_get_glyph(guac_terminal_display* display, int codepoint) {
|
|||||||
guac_socket* socket = display->client->socket;
|
guac_socket* socket = display->client->socket;
|
||||||
int location;
|
int location;
|
||||||
|
|
||||||
char utf8[5];
|
int bytes;
|
||||||
|
char utf8[4];
|
||||||
|
|
||||||
/* Use foreground color */
|
/* Use foreground color */
|
||||||
const guac_terminal_color* color =
|
const guac_terminal_color* color =
|
||||||
@ -174,7 +173,7 @@ int __guac_terminal_get_glyph(guac_terminal_display* display, int codepoint) {
|
|||||||
location = display->next_glyph++;
|
location = display->next_glyph++;
|
||||||
|
|
||||||
/* Convert to UTF-8 */
|
/* Convert to UTF-8 */
|
||||||
__guac_terminal_encode_utf8(codepoint, utf8);
|
bytes = __guac_terminal_encode_utf8(codepoint, utf8);
|
||||||
|
|
||||||
/* Prepare surface */
|
/* Prepare surface */
|
||||||
surface = cairo_image_surface_create(
|
surface = cairo_image_surface_create(
|
||||||
@ -185,7 +184,7 @@ int __guac_terminal_get_glyph(guac_terminal_display* display, int codepoint) {
|
|||||||
/* Get layout */
|
/* Get layout */
|
||||||
layout = pango_cairo_create_layout(cairo);
|
layout = pango_cairo_create_layout(cairo);
|
||||||
pango_layout_set_font_description(layout, display->font_desc);
|
pango_layout_set_font_description(layout, display->font_desc);
|
||||||
pango_layout_set_text(layout, utf8, 1);
|
pango_layout_set_text(layout, utf8, bytes);
|
||||||
|
|
||||||
/* Draw */
|
/* Draw */
|
||||||
cairo_set_source_rgba(cairo,
|
cairo_set_source_rgba(cairo,
|
||||||
|
Loading…
Reference in New Issue
Block a user