summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorIan MacArthur <imacarthur@gmail.com>2011-04-11 21:49:05 +0000
committerIan MacArthur <imacarthur@gmail.com>2011-04-11 21:49:05 +0000
commit924ed100d6747d5dec17366590637875ad19471e (patch)
tree178713b0a44ba79e1b98487bdff6ae4d33a2d588 /src
parent87b998ed1f7664a508e4c8906635a7b512b5168a (diff)
Minor rework of code to make ::rtl_draw() and ::draw(int angle,...) more consistent in coding terms. Behaviour of output unchanged.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8578 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/fl_font_win32.cxx24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/fl_font_win32.cxx b/src/fl_font_win32.cxx
index 711f829da..cac374842 100644
--- a/src/fl_font_win32.cxx
+++ b/src/fl_font_win32.cxx
@@ -159,7 +159,7 @@ int Fl_GDI_Graphics_Driver::descent() {
}
// Unicode string buffer
-static xchar *wstr = NULL;
+static unsigned short *wstr = NULL;
static int wstr_len = 0;
@@ -371,29 +371,27 @@ void Fl_GDI_Graphics_Driver::draw(const char* str, int n, int x, int y) {
void Fl_GDI_Graphics_Driver::draw(int angle, const char* str, int n, int x, int y) {
fl_font(this, Fl_Graphics_Driver::font(), size(), angle);
- int wc_count = 0; // count of UTF16 cells to render full string
+ int wn = 0; // count of UTF16 cells to render full string
COLORREF oldColor = SetTextColor(fl_gc, fl_RGB());
SelectObject(fl_gc, font_descriptor()->fid);
- unsigned short* ucs = new unsigned short[n+1]; // alloc an array for the UTF16 string
- wc_count = fl_utf8toUtf16(str, n, ucs, n);
- if(wc_count > n) { // Array too small - this should never happen...
- delete[] ucs; // free up the initial allocation
- ucs = new unsigned short[wc_count + 4]; // make a "big enough" array
- wc_count = fl_utf8toUtf16(str, n, ucs, wc_count); // respin the translation
+ wn = fl_utf8toUtf16(str, n, wstr, wstr_len);
+ if(wn >= wstr_len) { // Array too small
+ wstr = (unsigned short*) realloc(wstr, sizeof(unsigned short) * (wn + 1));
+ wstr_len = wn + 1;
+ wn = fl_utf8toUtf16(str, n, wstr, wstr_len); // respin the translation
}
- TextOutW(fl_gc, x, y, (WCHAR*)ucs, wc_count);
- delete[] ucs;
+ TextOutW(fl_gc, x, y, (WCHAR*)wstr, wn);
SetTextColor(fl_gc, oldColor);
fl_font(this, Fl_Graphics_Driver::font(), size(), 0);
}
void Fl_GDI_Graphics_Driver::rtl_draw(const char* c, int n, int x, int y) {
int wn;
- wn = fl_utf8toUtf16(c, n, (unsigned short*)wstr, wstr_len);
+ wn = fl_utf8toUtf16(c, n, wstr, wstr_len);
if(wn >= wstr_len) {
- wstr = (xchar*) realloc(wstr, sizeof(xchar) * (wn + 1));
+ wstr = (unsigned short*) realloc(wstr, sizeof(unsigned short) * (wn + 1));
wstr_len = wn + 1;
- wn = fl_utf8toUtf16(c, n, (unsigned short*)wstr, wstr_len);
+ wn = fl_utf8toUtf16(c, n, wstr, wstr_len);
}
COLORREF oldColor = SetTextColor(fl_gc, fl_RGB());