[mapserver-commits] r9478 - sandbox/aggplugin/mapserver

svn at osgeo.org svn at osgeo.org
Sat Oct 17 09:50:13 EDT 2009


Author: tbonfort
Date: 2009-10-17 09:50:13 -0400 (Sat, 17 Oct 2009)
New Revision: 9478

Modified:
   sandbox/aggplugin/mapserver/mapagg2.cpp
Log:
add truetype point symbols 


Modified: sandbox/aggplugin/mapserver/mapagg2.cpp
===================================================================
--- sandbox/aggplugin/mapserver/mapagg2.cpp	2009-10-17 11:22:07 UTC (rev 9477)
+++ sandbox/aggplugin/mapserver/mapagg2.cpp	2009-10-17 13:50:13 UTC (rev 9478)
@@ -104,6 +104,7 @@
 template<class VertexSource>
 static void applyCJC(VertexSource &stroke, int caps, int joins) {
    switch (joins) {
+      case MS_CJC_NONE:
       case MS_CJC_ROUND:
          stroke.line_join(mapserver::round_join);
          break;
@@ -296,7 +297,60 @@
 
 void agg2RenderTruetypeSymbol(imageObj *img, double x, double y,
         symbolObj *symbol, symbolStyleObj * style) {
+   AGG2Renderer *r = agg2GetRenderer(img);
+   if (!r->m_feng.load_font(symbol->full_font_path, 0, mapserver::glyph_ren_outline)) {
+      msSetError(MS_TTFERR, "AGG error loading font (%s)", "agg2RenderTruetypeSymbol()", symbol->full_font_path);
+   }
 
+   const mapserver::glyph_cache* glyph;
+   int unicode;
+   r->m_feng.hinting(true);
+   r->m_feng.height(style->scale);
+   r->m_feng.resolution(96);
+   r->m_feng.flip_y(true);
+   font_curve_type m_curves(r->m_fman.path_adaptor());
+   double ox = 0, oy = 0;
+      //we're rendering a marker symbol, it has to be centered
+      //on the label point (the default is the lower left of the
+      //text)
+      //this block computes the offset between the lower left corner
+      //of the character and it's center for the given rotaion. this
+      //offset will then be used in the following mapserver::trans_affine_translation
+      msUTF8ToUniChar(symbol->character, &unicode);
+      glyph = r->m_fman.glyph(unicode);
+      ox = glyph->bounds.x1 + (glyph->bounds.x2 - glyph->bounds.x1) / 2.;
+      oy = glyph->bounds.y1 + (glyph->bounds.y2 - glyph->bounds.y1) / 2.;
+      mapserver::trans_affine_rotation(-style->rotation).transform(&ox, &oy);
+   mapserver::trans_affine mtx;
+   mtx *= mapserver::trans_affine_translation(-x, -y);
+   /*agg angles are antitrigonometric*/
+   mtx *= mapserver::trans_affine_rotation(-style->rotation);
+   mtx *= mapserver::trans_affine_translation(x - ox, y - oy);
+   mapserver::path_storage glyphs;
+
+         r->m_fman.init_embedded_adaptors(glyph, x, y);
+         mapserver::conv_transform<font_curve_type, mapserver::trans_affine> trans_c(m_curves, mtx);
+         glyphs.concat_path(trans_c);
+   if (style->outlinecolor.alpha) {
+      color_type outlinecolor = aggColor(&(style->outlinecolor));
+      r->m_rasterizer_aa.reset();
+      r->m_rasterizer_aa.filling_rule(mapserver::fill_non_zero);
+      mapserver::conv_contour<mapserver::path_storage> cc(glyphs);
+      cc.width(style->outlinewidth);
+      r->m_rasterizer_aa.add_path(cc);
+      r->m_renderer_scanline.color(outlinecolor);
+      mapserver::render_scanlines(r->m_rasterizer_aa, r->sl_line, r->m_renderer_scanline);
+   }
+
+   if (style->color.alpha) {
+      r->m_rasterizer_aa.reset();
+      r->m_rasterizer_aa.filling_rule(mapserver::fill_non_zero);
+      r->m_rasterizer_aa.add_path(glyphs);
+      color_type color = aggColor(&(style->color));
+      r->m_renderer_scanline.color(color);
+      mapserver::render_scanlines(r->m_rasterizer_aa, r->sl_line, r->m_renderer_scanline);
+   }
+
 }
 
 void* agg2CreateTruetypeSymbolTile(int width, int height,



More information about the mapserver-commits mailing list