Skip to content
Permalink
Browse files
5901 utf grid support for true type symbols (#5918)
* Ticket #5901 - Add support for TrueType symbol output in UTFGrid

* Add msautotests for TrueType symbols (and labels) in UTFGrid
  • Loading branch information
charles-plante authored and dmorissette committed Nov 12, 2019
1 parent e1a3b57 commit 8f2de5bdb002d4309cbde4b906fa862ffb39fedf
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 8 deletions.
@@ -560,7 +560,7 @@ int agg2RenderPolygonTiled(imageObj *img, shapeObj *p, imageObj * tile)
return MS_SUCCESS;
}

int agg2RenderGlyphsPath(imageObj *img, textPathObj *tp, colorObj *c, colorObj *oc, int ow) {
int agg2RenderGlyphsPath(imageObj *img, textPathObj *tp, colorObj *c, colorObj *oc, int ow, int isMarker) {
mapserver::path_storage glyphs;
mapserver::trans_affine trans;
AGG2Renderer *r = AGG_RENDERER(img);
@@ -409,7 +409,7 @@ int renderTileCairo(imageObj *img, imageObj *tile, double x, double y)
return MS_SUCCESS;
}

int renderGlyphs2Cairo(imageObj *img, textPathObj *tp, colorObj *c, colorObj *oc, int ow) {
int renderGlyphs2Cairo(imageObj *img, textPathObj *tp, colorObj *c, colorObj *oc, int ow, int isMarker) {
cairo_renderer *r = CAIRO_RENDERER(img);
cairoCacheData *cache = MS_IMAGE_RENDERER_CACHE(img);
cairoFaceCache *cairo_face = NULL;
@@ -213,7 +213,7 @@ int WARN_UNUSED drawGlyphMarker(imageObj *img, face_element *face, glyph_element
glyph.pnt.x = px - ox;
glyph.pnt.y = py + oy;
}
return renderer->renderGlyphs(img, &path, clr, oclr, olwidth);
return renderer->renderGlyphs(img, &path, clr, oclr, olwidth, MS_TRUE);
}


@@ -1049,7 +1049,7 @@ int msDrawTextSymbol(mapObj *map, imageObj *image, pointObj labelPnt, textSymbol
ts_shadow->textpath->glyphs[g].pnt.y += oy;
}

ret = renderer->renderGlyphs(image,ts_shadow->textpath,&ts->label->shadowcolor,NULL,0);
ret = renderer->renderGlyphs(image,ts_shadow->textpath,&ts->label->shadowcolor,NULL,0, MS_FALSE);
freeTextSymbol(ts_shadow);
msFree(ts_shadow);
if( ret != MS_SUCCESS )
@@ -1061,7 +1061,7 @@ int msDrawTextSymbol(mapObj *map, imageObj *image, pointObj labelPnt, textSymbol
if(MS_VALID_COLOR(ts->label->outlinecolor))
oc = &ts->label->outlinecolor;
ow = MS_NINT((double)ts->label->outlinewidth * ((double)ts->textpath->glyph_size / (double)ts->label->size));
return renderer->renderGlyphs(image,ts->textpath,c,oc,ow);
return renderer->renderGlyphs(image,ts->textpath,c,oc,ow, MS_FALSE);

}

@@ -3144,7 +3144,7 @@ void msPopulateTextSymbolForLabelAndString(textSymbolObj *ts, labelObj *l, char
int WARN_UNUSED (*renderPolygonTiled)(imageObj *img, shapeObj *p, imageObj *tile);
int WARN_UNUSED (*renderLineTiled)(imageObj *img, shapeObj *p, imageObj *tile);

int WARN_UNUSED (*renderGlyphs)(imageObj *img, textPathObj *tp, colorObj *clr, colorObj *olcolor, int olwidth);
int WARN_UNUSED (*renderGlyphs)(imageObj *img, textPathObj *tp, colorObj *clr, colorObj *olcolor, int olwidth, int isMarker);
int WARN_UNUSED (*renderText)(imageObj *img, pointObj *labelpnt, char *text, double angle, colorObj *clr, colorObj *olcolor, int olwidth);

int WARN_UNUSED (*renderVectorSymbol)(imageObj *img, double x, double y,
@@ -779,8 +779,39 @@ int utfgridRenderEllipseSymbol(imageObj *img, double x, double y, symbolObj *sym
return MS_SUCCESS;
}

int utfgridRenderGlyphs(imageObj *img, textPathObj *tp, colorObj *c, colorObj *oc, int ow) {
return MS_SUCCESS;
int utfgridRenderGlyphs(imageObj *img, textPathObj *tp, colorObj *c, colorObj *oc, int ow, int isMarker) {

UTFGridRenderer *r = UTFGRID_RENDERER(img);

/* If it's not a marker then it's a label or other thing and we dont
* want to draw it on the map
*/
if(!isMarker) {
return MS_SUCCESS; //Stop the rendering with no errors
}

/* utfvalue is set to 0 if the shape isn't in the table. */
if(r->utfvalue == 0) {
return MS_SUCCESS; //Stop the rendering with no errors
}

/* Pathing the symbol BBox */
mapserver::path_storage box;
double size, x, y;

size = tp->glyph_size;;
x = tp->glyphs->pnt.x;
y = tp->glyphs->pnt.y;

box.move_to((x)/r->utfresolution,(y)/r->utfresolution);
box.line_to((x+size)/r->utfresolution,(y)/r->utfresolution);
box.line_to((x+size)/r->utfresolution,(y-size)/r->utfresolution);
box.line_to((x)/r->utfresolution,(y-size)/r->utfresolution);

/* Rendering the symbol */
utfgridRenderPath(img, box);

return MS_SUCCESS;
}

int utfgridFreeSymbol(symbolObj * symbol)
@@ -0,0 +1 @@
{"grid":[" "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," !!!!! "," !!!!! "," !!!!! "," !!!!! "," "," "," "," "],"keys":["","1"],"data":{}}
@@ -0,0 +1 @@
{"grid":[" "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," "," !!!!! "," !!!!! "," !!!!! "," !!!!! "," "," "," "," "],"keys":["","1"],"data":{}}
@@ -0,0 +1,73 @@
# RUN_PARMS: utfgrid_truetype_symbol_labelcache.json [SHP2IMG] -m [MAPFILE] -l symbol-labelcache -i json -o [RESULT]
# RUN_PARMS: utfgrid_truetype_symbol_nolabelcache.json [SHP2IMG] -m [MAPFILE] -l symbol-nolabelcache -i json -o [RESULT]
#
#
MAP

STATUS ON
EXTENT 0 0 400 300
SIZE 200 150
FONTSET "../misc/fonts.lst"
IMAGETYPE png24
symbolset "symbolset"

# This layer renders the symbol to the utfgrid output but not the label
# (in this case the label is handled via the labelcache code path)
LAYER
NAME "symbol-labelcache"
TYPE point
STATUS OFF
LABELCACHE ON
CLASS
NAME "test1"
STYLE
SYMBOL "ttf"
COLOR 0 0 0
SIZE 15
END
LABEL
COLOR 12 0 150
OUTLINECOLOR 0 0 255
TYPE truetype
SIZE 6
POSITION AUTO
END
END
FEATURE
POINTS
50 50
END
TEXT 'label_sample'
END
END

# This layer renders the symbol to the utfgrid output but not the label
# (in this case the label is handled via the msDrawLabel() code path)
LAYER
NAME "symbol-nolabelcache"
TYPE point
STATUS OFF
LABELCACHE OFF
CLASS
NAME "test1"
STYLE
SYMBOL "ttf"
COLOR 0 0 0
SIZE 15
END
LABEL
COLOR 12 0 150
OUTLINECOLOR 0 0 255
TYPE truetype
SIZE 6
POSITION AUTO
END
END
FEATURE
POINTS
50 50
END
TEXT 'label_sample'
END
END
END #MAP

0 comments on commit 8f2de5b

Please sign in to comment.