* Simply draws a label based on the label point and the supplied label object. */
| 1664 | * Simply draws a label based on the label point and the supplied label object. |
| 1665 | */ |
| 1666 | int msDrawTextIM(imageObj* img, pointObj labelPnt, char *string, labelObj *label, fontSetObj *fontset, double scalefactor) |
| 1667 | { |
| 1668 | int x, y; |
| 1669 | |
| 1670 | |
| 1671 | DEBUG_IF printf("msDrawText<BR>\n"); |
| 1672 | if(!string) return(0); /* not errors, just don't want to do anything */ |
| 1673 | if(strlen(string) == 0) return(0); |
| 1674 | if(!dxf) return (0); |
| 1675 | x = MS_NINT(labelPnt.x); |
| 1676 | y = MS_NINT(labelPnt.y); |
| 1677 | |
| 1678 | if (dxf == 2) { |
| 1679 | im_iprintf (&imgStr, "TEXT\n%d\n%s\n%.0f\n%.0f\n%.0f\n" , matchdxfcolor(label->color), string, labelPnt.x, labelPnt.y, -label->angle); |
| 1680 | } else if (dxf) { |
| 1681 | im_iprintf (&imgStr, " 0\nTEXT\n 1\n%s\n 10\n%f\n 20\n%f\n 30\n0.0\n 40\n%f\n 50\n%f\n 62\n%6d\n 8\n%s\n 73\n 2\n 72\n 1\n" , string, labelPnt.x, labelPnt.y, label->size * scalefactor *100, -label->angle, matchdxfcolor(label->color), lname); |
| 1682 | } |
| 1683 | /* |
| 1684 | if(label->color.pen == MS_PEN_UNSET) msImageSetPenIM(img, &(label->color)); |
| 1685 | if(label->outlinecolor.pen == MS_PEN_UNSET) msImageSetPenIM(img, &(label->outlinecolor)); |
| 1686 | if(label->shadowcolor.pen == MS_PEN_UNSET) msImageSetPenIM(img, &(label->shadowcolor)); |
| 1687 | |
| 1688 | if(label->type == MS_TRUETYPE) { |
| 1689 | char *error=NULL, *font=NULL; |
| 1690 | int bbox[8]; |
| 1691 | double angle_radians = MS_DEG_TO_RAD*label->angle; |
| 1692 | double size; |
| 1693 | |
| 1694 | size = label->size*scalefactor; |
| 1695 | |
| 1696 | #if defined (USE_GD_FT) || defined (USE_GD_TTF) |
| 1697 | if(!fontset) { |
| 1698 | msSetError(MS_TTFERR, "No fontset defined.", "msDrawTextIM()"); |
| 1699 | return(-1); |
| 1700 | } |
| 1701 | |
| 1702 | if(!label->font) { |
| 1703 | msSetError(MS_TTFERR, "No Trueype font defined.", "msDrawTextIM()"); |
| 1704 | return(-1); |
| 1705 | } |
| 1706 | |
| 1707 | font = msLookupHashTable(&(fontset->fonts), label->font); |
| 1708 | if(!font) { |
| 1709 | msSetError(MS_TTFERR, "Requested font (%s) not found.", "msDrawTextIM()", |
| 1710 | label->font); |
| 1711 | return(-1); |
| 1712 | } |
| 1713 | |
| 1714 | if(label->outlinecolor.pen >= 0) { // handle the outline color // |
| 1715 | #ifdef USE_GD_TTF |
| 1716 | error = gdImageStringTTF(img, bbox, ((label->antialias)?(label->outlinecolor.pen):-(label->outlinecolor.pen)), font, size, angle_radians, x-1, y-1, string); |
| 1717 | #else |
| 1718 | error = gdImageStringFT(img, bbox, ((label->antialias)?(label->outlinecolor.pen):-(label->outlinecolor.pen)), font, size, angle_radians, x-1, y-1, string); |
| 1719 | #endif |
| 1720 | if(error) { |
| 1721 | msSetError(MS_TTFERR, error, "msDrawTextIM()"); |
| 1722 | return(-1); |
| 1723 | } |
no test coverage detected