mirror of
https://github.com/fltk/fltk.git
synced 2026-06-01 06:14:28 +08:00
WIN32 + OpenGL: fix use of wglUseFontBitmapsW() to draw all of UTF under GL with gl_draw().
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@12623 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
+11
-11
@@ -3,7 +3,7 @@
|
|||||||
//
|
//
|
||||||
// OpenGL drawing support routines for the Fast Light Tool Kit (FLTK).
|
// OpenGL drawing support routines for the Fast Light Tool Kit (FLTK).
|
||||||
//
|
//
|
||||||
// Copyright 1998-2016 by Bill Spitzak and others.
|
// Copyright 1998-2018 by Bill Spitzak and others.
|
||||||
//
|
//
|
||||||
// This library is free software. Distribution and use rights are outlined in
|
// This library is free software. Distribution and use rights are outlined in
|
||||||
// the file "COPYING" which should have been included with this file. If this
|
// the file "COPYING" which should have been included with this file. If this
|
||||||
@@ -135,7 +135,7 @@ static void get_list(int r) {
|
|||||||
#elif defined(WIN32)
|
#elif defined(WIN32)
|
||||||
unsigned int ii = r * 0x400;
|
unsigned int ii = r * 0x400;
|
||||||
HFONT oldFid = (HFONT)SelectObject(fl_gc, gl_fontsize->fid);
|
HFONT oldFid = (HFONT)SelectObject(fl_gc, gl_fontsize->fid);
|
||||||
wglUseFontBitmapsW(fl_gc, ii, ii + 0x03ff, gl_fontsize->listbase+ii);
|
wglUseFontBitmapsW(fl_gc, ii, 0x400, gl_fontsize->listbase+ii);
|
||||||
SelectObject(fl_gc, oldFid);
|
SelectObject(fl_gc, oldFid);
|
||||||
#else
|
#else
|
||||||
# error unsupported platform
|
# error unsupported platform
|
||||||
@@ -194,22 +194,22 @@ void gl_draw(const char* str, int n) {
|
|||||||
#ifdef __APPLE__
|
#ifdef __APPLE__
|
||||||
gl_draw_textures(str, n);
|
gl_draw_textures(str, n);
|
||||||
#else
|
#else
|
||||||
static xchar *buf = NULL;
|
static unsigned short *buf = NULL;
|
||||||
static int l = 0;
|
static unsigned l = 0;
|
||||||
int wn = fl_utf8toUtf16(str, n, (unsigned short*)buf, l);
|
unsigned wn = fl_utf8toUtf16(str, n, buf, l);
|
||||||
if (wn >= l) {
|
if (wn >= l) {
|
||||||
buf = (xchar*) realloc(buf, sizeof(xchar) * (wn + 1));
|
buf = (unsigned short*) realloc(buf, sizeof(unsigned short) * (wn + 1));
|
||||||
l = wn + 1;
|
l = wn + 1;
|
||||||
wn = fl_utf8toUtf16(str, n, (unsigned short*)buf, l);
|
wn = fl_utf8toUtf16(str, n, buf, l);
|
||||||
}
|
}
|
||||||
n = wn;
|
|
||||||
|
|
||||||
int i;
|
#if !( defined(USE_X11) || USE_XFT )
|
||||||
for (i = 0; i < n; i++) {
|
for (unsigned i = 0; i < wn; i++) {
|
||||||
unsigned int r;
|
unsigned int r;
|
||||||
r = (str[i] & 0xFC00) >> 10;
|
r = (buf[i] & 0xFC00) >> 10;
|
||||||
if (!gl_fontsize->glok[r]) get_list(r);
|
if (!gl_fontsize->glok[r]) get_list(r);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
glCallLists(n, GL_UNSIGNED_SHORT, buf);
|
glCallLists(n, GL_UNSIGNED_SHORT, buf);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user