[mapserver-commits] r7954 - trunk/mapserver

svn at osgeo.org svn at osgeo.org
Sat Oct 4 06:59:35 EDT 2008


Author: tbonfort
Date: 2008-10-04 06:59:35 -0400 (Sat, 04 Oct 2008)
New Revision: 7954

Modified:
   trunk/mapserver/HISTORY.TXT
   trunk/mapserver/mapagg.cpp
   trunk/mapserver/mapdraw.c
   trunk/mapserver/mapgd.c
   trunk/mapserver/mapgraticule.c
   trunk/mapserver/mapimagemap.c
   trunk/mapserver/maplabel.c
   trunk/mapserver/maplegend.c
   trunk/mapserver/mappdf.c
   trunk/mapserver/mapprimitive.c
   trunk/mapserver/mapscale.c
   trunk/mapserver/mapserver.h
   trunk/mapserver/mapsvg.c
Log:
 * refactor msGetLabelSizeEx (now merged with msGetLabelSize) (#2390)
 * native label size computation for AGG when using angle follow (#2357)


Modified: trunk/mapserver/HISTORY.TXT
===================================================================
--- trunk/mapserver/HISTORY.TXT	2008-10-04 01:25:54 UTC (rev 7953)
+++ trunk/mapserver/HISTORY.TXT	2008-10-04 10:59:35 UTC (rev 7954)
@@ -11,9 +11,12 @@
 
 Current Version (5.3-dev, SVN trunk):
 ------------------------------------
+- refactor msGetLabelSizeEx (now merged with msGetLabelSize) (#2390)
 
-- memory leak in msInsertLayer, from Ned Horning (#2784)
+- native label size computation for AGG when using angle follow (#2357)
 
+- memory leak in msInsertLayer, from Ned Harding (#2784)
+
 - label size computation refactoring (#2390)
 
 - don't draw label background if we're using angle follow. (#2726)

Modified: trunk/mapserver/mapagg.cpp
===================================================================
--- trunk/mapserver/mapagg.cpp	2008-10-04 01:25:54 UTC (rev 7953)
+++ trunk/mapserver/mapagg.cpp	2008-10-04 10:59:35 UTC (rev 7954)
@@ -675,9 +675,8 @@
         return MS_SUCCESS;
     }
     
-    int getLabelSize(char *string, char *font, double size, rectObj *rect) {
+    int getLabelSize(char *string, char *font, double size, rectObj *rect, double **advances) {
 
-
         if(!m_feng.load_font(font, 0, agg::glyph_ren_outline)) {
             msSetError(MS_TTFERR, "AGG error loading font (%s)", "getLabelSize()", font);
             return MS_FAILURE;
@@ -686,7 +685,10 @@
         m_feng.height(size);
         m_feng.resolution(96);
         m_feng.flip_y(true);
-        int unicode;
+        int unicode,curGlyph=1,numglyphs;
+        if(advances) {
+            numglyphs=msGetNumGlyphs(string);
+        }
         const agg::glyph_cache* glyph;
         string+=msUTF8ToUniChar(string, &unicode);
         glyph=m_fman.glyph(unicode);
@@ -698,8 +700,16 @@
         }
         else
             return MS_FAILURE;
+        if(advances) {
+            *advances = (double*)malloc(numglyphs*sizeof(double));
+            (*advances)[0]=glyph->advance_x;
+        }
         double fx=glyph->advance_x,fy=glyph->advance_y;
         while(*string) {
+            if(advances) {
+                if(*string=='\r' || *string=='\n')
+                    (*advances)[curGlyph++]=-fx;
+            }
             if(*string=='\r') {fx=0;string++;continue;}
             if(*string=='\n') {fx=0;fy+=ceil(size*LINESPACE);string++;continue;}
             string+=msUTF8ToUniChar(string, &unicode);
@@ -714,15 +724,18 @@
 
                 fx += glyph->advance_x;
                 fy += glyph->advance_y;
+                if(advances) {
+                    double x,y;
+                    x=glyph->advance_x;
+                    m_fman.add_kerning(&x,&y);
+                    (*advances)[curGlyph++]=x;
+                }
             }
         }
-        /*rect->minx--;
-        rect->miny--;
-        rect->maxx++;
-        rect->maxy++;*/
         return MS_SUCCESS;
     }
     
+      
     ///render a freetype string
     ///@param x,y the lower left corner where to start the string, or the center of
     ///     the character if isMarker is true
@@ -1235,7 +1248,7 @@
         if(!font) return;
         double x,y;
         rectObj bounds;
-        if(ren->getLabelSize(symbol->character,font,size,&bounds)!=MS_SUCCESS)
+        if(ren->getLabelSize(symbol->character,font,size,&bounds,NULL)!=MS_SUCCESS)
             return;
         x = p->x + ox - bounds.minx - (bounds.maxx-bounds.minx)/2.;
         y = p->y + oy - bounds.maxy + (bounds.maxy-bounds.miny)/2.;
@@ -1496,7 +1509,7 @@
         msSetError(MS_TTFERR, "Requested font (%s) not found.", "msDrawTextAGG()", label.font);
         return;
     }
-  if(ren->getLabelSize(symbol->character, font, label.size, &label_rect) != MS_SUCCESS)
+  if(ren->getLabelSize(symbol->character, font, label.size, &label_rect,NULL) != MS_SUCCESS)
     return;
 
   label_width = (int) label_rect.maxx - (int) label_rect.minx;
@@ -2032,9 +2045,9 @@
 
 }
 
-int msGetTruetypeTextBBoxAGG(imageObj *img, char *font, int size, char *string, rectObj *rect) {
+int msGetTruetypeTextBBoxAGG(imageObj *img, char *font, int size, char *string, rectObj *rect, double **advances) {
         AGGMapserverRenderer* ren = getAGGRenderer(img);
-        return ren->getLabelSize(string, font, size, rect);
+        return ren->getLabelSize(string, font, size, rect,advances);
 }
 
 int msGetRasterTextBBoxAGG(imageObj *img, int size, char *string, rectObj *rect) {
@@ -2341,7 +2354,7 @@
         if (label.type == MS_TRUETYPE) label.size = height;
         marker.x = dstX + MS_NINT(width / 2.0);
         marker.y = dstY + MS_NINT(height / 2.0);
-        if(msGetLabelSize(image, (char*)"Aa", &label, &label_rect, &map->fontset, 1.0, MS_FALSE) != -1)
+        if(msGetLabelSize(image, (char*)"Aa", &label, &label_rect, &map->fontset, 1.0, MS_FALSE,NULL) != -1)
         {
           pointObj label_point = get_metrics(&marker, MS_CC, label_rect, 0, 0, label.angle, 0, NULL);
           msDrawTextAGG(image, label_point, (char*)"Aa", &label, &map->fontset, 1.0);

Modified: trunk/mapserver/mapdraw.c
===================================================================
--- trunk/mapserver/mapdraw.c	2008-10-04 01:25:54 UTC (rev 7953)
+++ trunk/mapserver/mapdraw.c	2008-10-04 10:59:35 UTC (rev 7954)
@@ -1413,7 +1413,7 @@
         msTransformShape(&annoshape, map->extent, map->cellsize, image);
 
         if(layer->class[c]->label.autofollow == MS_TRUE ) {
-          annopath = msPolylineLabelPath(&annoshape, layer->class[c]->label.minfeaturesize, &(map->fontset), shape->text, &(layer->class[c]->label), layer->scalefactor, &status);
+          annopath = msPolylineLabelPath(image,&annoshape, layer->class[c]->label.minfeaturesize, &(map->fontset), shape->text, &(layer->class[c]->label), layer->scalefactor, &status);
         } else {
           annocallret = msPolylineLabelPoint(&annoshape, &annopnt, layer->class[c]->label.minfeaturesize, &angle, &length);
         }
@@ -1434,7 +1434,7 @@
 
         /* Determine the label path if it has not been computed above */
         if(bLabelNoClip == MS_FALSE)
-          annopath = msPolylineLabelPath(shape, layer->class[c]->label.minfeaturesize, &(map->fontset), shape->text, &(layer->class[c]->label), layer->scalefactor, &status);
+          annopath = msPolylineLabelPath(image,shape, layer->class[c]->label.minfeaturesize, &(map->fontset), shape->text, &(layer->class[c]->label), layer->scalefactor, &status);
 
         if( annopath ) {
           labelObj label = layer->class[c]->label;
@@ -1614,7 +1614,7 @@
       msTransformShape(&annoshape, map->extent, map->cellsize, image);
 
       if(layer->class[c]->label.autofollow == MS_TRUE) {
-        annopath = msPolylineLabelPath(&annoshape, layer->class[c]->label.minfeaturesize, &(map->fontset), shape->text, &(layer->class[c]->label), layer->scalefactor, &status);
+        annopath = msPolylineLabelPath(image,&annoshape, layer->class[c]->label.minfeaturesize, &(map->fontset), shape->text, &(layer->class[c]->label), layer->scalefactor, &status);
       } else {
         annocallret = msPolylineLabelPoint(&annoshape, &annopnt, layer->class[c]->label.minfeaturesize, &angle, &length);
       }
@@ -1644,7 +1644,7 @@
         layer->class[c]->label.position = MS_CC; /* Force all label positions to MS_CC regardless if a path is computed */
 
         if (bLabelNoClip == MS_FALSE)
-          annopath = msPolylineLabelPath(shape, layer->class[c]->label.minfeaturesize, &(map->fontset), shape->text, &(layer->class[c]->label), layer->scalefactor, &status);
+          annopath = msPolylineLabelPath(image,shape, layer->class[c]->label.minfeaturesize, &(map->fontset), shape->text, &(layer->class[c]->label), layer->scalefactor, &status);
 
         if(annopath) {
           labelObj label = layer->class[c]->label;
@@ -1992,7 +1992,7 @@
     initStyle(&style);
   }
 
-  if(msGetLabelSize(image, string, label, &r, &(map->fontset), scalefactor, MS_FALSE) == -1) return(-1);
+  if(msGetLabelSize(image, string, label, &r, &(map->fontset), scalefactor, MS_FALSE,NULL) == -1) return(-1);
 
   if(label->position != MS_XY) {
     pointObj p;
@@ -2151,7 +2151,7 @@
           if(!cachePtr->text || strlen(cachePtr->text) == 0)
             continue; /* not an error, just don't want to do anything */
 
-          if(msGetLabelSize(image,cachePtr->text, labelPtr, &r, &(map->fontset), layerPtr->scalefactor, MS_TRUE) == -1)
+          if(msGetLabelSize(image,cachePtr->text, labelPtr, &r, &(map->fontset), layerPtr->scalefactor, MS_TRUE,NULL) == -1)
             return(-1);
           if(labelPtr->autominfeaturesize && ((r.maxx-r.minx) > cachePtr->featuresize))
             continue; /* label too large relative to the feature */

Modified: trunk/mapserver/mapgd.c
===================================================================
--- trunk/mapserver/mapgd.c	2008-10-04 01:25:54 UTC (rev 7953)
+++ trunk/mapserver/mapgd.c	2008-10-04 10:59:35 UTC (rev 7954)
@@ -3230,7 +3230,7 @@
         if (label.type == MS_TRUETYPE) label.size = height;
         marker.x = dstX + MS_NINT(width / 2.0);
         marker.y = dstY + MS_NINT(height / 2.0);
-        if(msGetLabelSize(NULL,"Aa", &label, &label_rect, &map->fontset, 1.0, MS_FALSE) != -1)
+        if(msGetLabelSize(NULL,"Aa", &label, &label_rect, &map->fontset, 1.0, MS_FALSE,NULL) != -1)
         {
           pointObj label_point = get_metrics(&marker, MS_CC, label_rect, 0, 0, label.angle, 0, NULL);
           msDrawTextGD(img, label_point, "Aa", &label, &map->fontset, 1.0);

Modified: trunk/mapserver/mapgraticule.c
===================================================================
--- trunk/mapserver/mapgraticule.c	2008-10-04 01:25:54 UTC (rev 7953)
+++ trunk/mapserver/mapgraticule.c	2008-10-04 10:59:35 UTC (rev 7954)
@@ -630,7 +630,7 @@
   if(pLayer->transform) 
     msTransformShapeToPixel(pShape, pLayer->map->extent, pLayer->map->cellsize);
 
-  if(msGetLabelSize(NULL, pShape->text, &pLayer->class[0]->label, &rectLabel, &pLayer->map->fontset, 1.0, MS_FALSE) != 0)
+  if(msGetLabelSize(NULL, pShape->text, &pLayer->class[0]->label, &rectLabel, &pLayer->map->fontset, 1.0, MS_FALSE,NULL) != 0)
     return MS_FAILURE;  /* msSetError already called */
 
   switch( ePosition ) {

Modified: trunk/mapserver/mapimagemap.c
===================================================================
--- trunk/mapserver/mapimagemap.c	2008-10-04 01:25:54 UTC (rev 7953)
+++ trunk/mapserver/mapimagemap.c	2008-10-04 10:59:35 UTC (rev 7954)
@@ -1850,7 +1850,7 @@
     if(cachePtr->label.type == MS_TRUETYPE)
       cachePtr->label.size = (int)(cachePtr->label.size*layerPtr->scalefactor);
 
-    if(msGetLabelSize(img,cachePtr->text, labelPtr, &r, &(map->fontset), layerPtr->scalefactor, MS_TRUE) == -1)
+    if(msGetLabelSize(img,cachePtr->text, labelPtr, &r, &(map->fontset), layerPtr->scalefactor, MS_TRUE,NULL) == -1)
       return(-1);
 
     if(labelPtr->autominfeaturesize && ((r.maxx-r.minx) > cachePtr->featuresize))

Modified: trunk/mapserver/maplabel.c
===================================================================
--- trunk/mapserver/maplabel.c	2008-10-04 01:25:54 UTC (rev 7953)
+++ trunk/mapserver/maplabel.c	2008-10-04 10:59:35 UTC (rev 7954)
@@ -192,7 +192,7 @@
          * that the integer rounding for such a number of spaces will be negligeable
          * compared to the actual size of thoses spaces */ 
         if(msGetLabelSize(image, "                ", label,&label_rect, 
-                    &map->fontset, 1.0, MS_FALSE)==-1) { 
+                    &map->fontset, 1.0, MS_FALSE,NULL)==-1) { 
             /*error computing label size, we can't continue*/
 
             /*free the previously allocated split text*/
@@ -230,7 +230,7 @@
     /*length in pixels of the longest line*/
     maxlinelength=0;
     for(i=0;i<numlines;i++) {
-        msGetLabelSize(image, textlines[i], label, &label_rect, &map->fontset, 1.0, MS_FALSE);
+        msGetLabelSize(image, textlines[i], label, &label_rect, &map->fontset, 1.0, MS_FALSE, NULL);
         textlinelengths[i] = label_rect.maxx-label_rect.minx;
         if(maxlinelength<textlinelengths[i])
             maxlinelength=textlinelengths[i];
@@ -642,26 +642,63 @@
 #endif
 }
 
-int msGetTruetypeTextBBox(imageObj *img, char *font, int size, char *string, rectObj *rect) {
+int msGetTruetypeTextBBox(imageObj *img, char *font, int size, char *string, rectObj *rect, double **advances) {
 #ifdef USE_GD_FT
 #ifdef USE_AGG
     if(img!=NULL && MS_RENDERER_AGG(img->format)) {
-        return msGetTruetypeTextBBoxAGG(img,font,size,string,rect); 
+        return msGetTruetypeTextBBoxAGG(img,font,size,string,rect,advances); 
     } else
 #endif
     {
         int bbox[8];
-        char *error = gdImageStringFT(NULL, bbox, 0, font, size, 0, 0, 0, string);
-        if(error) {
-            msSetError(MS_TTFERR, error, "msGetTruetypeTextBBox()");
-            return(MS_FAILURE);
-        }
+        char *error;
+        if(advances) {
+#if defined (GD_HAS_FTEX_XSHOW)
+            char *s;
+            int k;
+            gdFTStringExtra strex;
+            strex.flags = gdFTEX_XSHOW;
+            error = gdImageStringFTEx(NULL, bbox, 0, font, size, 0, 0, 0, string, &strex);
+            if(error) {
+                msSetError(MS_TTFERR, error, "gdImageStringFTEx()");
+                return(MS_FAILURE);
+            }
 
-        rect->minx = bbox[0];
-        rect->miny = bbox[5];
-        rect->maxx = bbox[2];
-        rect->maxy = bbox[1];
-        return MS_SUCCESS;
+            *advances = (double*)malloc( strlen(string) * sizeof(double) );
+            s = strex.xshow;
+            k = 0;
+            while ( *s && k < strlen(string) ) {
+                (*advances)[k++] = atof(s);      
+                while ( *s && *s != ' ')
+                    s++;
+                if ( *s == ' ' )
+                    s++;
+            }
+
+            gdFree(strex.xshow); /* done with character advances */
+
+            rect->minx = bbox[0];
+            rect->miny = bbox[5];
+            rect->maxx = bbox[2];
+            rect->maxy = bbox[1];
+            return MS_SUCCESS;
+#else
+            msSetError(MS_TTFERR, "gdImageStringFTEx support is not available or is not current enough (requires 2.0.29 or higher).", "msGetTruetypeTextBBox()");
+            return(-1);
+#endif
+        } else {
+            error = gdImageStringFT(NULL, bbox, 0, font, size, 0, 0, 0, string);
+            if(error) {
+                msSetError(MS_TTFERR, error, "msGetTruetypeTextBBox()");
+                return(MS_FAILURE);
+            }
+
+            rect->minx = bbox[0];
+            rect->miny = bbox[5];
+            rect->maxx = bbox[2];
+            rect->maxy = bbox[1];
+            return MS_SUCCESS;
+        }
     }
 #else
     /*shouldn't happen*/
@@ -705,7 +742,7 @@
 */
 
 /* assumes an angle of 0 regardless of what's in the label object */
-int msGetLabelSize(imageObj *img, char *string, labelObj *label, rectObj *rect, fontSetObj *fontset, double scalefactor, int adjustBaseline)
+int msGetLabelSize(imageObj *img, char *string, labelObj *label, rectObj *rect, fontSetObj *fontset, double scalefactor, int adjustBaseline, double **advances)
 {
   int size;
   if(label->type == MS_TRUETYPE) {
@@ -725,7 +762,7 @@
       return(-1);
     }
 
-    if(msGetTruetypeTextBBox(img,font,size,string,rect)!=MS_SUCCESS)
+    if(msGetTruetypeTextBBox(img,font,size,string,rect,advances)!=MS_SUCCESS)
         return MS_FAILURE;
 
     /* bug 1449 fix (adjust baseline) */
@@ -738,7 +775,7 @@
       else {
         rectObj rect2; /*bbox of first line only*/
         char* firstLine = msGetFirstLine(string);
-        msGetTruetypeTextBBox(img,font,size,firstLine,&rect2);
+        msGetTruetypeTextBBox(img,font,size,firstLine,&rect2,NULL);
         label->offsety += MS_NINT(((rect2.miny+rect2.maxy) + size) / 2);
         label->offsetx += MS_NINT(rect2.minx / 2);
         free(firstLine);
@@ -755,73 +792,6 @@
   return(0);
 }
 
-/*
- * Return the size of the label, plus an array of individual character
- * offsets, as calculated by gdImageStringFTEx().  The callee is
- * responsible for freeing *offsets.
- */
-int msGetLabelSizeEx(char *string, labelObj *label, rectObj *rect, fontSetObj *fontset, double scalefactor, int adjustBaseline, double **offsets) 
-{
-#if defined (USE_GD_FT) && defined (GD_HAS_FTEX_XSHOW)
-    int size;
-    char *s;
-    int k;
-    int bbox[8];
-    char *error=NULL, *font=NULL;
-    gdFTStringExtra strex;
-    
-    size = MS_NINT(label->size*scalefactor);
-    size = MS_MAX(size, label->minsize);
-    size = MS_MIN(size, label->maxsize);
-
-    font = msLookupHashTable(&(fontset->fonts), label->font);
-    if(!font) {
-      if(label->font) 
-        msSetError(MS_TTFERR, "Requested font (%s) not found.", "msGetLabelSizeEx()", label->font);
-      else
-        msSetError(MS_TTFERR, "Requested font (NULL) not found.", "msGetLabelSizeEx()");
-      return(-1);
-    }
-
-    strex.flags = gdFTEX_XSHOW;
-    error = gdImageStringFTEx(NULL, bbox, 0, font, size, 0, 0, 0, string, &strex);
-    if(error) {
-      msSetError(MS_TTFERR, error, "msGetLabelSizeEx()");
-      return(-1);
-    }
-
-    *offsets = (double*)malloc( strlen(string) * sizeof(double) );
-    
-    s = strex.xshow;
-    k = 0;
-    while ( *s && k < strlen(string) ) {
-      (*offsets)[k++] = atof(s);      
-      while ( *s && *s != ' ')
-        s++;
-      if ( *s == ' ' )
-        s++;
-    }
-
-    gdFree(strex.xshow); /* done with character advances */
-
-    rect->minx = bbox[0];
-    rect->miny = bbox[5];
-    rect->maxx = bbox[2];
-    rect->maxy = bbox[1];
-
-    /* bug 1449 fix (adjust baseline) */
-    if(adjustBaseline) {
-      label->offsety += MS_NINT(((bbox[5] + bbox[1]) + size) / 2);
-      label->offsetx += MS_NINT(bbox[0] / 2);
-    }
-
-    return MS_SUCCESS;
-#else
-    msSetError(MS_TTFERR, "TrueType font support is not available or is not current enough (requires 2.0.29 or higher).", "msGetLabelSizeEx()");
-    return(-1);
-#endif
-}
-
 gdFontPtr msGetBitmapFont(int size)
 {
   switch(size) { /* set the font to use */
@@ -1088,7 +1058,7 @@
   label.outlinecolor = style->outlinecolor;
   label.antialias = symbol->antialias;
   
-  if(msGetLabelSize(NULL,symbol->character, &label, &label_rect, symbolset->fontset, scalefactor, MS_FALSE) == -1)
+  if(msGetLabelSize(NULL,symbol->character, &label, &label_rect, symbolset->fontset, scalefactor, MS_FALSE,NULL) == -1)
     return(-1);
 
   label_width = (int) label_rect.maxx - (int) label_rect.minx;

Modified: trunk/mapserver/maplegend.c
===================================================================
--- trunk/mapserver/maplegend.c	2008-10-04 01:25:54 UTC (rev 7953)
+++ trunk/mapserver/maplegend.c	2008-10-04 10:59:35 UTC (rev 7954)
@@ -190,7 +190,7 @@
        else
          transformedText = strdup(lp->class[j]->name);
 
-       if(transformedText == NULL || msGetLabelSize(NULL,transformedText, &map->legend.label, &rect, &(map->fontset), 1.0, MS_FALSE) != 0) { /* something bad happened */
+       if(transformedText == NULL || msGetLabelSize(NULL,transformedText, &map->legend.label, &rect, &(map->fontset), 1.0, MS_FALSE,NULL) != 0) { /* something bad happened */
          if(transformedText) msFree(transformedText);
          return MS_FAILURE;
        }
@@ -297,7 +297,7 @@
       cur->pred = head;
       head = cur;
 
-      if(cur->transformedText==NULL || msGetLabelSize(NULL,cur->transformedText, &map->legend.label, &rect, &(map->fontset), 1.0, MS_FALSE) != 0) { /* something bad happened, free allocated mem */
+      if(cur->transformedText==NULL || msGetLabelSize(NULL,cur->transformedText, &map->legend.label, &rect, &(map->fontset), 1.0, MS_FALSE,NULL) != 0) { /* something bad happened, free allocated mem */
         while(cur) {
           if(cur->transformedText!=cur->theclass->name)
             free(cur->transformedText);

Modified: trunk/mapserver/mappdf.c
===================================================================
--- trunk/mapserver/mappdf.c	2008-10-04 01:25:54 UTC (rev 7953)
+++ trunk/mapserver/mappdf.c	2008-10-04 10:59:35 UTC (rev 7954)
@@ -451,7 +451,7 @@
         pointObj p;
         rectObj r;
 
-        if(msGetLabelSize(image,string, label, &r, fontset, scalefactor, MS_FALSE) == -1) return(-1);
+        if(msGetLabelSize(image,string, label, &r, fontset, scalefactor, MS_FALSE,NULL) == -1) return(-1);
         p = get_metrics(&labelPnt, label->position, r,
                                    label->offsetx,
                                    label->offsety,
@@ -534,7 +534,7 @@
         if(strlen(cachePtr->text) == 0)
             continue; /* not an error, just don't want to do anything */
 
-        if(msGetLabelSize(image,cachePtr->text, labelPtr, &r, &(map->fontset), layerPtr->scalefactor, MS_TRUE) == -1)
+        if(msGetLabelSize(image,cachePtr->text, labelPtr, &r, &(map->fontset), layerPtr->scalefactor, MS_TRUE,NULL) == -1)
             return(-1);
 
         if(labelPtr->autominfeaturesize && ((r.maxx-r.minx) > cachePtr->featuresize))

Modified: trunk/mapserver/mapprimitive.c
===================================================================
--- trunk/mapserver/mapprimitive.c	2008-10-04 01:25:54 UTC (rev 7953)
+++ trunk/mapserver/mapprimitive.c	2008-10-04 10:59:35 UTC (rev 7954)
@@ -1204,7 +1204,7 @@
  * polyline must be converted to image coordinates before calling this
  * function.
  */
-labelPathObj* msPolylineLabelPath(shapeObj *p, int min_length, fontSetObj *fontset, char *string, labelObj *label, double scalefactor, int *status)
+labelPathObj* msPolylineLabelPath(imageObj *img,shapeObj *p, int min_length, fontSetObj *fontset, char *string, labelObj *label, double scalefactor, int *status)
 {
   double line_length, max_line_length, segment_length, total_length, distance_along_segment;
   double fwd_line_length, rev_line_length, text_length, text_start_length;
@@ -1290,7 +1290,7 @@
     goto FAILURE;
   
   /* determine the total length of the text */
-  if (msGetLabelSizeEx(string, label, &bbox, fontset, scalefactor, MS_FALSE, &offsets) == MS_FAILURE) {
+  if (msGetLabelSize(img,string, label, &bbox, fontset, scalefactor, MS_FALSE, &offsets) == MS_FAILURE) {
     *status = MS_FAILURE;
     goto FAILURE;
   }

Modified: trunk/mapserver/mapscale.c
===================================================================
--- trunk/mapserver/mapscale.c	2008-10-04 01:25:54 UTC (rev 7953)
+++ trunk/mapserver/mapscale.c	2008-10-04 10:59:35 UTC (rev 7954)
@@ -311,7 +311,7 @@
       p.x = ox + j*isx; /* + MS_NINT(fontPtr->w/2); */
       p.y = oy + map->scalebar.height + MS_NINT(VSPACING*fontPtr->h);
       if(msGetLabelSize(NULL,label,&(map->scalebar.label), &r, 
-              &(map->fontset), 1, MS_FALSE) == -1) return(NULL);
+              &(map->fontset), 1, MS_FALSE,NULL) == -1) return(NULL);
       p2 = get_metrics(&p, MS_CC, r, 0,0, 0, 0, NULL);
       msDrawTextGD(image->img.gd, p2, label, &(map->scalebar.label), &(map->fontset), 1.0);
 
@@ -324,7 +324,7 @@
     p.x = ox; /* + MS_NINT(fontPtr->w/2); */
     p.y = oy + map->scalebar.height + MS_NINT(VSPACING*fontPtr->h);
     if(msGetLabelSize(NULL,label,&(map->scalebar.label), &r, 
-            &(map->fontset), 1, MS_FALSE) == -1) return(NULL);
+            &(map->fontset), 1, MS_FALSE,NULL) == -1) return(NULL);
     p2 = get_metrics(&p, MS_CR, r, 0,0, 0, 0, NULL);
     msDrawTextGD(image->img.gd, p2, label, &(map->scalebar.label), &(map->fontset), 1.0);
 
@@ -344,7 +344,7 @@
       p.x = ox + j*isx; /* + MS_NINT(fontPtr->w/2); */
       p.y = oy + map->scalebar.height + MS_NINT(VSPACING*fontPtr->h);
       if(msGetLabelSize(NULL,label,&(map->scalebar.label), &r, 
-              &(map->fontset), 1, MS_FALSE) == -1) return(NULL);
+              &(map->fontset), 1, MS_FALSE,NULL) == -1) return(NULL);
       p2 = get_metrics(&p, MS_CC, r, 0,0, 0, 0, NULL);
       msDrawTextGD(image->img.gd, p2, label, &(map->scalebar.label), &(map->fontset), 1.0);
 
@@ -360,7 +360,7 @@
     p.x = ox; /* + MS_NINT(fontPtr->w/2); */
     p.y = oy + map->scalebar.height + MS_NINT(VSPACING*fontPtr->h);
     if(msGetLabelSize(NULL,label,&(map->scalebar.label), &r, 
-            &(map->fontset), 1, MS_FALSE) == -1) return(NULL);
+            &(map->fontset), 1, MS_FALSE,NULL) == -1) return(NULL);
     p2 = get_metrics(&p, MS_CR, r, 0,0, 0, 0, NULL);
     msDrawTextGD(image->img.gd, p2, label, &(map->scalebar.label), &(map->fontset), 1.0);
 

Modified: trunk/mapserver/mapserver.h
===================================================================
--- trunk/mapserver/mapserver.h	2008-10-04 01:25:54 UTC (rev 7953)
+++ trunk/mapserver/mapserver.h	2008-10-04 10:59:35 UTC (rev 7954)
@@ -1701,8 +1701,7 @@
 MS_DLL_EXPORT int msInitFontSet(fontSetObj *fontset);
 MS_DLL_EXPORT int msFreeFontSet(fontSetObj *fontset);
 MS_DLL_EXPORT char *msTransformLabelText(mapObj *map, imageObj* image, labelObj *label, char *text);
-MS_DLL_EXPORT int msGetLabelSize(imageObj *img, char *string, labelObj *label, rectObj *rect, fontSetObj *fontSet, double scalefactor, int adjustBaseline);
-MS_DLL_EXPORT int msGetLabelSizeEx(char *string, labelObj *label, rectObj *rect, fontSetObj *fontSet, double scalefactor, int adjustBaseline, double **offsets);
+MS_DLL_EXPORT int msGetLabelSize(imageObj *img, char *string, labelObj *label, rectObj *rect, fontSetObj *fontSet, double scalefactor, int adjustBaseline,double **advances);
 MS_DLL_EXPORT int msAddLabel(mapObj *map, int layerindex, int classindex, int shapeindex, int tileindex, pointObj *point, labelPathObj *labelpath, char *string, double featuresize, labelObj *label);
 MS_DLL_EXPORT void msTestLabelCacheCollisions(labelCacheObj *labelcache, labelObj *labelPtr, int mapwidth, int mapheight, int buffer, labelCacheMemberObj *cachePtr, int current_priority, int current_label);
 MS_DLL_EXPORT labelCacheMemberObj *msGetLabelCacheMember(labelCacheObj *labelcache, int i);
@@ -1731,7 +1730,7 @@
 MS_DLL_EXPORT void msTransformPixelToShape(shapeObj *shape, rectObj extent, double cellsize);
 MS_DLL_EXPORT void msImageCartographicPolyline(gdImagePtr im, shapeObj *p, styleObj *style, symbolObj *symbol, int c, double size, double scalefactor);
 MS_DLL_EXPORT int msPolylineLabelPoint(shapeObj *p, pointObj *lp, int min_length, double *angle, double *length);
-MS_DLL_EXPORT labelPathObj* msPolylineLabelPath(shapeObj *p, int min_length, fontSetObj *fontset, char *string, labelObj *label, double scalefactor, int *status);
+MS_DLL_EXPORT labelPathObj* msPolylineLabelPath(imageObj *img, shapeObj *p, int min_length, fontSetObj *fontset, char *string, labelObj *label, double scalefactor, int *status);
 MS_DLL_EXPORT int msPolygonLabelPoint(shapeObj *p, pointObj *lp, int min_dimension);
 MS_DLL_EXPORT int msAddLine(shapeObj *p, lineObj *new_line);
 MS_DLL_EXPORT int msAddLineDirectly(shapeObj *p, lineObj *new_line);
@@ -1947,7 +1946,7 @@
 MS_DLL_EXPORT void msDrawMarkerSymbolAGG(symbolSetObj *symbolset, imageObj *image, pointObj *p, styleObj *style, double scalefactor);
 MS_DLL_EXPORT void msDrawLineSymbolAGG(symbolSetObj *symbolset, imageObj *image, shapeObj *p, styleObj *style, double scalefactor);
 MS_DLL_EXPORT void msDrawShadeSymbolAGG(symbolSetObj *symbolset, imageObj *image,shapeObj *p, styleObj *style, double scalefactor);
-int msGetTruetypeTextBBoxAGG(imageObj *img, char *font, int size, char *string, rectObj *rect);
+int msGetTruetypeTextBBoxAGG(imageObj *img, char *font, int size, char *string, rectObj *rect, double **advances);
 int msGetRasterTextBBoxAGG(imageObj *img, int size, char *string, rectObj *rect);
 MS_DLL_EXPORT int msDrawTextAGG(imageObj *imgage, pointObj labelPnt, char *string, labelObj *label, fontSetObj *fontset, double scalefactor);
 MS_DLL_EXPORT int msDrawTextLineAGG(imageObj *image, char *string, labelObj *label, labelPathObj *labelpath, fontSetObj *fontset, double scalefactor);

Modified: trunk/mapserver/mapsvg.c
===================================================================
--- trunk/mapserver/mapsvg.c	2008-10-04 01:25:54 UTC (rev 7953)
+++ trunk/mapserver/mapsvg.c	2008-10-04 10:59:35 UTC (rev 7954)
@@ -1179,7 +1179,7 @@
     if(!cachePtr->text || strlen(cachePtr->text) == 0)
       continue; /* not an error, just don't want to do anything */
 
-    if(msGetLabelSize(image, cachePtr->text, labelPtr, &r, &(map->fontset), layerPtr->scalefactor, MS_TRUE) == -1)
+    if(msGetLabelSize(image, cachePtr->text, labelPtr, &r, &(map->fontset), layerPtr->scalefactor, MS_TRUE,NULL) == -1)
       return(-1);
 
     if(labelPtr->autominfeaturesize && ((r.maxx-r.minx) > cachePtr->featuresize))



More information about the mapserver-commits mailing list