Permalink
Browse files

Fix segfault on TTF symbols smaller than 1 pixel (#5086)

  • Loading branch information...
tbonfort committed Apr 2, 2015
1 parent 9da77c1 commit 29bbefa308ea45a0df2c9d588cce98aeb5832b1d
Showing with 5 additions and 5 deletions.
  1. +5 −5 maprendering.c
View
@@ -247,8 +247,8 @@ imageObj *getTile(imageObj *img, symbolObj *symbol, symbolStyleObj *s, int widt
if(UNLIKELY(!face)) { status = MS_FAILURE; break; }
msUTF8ToUniChar(symbol->character, &unicode);
unicode = msGetGlyphIndex(face,unicode);
- glyphc = msGetGlyphByIndex(face, s->scale, unicode);
- if(UNLIKELY(!face)) { status = MS_FAILURE; break; }
+ glyphc = msGetGlyphByIndex(face, MS_MAX(MS_NINT(s->scale),1), unicode);
+ if(UNLIKELY(!glyphc)) { status = MS_FAILURE; break; }
status = drawGlyphMarker(tileimg, face, glyphc, p_x, p_y, s->scale, s->rotation,
s->color, s->outlinecolor, s->outlinewidth);
}
@@ -311,7 +311,7 @@ imageObj *getTile(imageObj *img, symbolObj *symbol, symbolStyleObj *s, int widt
if(UNLIKELY(!face)) { status = MS_FAILURE; break; }
msUTF8ToUniChar(symbol->character, &unicode);
unicode = msGetGlyphIndex(face,unicode);
- glyphc = msGetGlyphByIndex(face, s->scale, unicode);
+ glyphc = msGetGlyphByIndex(face, MS_MAX(MS_NINT(s->scale),1), unicode);
if(UNLIKELY(!glyphc)) { status = MS_FAILURE; break; }
status = drawGlyphMarker(tileimg, face, glyphc, p_x, p_y, s->scale, s->rotation,
s->color, s->outlinecolor, s->outlinewidth);
@@ -384,7 +384,7 @@ int msImagePolylineMarkers(imageObj *image, shapeObj *p, symbolObj *symbol,
face = msGetFontFace(symbol->font, &image->map->fontset);
if(UNLIKELY(!face)) return MS_FAILURE;
unicode = msGetGlyphIndex(face,unicode);
- glyphc = msGetGlyphByIndex(face, style->scale, unicode);
+ glyphc = msGetGlyphByIndex(face, MS_MAX(MS_NINT(style->scale),1), unicode);
if(UNLIKELY(!glyphc)) return MS_FAILURE;
symbol_width = glyphc->metrics.maxx - glyphc->metrics.minx;
symbol_height = glyphc->metrics.maxy - glyphc->metrics.miny;
@@ -922,7 +922,7 @@ int msDrawMarkerSymbol(mapObj *map, imageObj *image, pointObj *p, styleObj *styl
if(UNLIKELY(!face)) return MS_FAILURE;
msUTF8ToUniChar(symbol->character,&unicode);
unicode = msGetGlyphIndex(face,unicode);
- glyphc = msGetGlyphByIndex(face,s.scale,unicode);
+ glyphc = msGetGlyphByIndex(face, MS_MAX(MS_NINT(s.scale),1), unicode);
if(UNLIKELY(!glyphc)) return MS_FAILURE;
ret = drawGlyphMarker(image, face, glyphc, p_x, p_y, s.scale, s.rotation, s.color, s.outlinecolor, s.outlinewidth);
}

0 comments on commit 29bbefa

Please sign in to comment.