summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-08-13 12:25:04 +0200
committerManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com>2022-08-13 12:25:04 +0200
commitd325fa504e4a4e2a456a646a4159a43a8dfac4fd (patch)
tree5781b15877539fc83ae440ff710cdd32b3a6bffb /src/drivers
parentd1d3cc9afa169ab4a38063a3f6667ca8c2544d49 (diff)
Replace call to CreateFont() by call to CreateFontW().
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/GDI/Fl_GDI_Graphics_Driver_font.cxx20
1 files changed, 12 insertions, 8 deletions
diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver_font.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver_font.cxx
index 2315c875c..82bf2078a 100644
--- a/src/drivers/GDI/Fl_GDI_Graphics_Driver_font.cxx
+++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver_font.cxx
@@ -208,6 +208,9 @@ void Fl_GDI_Graphics_Driver::font_name(int num, const char *name) {
static int fl_angle_ = 0;
+// Unicode string buffer
+static unsigned short *wstr = NULL;
+static int wstr_len = 0;
#ifndef FL_DOXYGEN
Fl_GDI_Font_Descriptor::Fl_GDI_Font_Descriptor(const char* name, Fl_Fontsize fsize) : Fl_Font_Descriptor(name,fsize) {
@@ -220,7 +223,14 @@ Fl_GDI_Font_Descriptor::Fl_GDI_Font_Descriptor(const char* name, Fl_Fontsize fsi
case ' ': break;
default: name--;
}
- fid = CreateFont(
+ int wn = fl_utf8toUtf16(name, strlen(name), wstr, wstr_len);
+ if (wn >= wstr_len) {
+ wstr = (unsigned short*) realloc(wstr, sizeof(unsigned short) * (wn + 1));
+ wstr_len = wn + 1;
+ wn = fl_utf8toUtf16(name, strlen(name), wstr, wstr_len);
+ }
+
+ fid = CreateFontW(
-fsize, // negative makes it use "char size"
0, // logical average character width
fl_angle_*10, // angle of escapement
@@ -234,7 +244,7 @@ Fl_GDI_Font_Descriptor::Fl_GDI_Font_Descriptor(const char* name, Fl_Fontsize fsi
CLIP_DEFAULT_PRECIS,// clipping precision
DEFAULT_QUALITY, // output quality
DEFAULT_PITCH, // pitch and family
- name // pointer to typeface name string
+ (LPCWSTR)wstr // pointer to typeface name string
);
angle = fl_angle_;
HDC gc = (HDC)fl_graphics_driver->gc();
@@ -338,12 +348,6 @@ Fl_Fontsize Fl_GDI_Graphics_Driver::size_unscaled() {
return -1;
}
-
-// Unicode string buffer
-static unsigned short *wstr = NULL;
-static int wstr_len = 0;
-
-
double Fl_GDI_Graphics_Driver::width_unscaled(const char* c, int n) {
int i = 0;
if (!font_descriptor()) return -1.0;