Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Only do baseline adjustment on text, not on truetype symbols

git-svn-id: http://svn.osgeo.org/mapserver/trunk@13250 7532c77e-422f-0410-93f4-f0b67bdd69e2
  • Loading branch information...
commit a06618e3cd127030f24b5927187f40c81579d365 1 parent a9cc54b
@tbonfort tbonfort authored
View
13 mapcairo.c
@@ -456,7 +456,8 @@ int renderTileCairo(imageObj *img, imageObj *tile, double x, double y) {
#define CAIROLINESPACE 1.33
-int getTruetypeTextBBoxCairo(rendererVTableObj *renderer, char **fonts, int numfonts, double size, char *text, rectObj *rect, double **advances) {
+int getTruetypeTextBBoxCairo(rendererVTableObj *renderer, char **fonts, int numfonts, double size,
+ char *text, rectObj *rect, double **advances, int bAdjustBaseline) {
cairoCacheData *cache = MS_RENDERER_CACHE(renderer);
faceCacheObj* face = getFontFace(cache,fonts[0]);
@@ -524,11 +525,11 @@ int getTruetypeTextBBoxCairo(rendererVTableObj *renderer, char **fonts, int numf
rect->minx = px+extents.x_bearing;
rect->miny = py+extents.y_bearing;
rect->maxx = px+extents.x_bearing+extents.width;
- rect->maxy = py+1;
+ rect->maxy = py+(bAdjustBaseline?1:(extents.y_bearing+extents.height));
} else {
rect->minx = MS_MIN(rect->minx,px+extents.x_bearing);
rect->miny = MS_MIN(rect->miny,py+extents.y_bearing);
- rect->maxy = MS_MAX(rect->maxy,py+1);
+ rect->maxy = MS_MAX(rect->maxy,py+(bAdjustBaseline?1:(extents.y_bearing+extents.height)));
rect->maxx = MS_MAX(rect->maxx,px+extents.x_bearing+extents.width);
}
if(advances!=NULL)
@@ -537,12 +538,6 @@ int getTruetypeTextBBoxCairo(rendererVTableObj *renderer, char **fonts, int numf
previdx=glyph.index;
prevface = face;
}
- /*
- rect->minx = 0;
- rect->miny = 0;
- rect->maxx = 1;
- rect->maxy = 1;
- */
return MS_SUCCESS;
}
View
3  mapdummyrenderer.c
@@ -166,7 +166,8 @@ int saveImageDummy(imageObj *img, mapObj *map, FILE *fp, outputFormatObj *format
/*...*/
/* helper functions */
-int getTruetypeTextBBoxDummy(rendererVTableObj *renderer, char **fonts, int numfonts, double size, char *string,rectObj *rect, double **advances) {
+int getTruetypeTextBBoxDummy(rendererVTableObj *renderer, char **fonts, int numfonts, double size,
+ char *string,rectObj *rect, double **advances, int bAdjustBaseline) {
msSetError(MS_RENDERERERR,"getTruetypeTextBBox not implemented","getTruetypeTextBBox()");
return MS_FAILURE;
}
View
2  mapgd.c
@@ -833,7 +833,7 @@ int mergeRasterBufferGD(imageObj *dest, rasterBufferObj *overlay, double opacity
return MS_SUCCESS;
}
-int getTruetypeTextBBoxGD(rendererVTableObj *renderer, char **fonts, int numfonts, double size, char *string, rectObj *rect, double **advances) {
+int getTruetypeTextBBoxGD(rendererVTableObj *renderer, char **fonts, int numfonts, double size, char *string, rectObj *rect, double **advances, int bAdjustBaseline) {
#ifdef USE_GD_FT
int bbox[8];
char *error;
View
7 maplabel.c
@@ -965,13 +965,14 @@ int msLoadFontSet(fontSetObj *fontset, mapObj *map)
#endif
}
-int msGetTruetypeTextBBox(rendererVTableObj *renderer, char* fontstring, fontSetObj *fontset, double size, char *string, rectObj *rect, double **advances) {
+int msGetTruetypeTextBBox(rendererVTableObj *renderer, char* fontstring, fontSetObj *fontset,
+ double size, char *string, rectObj *rect, double **advances, int bAdjustbaseline) {
char *lookedUpFonts[MS_MAX_LABEL_FONTS];
int numfonts;
if(MS_FAILURE == msFontsetLookupFonts(fontstring, &numfonts, fontset, lookedUpFonts))
return MS_FAILURE;
if(renderer) {
- return renderer->getTruetypeTextBBox(renderer,lookedUpFonts,numfonts,size,string,rect,advances);
+ return renderer->getTruetypeTextBBox(renderer,lookedUpFonts,numfonts,size,string,rect,advances,bAdjustbaseline);
}
#ifdef USE_GD_FT
else {
@@ -1140,7 +1141,7 @@ int msGetLabelSize(mapObj *map, labelObj *label, char *string, double size, rect
msSetError(MS_MISCERR, "label has no true type font", "msGetLabelSize()");
return MS_FAILURE;
}
- return msGetTruetypeTextBBox(renderer,label->font,&(map->fontset),size,string,rect,advances);
+ return msGetTruetypeTextBBox(renderer,label->font,&(map->fontset),size,string,rect,advances,1);
} else if(label->type == MS_BITMAP){
if(renderer->supports_bitmap_fonts)
return msGetRasterTextBBox(renderer,MS_NINT(label->size),string,rect);
View
2  maprendering.c
@@ -326,7 +326,7 @@ int msImagePolylineMarkers(imageObj *image, shapeObj *p, symbolObj *symbol,
} else {
rectObj rect;
if(MS_SUCCESS != renderer->getTruetypeTextBBox(renderer,&symbol->full_font_path,1,style->scale,
- symbol->character,&rect,NULL))
+ symbol->character,&rect,NULL,0))
return MS_FAILURE;
symbol_width=rect.maxx-rect.minx;
symbol_height=rect.maxy-rect.miny;
View
4 mapserver.h
@@ -2028,7 +2028,7 @@ MS_DLL_EXPORT char *msFontsetLookupFont(fontSetObj *fontset, char *fontKey);
MS_DLL_EXPORT int msFontsetLookupFonts(char* fontstring, int *numfonts, fontSetObj *fontset, char **lookedUpFonts);
MS_DLL_EXPORT char *msTransformLabelText(mapObj *map, labelObj *label, char *text);
-MS_DLL_EXPORT int msGetTruetypeTextBBox(rendererVTableObj *renderer, char* fontstring, fontSetObj *fontset, double size, char *string, rectObj *rect, double **advances);
+MS_DLL_EXPORT int msGetTruetypeTextBBox(rendererVTableObj *renderer, char* fontstring, fontSetObj *fontset, double size, char *string, rectObj *rect, double **advances, int bAdjustBaseline);
MS_DLL_EXPORT int msGetLabelSize(mapObj *map, labelObj *label, char *string, double size, rectObj *rect, double **advances);
@@ -2789,7 +2789,7 @@ struct rendererVTableObj {
/*...*/
/* helper functions */
- int (*getTruetypeTextBBox)(rendererVTableObj *renderer, char **fonts, int numfonts, double size, char *string, rectObj *rect, double **advances);
+ int (*getTruetypeTextBBox)(rendererVTableObj *renderer, char **fonts, int numfonts, double size, char *string, rectObj *rect, double **advances, int bAdjustBaseline);
int (*startLayer)(imageObj *img, mapObj *map, layerObj *layer);
int (*endLayer)(imageObj *img, mapObj *map, layerObj *layer);
View
2  mapsymbol.c
@@ -675,7 +675,7 @@ int msGetMarkerSize(symbolSetObj *symbolset, styleObj *style, double *width, dou
#ifdef USE_GD_FT
case(MS_SYMBOL_TRUETYPE):
- if(msGetTruetypeTextBBox(MS_MAP_RENDERER(symbolset->map),symbol->font,symbolset->fontset,size,symbol->character,&rect,NULL) != MS_SUCCESS)
+ if(msGetTruetypeTextBBox(MS_MAP_RENDERER(symbolset->map),symbol->font,symbolset->fontset,size,symbol->character,&rect,NULL,0) != MS_SUCCESS)
return(MS_FAILURE);
*width = MS_MAX(*width, rect.maxx - rect.minx);
Please sign in to comment.
Something went wrong with that request. Please try again.