diff options
author | jsorg71 <jsorg71> | 2007-09-23 06:47:21 +0000 |
---|---|---|
committer | jsorg71 <jsorg71> | 2007-09-23 06:47:21 +0000 |
commit | d1d5aac19c4bd961aa4e4a85e37b7f8a31992a24 (patch) | |
tree | 98454ce06bb0a12d77430a01036124340803e752 | |
parent | ef18f927df1c8a4a2ab9b37cbcca0b06efcf8977 (diff) | |
download | xrdp-proprietary-d1d5aac19c4bd961aa4e4a85e37b7f8a31992a24.tar.gz xrdp-proprietary-d1d5aac19c4bd961aa4e4a85e37b7f8a31992a24.zip |
unicode
-rw-r--r-- | xrdp/xrdp_painter.c | 25 | ||||
-rw-r--r-- | xrdp/xrdp_types.h | 6 |
2 files changed, 23 insertions, 8 deletions
diff --git a/xrdp/xrdp_painter.c b/xrdp/xrdp_painter.c index b266768b..7fb23621 100644 --- a/xrdp/xrdp_painter.c +++ b/xrdp/xrdp_painter.c @@ -182,6 +182,7 @@ xrdp_painter_text_width(struct xrdp_painter* self, char* text) int rv; int len; struct xrdp_font_char* font_item; + twchar* wstr; xrdp_painter_font_needed(self); if (text == 0) @@ -189,12 +190,15 @@ xrdp_painter_text_width(struct xrdp_painter* self, char* text) return 0; } rv = 0; - len = g_strlen(text); + len = g_mbstowcs(0, text, 0); + wstr = (twchar*)g_malloc((len + 2) * sizeof(twchar), 0); + g_mbstowcs(wstr, text, len + 1); for (index = 0; index < len; index++) { - font_item = self->font->font_items + (unsigned char)text[index]; + font_item = self->font->font_items + wstr[index]; rv = rv + font_item->incby; } + g_free(wstr); return rv; } @@ -206,6 +210,7 @@ xrdp_painter_text_height(struct xrdp_painter* self, char* text) int rv; int len; struct xrdp_font_char* font_item; + twchar* wstr; xrdp_painter_font_needed(self); if (text == 0) @@ -213,12 +218,15 @@ xrdp_painter_text_height(struct xrdp_painter* self, char* text) return 0; } rv = 0; - len = g_strlen(text); + len = g_mbstowcs(0, text, 0); + wstr = (twchar*)g_malloc((len + 2) * sizeof(twchar), 0); + g_mbstowcs(wstr, text, len + 1); for (index = 0; index < len; index++) { - font_item = self->font->font_items + (unsigned char)text[index]; + font_item = self->font->font_items + wstr[index]; rv = MAX(rv, font_item->height); } + g_free(wstr); return rv; } @@ -348,12 +356,13 @@ xrdp_painter_draw_text(struct xrdp_painter* self, struct xrdp_rect draw_rect; struct xrdp_font* font; struct xrdp_font_char* font_item; + twchar* wstr; if (self == 0) { return 0; } - len = g_strlen(text); + len = g_mbstowcs(0, text, 0); if (len < 1) { return 0; @@ -365,6 +374,9 @@ xrdp_painter_draw_text(struct xrdp_painter* self, { return 0; } + /* convert to wide char */ + wstr = (twchar*)g_malloc((len + 2) * sizeof(twchar), 0); + g_mbstowcs(wstr, text, len + 1); xrdp_painter_font_needed(self); font = self->font; f = 0; @@ -374,7 +386,7 @@ xrdp_painter_draw_text(struct xrdp_painter* self, data = (char*)g_malloc(len * 4, 1); for (index = 0; index < len; index++) { - font_item = font->font_items + (unsigned char)text[index]; + font_item = font->font_items + wstr[index]; i = xrdp_cache_add_char(self->wm->cache, font_item); f = HIWORD(i); c = LOWORD(i); @@ -408,6 +420,7 @@ xrdp_painter_draw_text(struct xrdp_painter* self, } xrdp_region_delete(region); g_free(data); + g_free(wstr); return 0; } diff --git a/xrdp/xrdp_types.h b/xrdp/xrdp_types.h index 3f4eab49..fbc519a6 100644 --- a/xrdp/xrdp_types.h +++ b/xrdp/xrdp_types.h @@ -314,7 +314,7 @@ struct xrdp_bitmap struct list* child_list; /* for edit */ int edit_pos; - int password_char; + twchar password_char; /* for button or combo */ int state; /* for button 0 = normal 1 = down */ /* for combo */ @@ -329,11 +329,13 @@ struct xrdp_bitmap int crc; }; +#define NUM_FONTS 4096 + /* font */ struct xrdp_font { struct xrdp_wm* wm; - struct xrdp_font_char font_items[1024]; + struct xrdp_font_char font_items[NUM_FONTS]; int color; char name[32]; int size; |