Add support file to locate truetype fonts on linux - gsl-shell.git - gsl-shell

index : gsl-shell.git
gsl-shell
summary refs log tree commit diff
path: root/agg-plot
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2012年07月22日 18:14:53 +0200
committerFrancesco Abbate <francesco.bbt@gmail.com>2012年07月22日 18:14:53 +0200
commit78702ab307e9d05493cb980a25f19d340d5644a0 (patch)
tree9d24fa8f54b30674460cacce96ef8bff1ff6e6dc /agg-plot
parent92e12ee84e5db62e8d33a1a32d9a5d6289c9fffc (diff)
downloadgsl-shell-78702ab307e9d05493cb980a25f19d340d5644a0.tar.gz
Add support file to locate truetype fonts on linux
Diffstat (limited to 'agg-plot')
-rw-r--r--agg-plot/Makefile 2
-rw-r--r--agg-plot/support_x11.cpp 24
2 files changed, 25 insertions, 1 deletions
diff --git a/agg-plot/Makefile b/agg-plot/Makefile
index 34786f94..d987ee22 100644
--- a/agg-plot/Makefile
+++ b/agg-plot/Makefile
@@ -31,7 +31,7 @@ ifeq ($(HOST_SYS),Windows)
INCLUDES += -I/usr/include -I/usr/pthreads-w32/include
PLATSUP_SRC_FILES = support_win32.cpp agg_platform_support_win32.cpp agg_win32_bmp.cpp
else
- PLATSUP_SRC_FILES = agg_platform_support_x11.cpp
+ PLATSUP_SRC_FILES = support_x11.cpp agg_platform_support_x11.cpp
endif
INCLUDES += $(AGG_INCLUDES) $(FREETYPE_INCLUDES) -I$(GSH_BASE_DIR) -I$(LUADIR)/src
diff --git a/agg-plot/support_x11.cpp b/agg-plot/support_x11.cpp
new file mode 100644
index 00000000..cc40d3d2
--- /dev/null
+++ b/agg-plot/support_x11.cpp
@@ -0,0 +1,24 @@
+#include <sys/stat.h>
+
+#include "agg-pixfmt-config.h"
+
+const char *ttf_names[] = {"freefont/FreeSans.ttf", "ttf-dejavu/DejaVuSans.ttf", 0};
+
+const char *gslshell::get_font_name()
+{
+ const char* ttf_dir = "/usr/share/fonts/truetype/";
+ unsigned len = strlen(ttf_dir);
+ static char pf[256];
+ memcpy(pf, ttf_dir, len + 1);
+ for (int k = 0; ttf_names[k]; k++)
+ {
+ const char* font_name = ttf_names[k];
+ memcpy(pf + len, font_name, (strlen(font_name) + 1) * sizeof(char));
+ struct stat inf[1];
+ int status = stat(pf, inf);
+ if (status == 0)
+ return pf;
+ }
+
+ return 0;
+}
generated by cgit v1.2.3 (git 2.39.1) at 2025年09月24日 09:12:58 +0000

AltStyle によって変換されたページ (->オリジナル) /