ulab-original
jsorg71 17 years ago
parent ef18f927df
commit d1d5aac19c

@ -182,6 +182,7 @@ xrdp_painter_text_width(struct xrdp_painter* self, char* text)
int rv; int rv;
int len; int len;
struct xrdp_font_char* font_item; struct xrdp_font_char* font_item;
twchar* wstr;
xrdp_painter_font_needed(self); xrdp_painter_font_needed(self);
if (text == 0) if (text == 0)
@ -189,12 +190,15 @@ xrdp_painter_text_width(struct xrdp_painter* self, char* text)
return 0; return 0;
} }
rv = 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++) 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; rv = rv + font_item->incby;
} }
g_free(wstr);
return rv; return rv;
} }
@ -206,6 +210,7 @@ xrdp_painter_text_height(struct xrdp_painter* self, char* text)
int rv; int rv;
int len; int len;
struct xrdp_font_char* font_item; struct xrdp_font_char* font_item;
twchar* wstr;
xrdp_painter_font_needed(self); xrdp_painter_font_needed(self);
if (text == 0) if (text == 0)
@ -213,12 +218,15 @@ xrdp_painter_text_height(struct xrdp_painter* self, char* text)
return 0; return 0;
} }
rv = 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++) 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); rv = MAX(rv, font_item->height);
} }
g_free(wstr);
return rv; return rv;
} }
@ -348,12 +356,13 @@ xrdp_painter_draw_text(struct xrdp_painter* self,
struct xrdp_rect draw_rect; struct xrdp_rect draw_rect;
struct xrdp_font* font; struct xrdp_font* font;
struct xrdp_font_char* font_item; struct xrdp_font_char* font_item;
twchar* wstr;
if (self == 0) if (self == 0)
{ {
return 0; return 0;
} }
len = g_strlen(text); len = g_mbstowcs(0, text, 0);
if (len < 1) if (len < 1)
{ {
return 0; return 0;
@ -365,6 +374,9 @@ xrdp_painter_draw_text(struct xrdp_painter* self,
{ {
return 0; 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); xrdp_painter_font_needed(self);
font = self->font; font = self->font;
f = 0; f = 0;
@ -374,7 +386,7 @@ xrdp_painter_draw_text(struct xrdp_painter* self,
data = (char*)g_malloc(len * 4, 1); data = (char*)g_malloc(len * 4, 1);
for (index = 0; index < len; index++) 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); i = xrdp_cache_add_char(self->wm->cache, font_item);
f = HIWORD(i); f = HIWORD(i);
c = LOWORD(i); c = LOWORD(i);
@ -408,6 +420,7 @@ xrdp_painter_draw_text(struct xrdp_painter* self,
} }
xrdp_region_delete(region); xrdp_region_delete(region);
g_free(data); g_free(data);
g_free(wstr);
return 0; return 0;
} }

@ -314,7 +314,7 @@ struct xrdp_bitmap
struct list* child_list; struct list* child_list;
/* for edit */ /* for edit */
int edit_pos; int edit_pos;
int password_char; twchar password_char;
/* for button or combo */ /* for button or combo */
int state; /* for button 0 = normal 1 = down */ int state; /* for button 0 = normal 1 = down */
/* for combo */ /* for combo */
@ -329,11 +329,13 @@ struct xrdp_bitmap
int crc; int crc;
}; };
#define NUM_FONTS 4096
/* font */ /* font */
struct xrdp_font struct xrdp_font
{ {
struct xrdp_wm* wm; struct xrdp_wm* wm;
struct xrdp_font_char font_items[1024]; struct xrdp_font_char font_items[NUM_FONTS];
int color; int color;
char name[32]; char name[32];
int size; int size;

Loading…
Cancel
Save