aboutsummaryrefslogtreecommitdiff
path: root/src/layer_text.cpp
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2012-10-05 18:16:47 +0200
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2012-10-05 18:16:47 +0200
commit0d0660ed39eb75aafd2d20bf5027add550376149 (patch)
treec44c76d1a3ad1921c0498027c0413454e65f4e54 /src/layer_text.cpp
parent2ba309a41be5a8bbc8dcd3443a198ce815c017aa (diff)
downloadosc-graphics-0d0660ed39eb75aafd2d20bf5027add550376149.tar.gz
interpret font paths relative to configured system path
* on Windows, SYSTEMROOT\fonts\ is assumed (untested)
Diffstat (limited to 'src/layer_text.cpp')
-rw-r--r--src/layer_text.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/layer_text.cpp b/src/layer_text.cpp
index 38ba0e5..bbfff93 100644
--- a/src/layer_text.cpp
+++ b/src/layer_text.cpp
@@ -2,8 +2,14 @@
#include "config.h"
#endif
+#include <string.h>
+#include <stdlib.h>
#include <math.h>
+#ifdef __WIN32__
+#include <windows.h>
+#endif
+
#include <SDL.h>
#include <SDL_ttf.h>
#include <SDL_rotozoom.h>
@@ -129,6 +135,51 @@ LayerText::color(SDL_Color color)
alpha(alphav);
}
+#ifdef __WIN32__
+
+void
+LayerText::font(const char *file)
+{
+ free(filev);
+
+ if (PathIsRelative(file)) {
+ /* relative path */
+ const char *systemroot = getenv("SYSTEMROOT");
+
+ filev = (char *)malloc(strlen(systemroot) + 7 + strlen(file) + 1);
+ strcpy(filev, systemroot);
+ strcat(filev, "\\fonts\\");
+ strcat(filev, file);
+ } else {
+ /* absolute path */
+ filev = strdup(file);
+ }
+
+ geo(geov);
+}
+
+#else /* assume POSIX */
+
+void
+LayerText::font(const char *file)
+{
+ free(filev);
+
+ if (*file != '/') {
+ /* relative path */
+ filev = (char *)malloc(sizeof(FONT_PATH) + strlen(file));
+ strcpy(filev, FONT_PATH);
+ strcat(filev, file);
+ } else {
+ /* absolute path */
+ filev = strdup(file);
+ }
+
+ geo(geov);
+}
+
+#endif
+
void
LayerText::style_osc(LayerText *obj, lo_arg **argv)
{