| 677 | } |
| 678 | |
| 679 | int msGetTruetypeTextBBox(rendererVTableObj *renderer, char *font, double size, char *string, rectObj *rect, double **advances) { |
| 680 | if(renderer) { |
| 681 | return renderer->getTruetypeTextBBox(renderer,font,size,string,rect,advances); |
| 682 | } |
| 683 | #ifdef USE_GD_FT |
| 684 | else { |
| 685 | int bbox[8]; |
| 686 | char *error; |
| 687 | if(advances) { |
| 688 | #if defined (GD_HAS_FTEX_XSHOW) |
| 689 | char *s; |
| 690 | int k; |
| 691 | gdFTStringExtra strex; |
| 692 | strex.flags = gdFTEX_XSHOW; |
| 693 | error = gdImageStringFTEx(NULL, bbox, 0, font, size, 0, 0, 0, string, &strex); |
| 694 | if(error) { |
| 695 | msSetError(MS_TTFERR, error, "gdImageStringFTEx()"); |
| 696 | return(MS_FAILURE); |
| 697 | } |
| 698 | |
| 699 | *advances = (double*)malloc( strlen(string) * sizeof(double) ); |
| 700 | MS_CHECK_ALLOC(*advances, strlen(string) * sizeof(double), MS_FAILURE); |
| 701 | s = strex.xshow; |
| 702 | k = 0; |
| 703 | while ( *s && k < strlen(string) ) { |
| 704 | (*advances)[k++] = atof(s); |
| 705 | while ( *s && *s != ' ') |
| 706 | s++; |
| 707 | if ( *s == ' ' ) |
| 708 | s++; |
| 709 | } |
| 710 | |
| 711 | gdFree(strex.xshow); /* done with character advances */ |
| 712 | |
| 713 | rect->minx = bbox[0]; |
| 714 | rect->miny = bbox[5]; |
| 715 | rect->maxx = bbox[2]; |
| 716 | rect->maxy = bbox[1]; |
| 717 | return MS_SUCCESS; |
| 718 | #else |
| 719 | msSetError(MS_TTFERR, "gdImageStringFTEx support is not available or is not current enough (requires 2.0.29 or higher).", "msGetTruetypeTextBBox()"); |
| 720 | return MS_FAILURE; |
| 721 | #endif |
| 722 | } else { |
| 723 | error = gdImageStringFT(NULL, bbox, 0, font, size, 0, 0, 0, string); |
| 724 | if(error) { |
| 725 | msSetError(MS_TTFERR, "gdImageStringFT: %s (%s)", "msGetTruetypeTextBBox()", error, font); |
| 726 | return(MS_FAILURE); |
| 727 | } |
| 728 | |
| 729 | rect->minx = bbox[0]; |
| 730 | rect->miny = bbox[5]; |
| 731 | rect->maxx = bbox[2]; |
| 732 | rect->maxy = bbox[1]; |
| 733 | return MS_SUCCESS; |
| 734 | } |
| 735 | } |
| 736 | #else |
no test coverage detected