]> mj.ucw.cz Git - leo.git/blobdiff - sym-text.c
Fixed bug in reporting of unknown roles in multipolygons
[leo.git] / sym-text.c
index 2666acd9f5d2e6f5984183750ad77b0a1ef2b7c8..504f62f5fd6115b3171d781fc6cc36b4d1406e81 100644 (file)
@@ -4,15 +4,16 @@
  *     (c) 2014 Martin Mares <mj@ucw.cz>
  */
 
-#include <ucw/lib.h>
+#include "leo.h"
+
 #include <ucw/stkstring.h>
 
+#include <math.h>
 #include <stdio.h>
 #include <ft2build.h>
 #include FT_FREETYPE_H
 #include <pango/pangoft2.h>
 
-#include "leo.h"
 #include "osm.h"
 #include "sym.h"
 #include "map.h"
@@ -241,10 +242,16 @@ static void sym_text_draw(struct symbol *sym, struct svg *svg)
       t->y = sy / nn;
     }
 
-  if (t->opacity != 1)
+  bool use_group = 0;
+  bool want_rotate = (fabs(t->rotate) > 1e-5);
+  if (t->opacity != 1 || want_rotate)
     {
+      use_group = 1;
       svg_push_element(svg, "g");
-      svg_set_attr_float(svg, "opacity", t->opacity);
+      if (t->opacity != 1)
+       svg_set_attr_float(svg, "opacity", t->opacity);
+      if (want_rotate)
+       svg_set_attr_format(svg, "transform", "rotate(%.2f %s %s)", -t->rotate, svg_format_dimen(svg, t->x), svg_format_dimen(svg, t->y));
     }
 
   if (t->halo_radius)
@@ -292,7 +299,7 @@ static void sym_text_draw(struct symbol *sym, struct svg *svg)
   svg_pop(svg);
 #endif
 
-  if (t->opacity != 1)
+  if (use_group)
     svg_pop(svg);
 }