2017-08-16 09:15:05 +02:00
|
|
|
---
|
|
|
|
src/gplt_x11.c | 33 +++++++++++++++++++++++++++------
|
2020-07-17 10:10:21 +02:00
|
|
|
1 file changed, 27 insertions(+), 6 deletions(-)
|
2017-08-16 09:15:05 +02:00
|
|
|
|
|
|
|
--- src/gplt_x11.c
|
2020-07-17 10:10:21 +02:00
|
|
|
+++ src/gplt_x11.c 2020-07-17 07:20:04.523781257 +0000
|
2018-05-07 09:16:41 +02:00
|
|
|
@@ -99,15 +99,16 @@
|
2008-03-14 17:41:50 +01:00
|
|
|
* patches by Masahito Yamaga <ma@yama-ga.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
+#ifndef _GNU_SOURCE
|
|
|
|
+#define _GNU_SOURCE
|
|
|
|
+#endif
|
|
|
|
+#include <string.h>
|
2010-04-07 21:19:15 +02:00
|
|
|
#include <X11/Xos.h>
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
#include <X11/Xresource.h>
|
|
|
|
#include <X11/Xutil.h>
|
2010-04-07 21:19:13 +02:00
|
|
|
#include <X11/Xatom.h>
|
|
|
|
#include <X11/keysym.h>
|
2010-04-07 21:19:15 +02:00
|
|
|
-#ifdef USE_X11_MULTIBYTE
|
|
|
|
-# include <X11/Xlocale.h>
|
|
|
|
-#endif
|
2015-01-23 15:40:26 +01:00
|
|
|
#include <X11/XKBlib.h> /* for XkbKeycodeToKeysym */
|
2010-04-07 21:19:15 +02:00
|
|
|
|
2012-04-02 16:02:56 +02:00
|
|
|
#include <assert.h>
|
2018-05-07 09:16:41 +02:00
|
|
|
@@ -118,6 +119,12 @@
|
2010-04-07 21:19:15 +02:00
|
|
|
#include "gplt_x11.h"
|
2012-04-02 16:02:56 +02:00
|
|
|
#include "version.h"
|
2010-04-07 21:19:15 +02:00
|
|
|
|
|
|
|
+#ifdef USE_X11_MULTIBYTE
|
2008-03-14 17:41:50 +01:00
|
|
|
+# include <locale.h>
|
|
|
|
+# include <langinfo.h>
|
2010-04-07 21:19:15 +02:00
|
|
|
+# include <X11/Xlocale.h>
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
#ifdef EXPORT_SELECTION
|
|
|
|
# undef EXPORT_SELECTION
|
|
|
|
#endif /* EXPORT SELECTION */
|
2024-01-09 09:40:54 +01:00
|
|
|
@@ -522,8 +529,8 @@ static char *gpFallbackFont(void);
|
2020-07-17 10:10:21 +02:00
|
|
|
static int gpXGetFontascent(XFontStruct *cfont);
|
2008-03-14 17:41:50 +01:00
|
|
|
|
|
|
|
enum set_encoding_id encoding = S_ENC_DEFAULT; /* EAM - mirrored from core code by 'QE' */
|
2015-01-23 15:40:26 +01:00
|
|
|
-static char default_font[196] = { '\0' };
|
2008-03-14 17:41:50 +01:00
|
|
|
-static char default_encoding[16] = { '\0' };
|
|
|
|
+static char default_font[256] = { '\0' };
|
|
|
|
+static char default_encoding[64] = { '\0' };
|
|
|
|
|
|
|
|
#define Nwidths 10
|
2015-01-23 15:40:26 +01:00
|
|
|
static unsigned int widths[Nwidths] = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
|
2024-01-09 09:40:54 +01:00
|
|
|
@@ -2294,6 +2301,8 @@ exec_cmd(plot_struct *plot, char *comman
|
2008-03-14 17:41:50 +01:00
|
|
|
/* Save the request default font */
|
|
|
|
c = &(buffer[strlen(buffer)-1]);
|
|
|
|
while (*c <= ' ') *c-- = '\0';
|
|
|
|
+ if (strlen(&buffer[2]) == 0)
|
2020-07-17 10:10:21 +02:00
|
|
|
+ break;
|
|
|
|
strncpy(default_font, &buffer[2], sizeof(default_font)-1);
|
2008-03-14 17:41:50 +01:00
|
|
|
FPRINTF((stderr, "gnuplot_x11: exec_cmd() set default_font to \"%s\"\n", default_font));
|
|
|
|
break;
|
2024-01-09 09:40:54 +01:00
|
|
|
@@ -5820,7 +5829,7 @@ XFontStruct *gpXLoadQueryFont (Display *
|
2008-03-14 17:41:50 +01:00
|
|
|
}
|
|
|
|
#else
|
|
|
|
if (first_time) {
|
|
|
|
- fprintf(stderr,"gnuplot_x11: Some character sets not available\n");
|
|
|
|
+ FPRINTF(("gnuplot_x11: Some character sets not available\n"));
|
|
|
|
first_time = FALSE;
|
|
|
|
}
|
|
|
|
while (n_miss-- > 0)
|
2024-01-09 09:40:54 +01:00
|
|
|
@@ -5972,6 +5981,18 @@ char *fontname;
|
2008-03-14 17:41:50 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef USE_X11_MULTIBYTE
|
|
|
|
+ if ((!fontname || !(*fontname)) && multibyte_fonts_usable) {
|
|
|
|
+ const char * codeset = nl_langinfo(CODESET);
|
|
|
|
+ if (strcasestr(codeset, "UTF-8")) {
|
|
|
|
+ const char* utf8 = "mbfont:-*-sazanami*mincho-medium-r-normal--16-* \
|
|
|
|
+-*-mincho-medium-r-normal--16-*,-*-verdana-medium-r-normal--16-* \
|
|
|
|
+-*-dejavu*sans-medium-r-normal--16-*,-*-medium-r-normal--16-*";
|
|
|
|
+ strncpy(default_font, utf8, strlen(utf8)+1);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+#ifdef USE_X11_MULTIBYTE
|
|
|
|
if (fontname && strncmp(fontname, "mbfont:", 7) == 0) {
|
|
|
|
if (multibyte_fonts_usable) {
|
|
|
|
usemultibyte = 1;
|