#include #include #include using namespace std; int main(int argc, char **argv) { int pt = atoi(argv[1]), angle = atoi(argv[2]); char *font = "sans"; const double rad = M_PI/180; int br[8]; gdFTUseFontConfig(1); gdImageStringFT(NULL, br, 0, font, pt, angle*rad, 200, 200, argv[3]); int l = min(br[0], min(br[2], min(br[4], br[6]))), r = max(br[0], max(br[2], max(br[4], br[6]))), t = min(br[1], min(br[3], min(br[5], br[7]))), b = max(br[1], max(br[3], max(br[5], br[7]))); int w = 400, h = 400; gdImagePtr im = gdImageCreateTrueColor(w, h); int black = gdImageColorAllocateAlpha(im, 0, 0, 0, 0); int white = gdImageColorAllocateAlpha(im, 255, 255, 255, 0); gdImageFilledRectangle(im, 0, 0, w-1, h-1, white); gdImageRectangle(im, 0, 0, w-1, h-1, black); gdPoint point[4]; point[0].x = br[0]; point[0].y = br[1]; point[1].x = br[2]; point[1].y = br[3]; point[2].x = br[4]; point[2].y = br[5]; point[3].x = br[6]; point[3].y = br[7]; gdImagePolygon(im, point, 4, black); gdImageStringFT(im, NULL, black, font, pt, angle*rad, br[0], br[1], argv[3]); gdImagePngEx(im, stdout, 9); gdImageDestroy(im); }