[mapserver-commits] r11964 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Wed Jul 20 09:44:04 EDT 2011


Author: tbonfort
Date: 2011-07-20 06:44:04 -0700 (Wed, 20 Jul 2011)
New Revision: 11964

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapgd.c
   trunk/mapserver/maprendering.c
   trunk/mapserver/mapserver.h
Log:
Add non antialiased text rendering for GD (#3896)

Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2011-07-20 13:06:10 UTC (rev 11963)
+++ trunk/mapserver/HISTORY.TXT	2011-07-20 13:44:04 UTC (rev 11964)
@@ -14,6 +14,7 @@
 
 Current Version (SVN trunk, 6.1-dev, future 6.2): 
 -------------------------------------------------
+- Add non antialiased text rendering for GD (#3896)
 
 - Fixed OGC filter using expressions (#3481)
 

Modified: trunk/mapserver/mapgd.c
===================================================================
--- trunk/mapserver/mapgd.c	2011-07-20 13:06:10 UTC (rev 11963)
+++ trunk/mapserver/mapgd.c	2011-07-20 13:44:04 UTC (rev 11964)
@@ -389,6 +389,7 @@
    gdImagePtr ip;
    char *error=NULL;
    int bbox[8];
+   int c,oc;
    x = MS_NINT(x);
    y = MS_NINT(y);
    if(!(ip = MS_IMAGE_GET_GDIMAGEPTR(img))) return MS_FAILURE;
@@ -396,25 +397,35 @@
 
    SETPEN(ip, style->color);
    SETPEN(ip, style->outlinecolor);
+
+   if(style->antialias) {
+      c = style->color->pen;
+      if(style->outlinewidth > 0)
+         oc = style->outlinecolor->pen;
+   } else {
+      c = -style->color->pen;
+      if(style->outlinewidth > 0)
+         oc = -style->outlinecolor->pen;
+   }
    
    if(style->outlinewidth > 0) { /* handle the outline color */
-      error = gdImageStringFT(ip, bbox, style->outlinecolor->pen, style->font, style->size, style->rotation, x, y-1, text);
+      error = gdImageStringFT(ip, bbox, oc, style->font, style->size, style->rotation, x, y-1, text);
       if(error) {
          msSetError(MS_TTFERR, error, "msDrawTextGD()");
          return(MS_FAILURE);
       }
 
-      gdImageStringFT(ip, bbox, style->outlinecolor->pen, style->font, style->size, style->rotation, x, y+1, text);
-      gdImageStringFT(ip, bbox, style->outlinecolor->pen, style->font, style->size, style->rotation, x+1, y, text);
-      gdImageStringFT(ip, bbox, style->outlinecolor->pen, style->font, style->size, style->rotation, x-1, y, text);
-      gdImageStringFT(ip, bbox, style->outlinecolor->pen, style->font, style->size, style->rotation, x-1, y-1, text);      
-      gdImageStringFT(ip, bbox, style->outlinecolor->pen, style->font, style->size, style->rotation, x-1, y+1, text);
-      gdImageStringFT(ip, bbox, style->outlinecolor->pen, style->font, style->size, style->rotation, x+1, y-1, text);
-      gdImageStringFT(ip, bbox, style->outlinecolor->pen, style->font, style->size, style->rotation, x+1, y+1, text);
+      gdImageStringFT(ip, bbox, oc, style->font, style->size, style->rotation, x, y+1, text);
+      gdImageStringFT(ip, bbox, oc, style->font, style->size, style->rotation, x+1, y, text);
+      gdImageStringFT(ip, bbox, oc, style->font, style->size, style->rotation, x-1, y, text);
+      gdImageStringFT(ip, bbox, oc, style->font, style->size, style->rotation, x-1, y-1, text);      
+      gdImageStringFT(ip, bbox, oc, style->font, style->size, style->rotation, x-1, y+1, text);
+      gdImageStringFT(ip, bbox, oc, style->font, style->size, style->rotation, x+1, y-1, text);
+      gdImageStringFT(ip, bbox, oc, style->font, style->size, style->rotation, x+1, y+1, text);
    }
    
    if(style->color)
-      gdImageStringFT(ip, bbox, style->color->pen, style->font, style->size, style->rotation, x, y, text);
+      gdImageStringFT(ip, bbox, c, style->font, style->size, style->rotation, x, y, text);
    return MS_SUCCESS;
 }
 
@@ -630,32 +641,43 @@
 int renderTruetypeSymbolGD(imageObj *img, double x, double y, symbolObj *symbol, symbolStyleObj *s) {
    int bbox[8];
    char *error;
+   int c,oc;
    gdImagePtr ip;
    if(!(ip = MS_IMAGE_GET_GDIMAGEPTR(img))) return MS_FAILURE;
    SETPEN(ip, s->color);
    SETPEN(ip, s->outlinecolor);
-   gdImageStringFT(NULL, bbox, s->color->pen, symbol->full_font_path, s->scale, s->rotation, 0,0, symbol->character);
    
+   if(s->style->antialias) {
+      c = s->color->pen;
+      if(s->outlinecolor)
+         oc = s->outlinecolor->pen;
+   } else {
+      c = -s->color->pen;
+      if(s->outlinecolor)
+         oc = -s->outlinecolor->pen;
+   }
+   gdImageStringFT(NULL, bbox, c, symbol->full_font_path, s->scale, s->rotation, 0,0, symbol->character);
+   
    x -=  (bbox[2] - bbox[0])/2 + bbox[0];
    y +=  (bbox[1] - bbox[5])/2 - bbox[1];
 
    if( s->outlinecolor ) {
-      error = gdImageStringFT(ip, bbox, s->outlinecolor->pen, symbol->full_font_path, s->scale, s->rotation, x, y-1, symbol->character);
+      error = gdImageStringFT(ip, bbox, oc, symbol->full_font_path, s->scale, s->rotation, x, y-1, symbol->character);
       if(error) {
          msSetError(MS_TTFERR, error, "msDrawMarkerSymbolGD()");
          return MS_FAILURE;
       }
 
-      gdImageStringFT(ip, bbox, s->outlinecolor->pen, symbol->full_font_path, s->scale, s->rotation, x, y+1, symbol->character);
-      gdImageStringFT(ip, bbox, s->outlinecolor->pen, symbol->full_font_path, s->scale, s->rotation, x+1, y, symbol->character);
-      gdImageStringFT(ip, bbox, s->outlinecolor->pen, symbol->full_font_path, s->scale, s->rotation, x-1, y, symbol->character);
-      gdImageStringFT(ip, bbox, s->outlinecolor->pen, symbol->full_font_path, s->scale, s->rotation, x+1, y+1, symbol->character);
-      gdImageStringFT(ip, bbox, s->outlinecolor->pen, symbol->full_font_path, s->scale, s->rotation, x+1, y-1, symbol->character);
-      gdImageStringFT(ip, bbox, s->outlinecolor->pen, symbol->full_font_path, s->scale, s->rotation, x-1, y+1, symbol->character);
-      gdImageStringFT(ip, bbox, s->outlinecolor->pen, symbol->full_font_path, s->scale, s->rotation, x-1, y-1, symbol->character);
+      gdImageStringFT(ip, bbox, oc, symbol->full_font_path, s->scale, s->rotation, x, y+1, symbol->character);
+      gdImageStringFT(ip, bbox, oc, symbol->full_font_path, s->scale, s->rotation, x+1, y, symbol->character);
+      gdImageStringFT(ip, bbox, oc, symbol->full_font_path, s->scale, s->rotation, x-1, y, symbol->character);
+      gdImageStringFT(ip, bbox, oc, symbol->full_font_path, s->scale, s->rotation, x+1, y+1, symbol->character);
+      gdImageStringFT(ip, bbox, oc, symbol->full_font_path, s->scale, s->rotation, x+1, y-1, symbol->character);
+      gdImageStringFT(ip, bbox, oc, symbol->full_font_path, s->scale, s->rotation, x-1, y+1, symbol->character);
+      gdImageStringFT(ip, bbox, oc, symbol->full_font_path, s->scale, s->rotation, x-1, y-1, symbol->character);
    }
    if(s->color)
-	   gdImageStringFT(ip, bbox, s->color->pen, symbol->full_font_path, s->scale, s->rotation, x, y, symbol->character);
+	   gdImageStringFT(ip, bbox, c, symbol->full_font_path, s->scale, s->rotation, x, y, symbol->character);
   return MS_SUCCESS;
 }
 

Modified: trunk/mapserver/maprendering.c
===================================================================
--- trunk/mapserver/maprendering.c	2011-07-20 13:06:10 UTC (rev 11963)
+++ trunk/mapserver/maprendering.c	2011-07-20 13:44:04 UTC (rev 11964)
@@ -61,6 +61,7 @@
       }
    }
    s->rotation = l->angle * MS_DEG_TO_RAD;
+   s->antialias = l->antialias;
    return MS_SUCCESS;
 }
 void computeSymbolStyle(symbolStyleObj *s, styleObj *src, symbolObj *symbol, double scalefactor) {

Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h	2011-07-20 13:06:10 UTC (rev 11963)
+++ trunk/mapserver/mapserver.h	2011-07-20 13:44:04 UTC (rev 11964)
@@ -2594,6 +2594,7 @@
     colorObj *color;
     double outlinewidth;
     colorObj *outlinecolor;
+    int antialias; /*only for GD*/
 } labelStyleObj;
 
 #define INIT_LABEL_STYLE(s) {(s).font=NULL; (s).size=0; (s).rotation=0; (s).color=NULL; (s).outlinewidth=0; (s).outlinecolor=NULL;}



More information about the mapserver-commits mailing list