main.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703
  1. /*
  2. ****************************************************************************
  3. *
  4. * MODULE: d.text
  5. *
  6. * AUTHOR(S): James Westervelt, US Army CERL
  7. * Updated by Huidae Cho, Markus Neteler
  8. *
  9. * PURPOSE: display text in active frame
  10. *
  11. * COPYRIGHT: (C) 2001 by the GRASS Development Team
  12. *
  13. * This program is free software under the GNU General Public
  14. * License (>=v2). Read the file COPYING that comes with GRASS
  15. * for details.
  16. *
  17. *****************************************************************************/
  18. /*
  19. * d.text commands:
  20. *
  21. * .F {font|path}[:charset] font
  22. * .C {color_name|RR:GG:BB|0xRRGGBB} color
  23. * .G {color_name|RR:GG:BB|0xRRGGBB} background color
  24. * .S [+|-]size[p] text size
  25. * +/-: relative size
  26. * p: size in pixels
  27. * .B {0|1} bold (double print) off/on
  28. * .A {ll|lc|lr|cl|cc|cr|ul|uc|ur} align (TODO)
  29. * .R [+|-]rotation[r] rotation
  30. * +/-: relative rotation
  31. * r: angle in radian
  32. * .I linespacing linespacing
  33. * .X [+|-]x[%|p] x: relative to x origin
  34. * +/-: relative dx
  35. * %: percentage
  36. * p: pixels
  37. * .Y [+|-]y[%|p] y: relative to y origin
  38. * +/-: relative dy
  39. * %: percentage
  40. * p: pixels
  41. * .L {0|1} linefeed off/on
  42. * .E [+|-]east[%|p] x origin: geographic coordinates
  43. * +/-: relative de
  44. * %: percentage
  45. * p: pixels
  46. * .N [+|-]north[%|p] y origin: geographic coordinates
  47. * +/-: relative dn
  48. * %: percentage
  49. * p: pixels
  50. * .. draw one dot (.)
  51. * .<SPACE> comments
  52. */
  53. #include <math.h>
  54. #include <stdio.h>
  55. #include <stdlib.h>
  56. #include <string.h>
  57. #include <unistd.h>
  58. #include <grass/gis.h>
  59. #include <grass/display.h>
  60. #include <grass/colors.h>
  61. #include <grass/glocale.h>
  62. #define BACKWARD_COMPATIBILITY
  63. #define DEFAULT_COLOR "gray"
  64. struct rectinfo
  65. {
  66. double t, b, l, r;
  67. };
  68. static void set_color(char *);
  69. static void get_coordinates(double *, double *, double *, double *,
  70. struct rectinfo, char **, char, char);
  71. static void draw_text(char *, double *, double *, double, char *, double, char,
  72. int, int, int);
  73. int main(int argc, char **argv)
  74. {
  75. struct GModule *module;
  76. struct
  77. {
  78. struct Option *text;
  79. struct Option *size;
  80. struct Option *fgcolor;
  81. struct Option *bgcolor;
  82. struct Option *line;
  83. struct Option *at;
  84. struct Option *rotation;
  85. struct Option *align;
  86. struct Option *linespacing;
  87. struct Option *font;
  88. struct Option *path;
  89. struct Option *charset;
  90. struct Option *input;
  91. } opt;
  92. struct
  93. {
  94. struct Flag *p;
  95. struct Flag *g;
  96. struct Flag *b;
  97. struct Flag *r;
  98. struct Flag *s;
  99. } flag;
  100. /* options and flags */
  101. char *text;
  102. double size;
  103. double x, y;
  104. int line;
  105. double rotation;
  106. char align[3];
  107. double linespacing;
  108. char bold;
  109. /* window info */
  110. struct rectinfo win;
  111. /* command file */
  112. FILE *cmd_fp;
  113. char buf[512];
  114. int first_text;
  115. int linefeed;
  116. int set_l;
  117. double orig_x, orig_y;
  118. double prev_x, prev_y;
  119. double set_x, set_y;
  120. double east, north;
  121. int do_background, fg_color, bg_color;
  122. /* initialize the GIS calls */
  123. G_gisinit(argv[0]);
  124. module = G_define_module();
  125. G_add_keyword(_("display"));
  126. G_add_keyword(_("cartography"));
  127. module->description =
  128. _("Draws text in the active display frame on the graphics monitor using the current font.");
  129. opt.text = G_define_option();
  130. opt.text->key = "text";
  131. opt.text->type = TYPE_STRING;
  132. opt.text->required = NO;
  133. opt.text->description = _("Text to display");
  134. opt.text->guisection = _("Input");
  135. opt.input = G_define_standard_option(G_OPT_F_INPUT);
  136. opt.input->required = NO;
  137. opt.input->description = _("Input file");
  138. opt.input->guisection = _("Input");
  139. opt.fgcolor = G_define_option();
  140. opt.fgcolor->key = "color";
  141. opt.fgcolor->type = TYPE_STRING;
  142. opt.fgcolor->answer = DEFAULT_COLOR;
  143. opt.fgcolor->required = NO;
  144. opt.fgcolor->description =
  145. _("Text color, either a standard GRASS color or R:G:B triplet");
  146. opt.fgcolor->gisprompt = "old_color,color,color";
  147. opt.fgcolor->guisection = _("Text");
  148. opt.bgcolor = G_define_option();
  149. opt.bgcolor->key = "bgcolor";
  150. opt.bgcolor->type = TYPE_STRING;
  151. opt.bgcolor->required = NO;
  152. opt.bgcolor->description =
  153. _("Text background color, either a standard GRASS color or R:G:B triplet");
  154. opt.bgcolor->gisprompt = "old_color,color,color";
  155. opt.bgcolor->guisection = _("Text");
  156. opt.rotation = G_define_option();
  157. opt.rotation->key = "rotation";
  158. opt.rotation->type = TYPE_DOUBLE;
  159. opt.rotation->required = NO;
  160. opt.rotation->answer = "0";
  161. opt.rotation->description =
  162. _("Rotation angle in degrees (counter-clockwise)");
  163. opt.rotation->guisection = _("Text");
  164. opt.linespacing = G_define_option();
  165. opt.linespacing->key = "linespacing";
  166. opt.linespacing->type = TYPE_DOUBLE;
  167. opt.linespacing->required = NO;
  168. opt.linespacing->answer = "1.25";
  169. opt.linespacing->description = _("Line spacing");
  170. opt.linespacing->guisection = _("Text");
  171. opt.at = G_define_option();
  172. opt.at->key = "at";
  173. opt.at->key_desc = "x,y";
  174. opt.at->type = TYPE_DOUBLE;
  175. opt.at->required = NO;
  176. opt.at->description =
  177. _("Screen position at which text will begin to be drawn (percentage, [0,0] is lower left)");
  178. opt.at->guisection = _("Position");
  179. opt.line = G_define_option();
  180. opt.line->key = "line";
  181. opt.line->required = NO;
  182. opt.line->type = TYPE_INTEGER;
  183. opt.line->options = "1-1000";
  184. opt.line->description =
  185. _("The screen line number on which text will begin to be drawn");
  186. opt.line->guisection = _("Position");
  187. opt.align = G_define_option();
  188. opt.align->key = "align";
  189. opt.align->type = TYPE_STRING;
  190. opt.align->required = NO;
  191. opt.align->answer = "ll";
  192. opt.align->options = "ll,lc,lr,cl,cc,cr,ul,uc,ur";
  193. opt.align->description = _("Text alignment");
  194. opt.align->guisection = _("Position");
  195. opt.font = G_define_option();
  196. opt.font->key = "font";
  197. opt.font->type = TYPE_STRING;
  198. opt.font->required = NO;
  199. opt.font->description = _("Font name");
  200. opt.font->guisection = _("Font settings");
  201. opt.size = G_define_option();
  202. opt.size->key = "size";
  203. opt.size->type = TYPE_DOUBLE;
  204. opt.size->required = NO;
  205. opt.size->answer = "5";
  206. opt.size->options = "0-100";
  207. opt.size->description =
  208. _("Height of letters in percentage of available frame height");
  209. opt.size->guisection = _("Font settings");
  210. opt.path = G_define_standard_option(G_OPT_F_INPUT);
  211. opt.path->key = "path";
  212. opt.path->required = NO;
  213. opt.path->description = _("Path to font file");
  214. opt.path->gisprompt = "old,font,file";
  215. opt.path->guisection = _("Font settings");
  216. opt.charset = G_define_option();
  217. opt.charset->key = "charset";
  218. opt.charset->type = TYPE_STRING;
  219. opt.charset->required = NO;
  220. opt.charset->description =
  221. _("Text encoding (only applicable to TrueType fonts)");
  222. opt.charset->guisection = _("Font settings");
  223. flag.p = G_define_flag();
  224. flag.p->key = 'p';
  225. flag.p->description = _("Screen position in pixels ([0,0] is top left)");
  226. flag.p->guisection = _("Position");
  227. flag.g = G_define_flag();
  228. flag.g->key = 'g';
  229. flag.g->description = _("Screen position in geographic coordinates");
  230. flag.g->guisection = _("Position");
  231. flag.b = G_define_flag();
  232. flag.b->key = 'b';
  233. flag.b->description = _("Use bold text");
  234. flag.b->guisection = _("Text");
  235. flag.r = G_define_flag();
  236. flag.r->key = 'r';
  237. flag.r->description = _("Use radians instead of degrees for rotation");
  238. flag.r->guisection = _("Text");
  239. flag.s = G_define_flag();
  240. flag.s->key = 's';
  241. flag.s->description = _("Font size is height in pixels");
  242. flag.s->guisection = _("Font settings");
  243. G_option_exclusive(opt.line, opt.at, NULL);
  244. G_option_exclusive(flag.p, flag.g, NULL);
  245. /* check command line */
  246. if (G_parser(argc, argv))
  247. exit(1);
  248. /* parse options */
  249. text = opt.text->answer;
  250. line = (opt.line->answer ? atoi(opt.line->answer) : 1);
  251. /* calculate rotation angle in radian */
  252. rotation = atof(opt.rotation->answer);
  253. if (!flag.r->answer)
  254. rotation *= M_PI / 180.0;
  255. rotation = fmod(rotation, 2.0 * M_PI);
  256. if (rotation < 0.0)
  257. rotation += 2.0 * M_PI;
  258. strncpy(align, opt.align->answer, 2);
  259. linespacing = atof(opt.linespacing->answer);
  260. bold = flag.b->answer;
  261. D_open_driver();
  262. if (opt.font->answer)
  263. D_font(opt.font->answer);
  264. else if (opt.path->answer)
  265. D_font(opt.path->answer);
  266. if (opt.charset->answer)
  267. D_encoding(opt.charset->answer);
  268. D_setup(0);
  269. /* figure out where to put text */
  270. D_get_dst(&win.t, &win.b, &win.l, &win.r);
  271. if (flag.s->answer)
  272. size = atof(opt.size->answer);
  273. else
  274. #ifdef BACKWARD_COMPATIBILITY
  275. size = atof(opt.size->answer) / 100.0 * (win.b - win.t) / linespacing;
  276. #else
  277. size = atof(opt.size->answer) / 100.0 * (win.b - win.t);
  278. #endif
  279. fg_color = D_parse_color(opt.fgcolor->answer, TRUE);
  280. if (opt.bgcolor->answer) {
  281. do_background = 1;
  282. bg_color = D_parse_color(opt.bgcolor->answer, TRUE);
  283. if (bg_color == 0) /* ie color="none" */
  284. do_background = 0;
  285. }
  286. else {
  287. do_background = 0;
  288. bg_color = 0;
  289. }
  290. set_color(opt.fgcolor->answer);
  291. orig_x = orig_y = 0;
  292. if (opt.at->answers) {
  293. get_coordinates(&x, &y, &east, &north, win, opt.at->answers,
  294. flag.p->answer, flag.g->answer);
  295. orig_x = x;
  296. orig_y = y;
  297. }
  298. else {
  299. x = win.l + (size * linespacing + 0.5) - size; /* d.text: +5 */
  300. y = win.t + line * (size * linespacing + 0.5);
  301. }
  302. prev_x = x;
  303. prev_y = y;
  304. D_text_size(size, size);
  305. D_text_rotation(rotation * 180.0 / M_PI);
  306. if (text) {
  307. if (text[0])
  308. draw_text(text, &x, &y, size, align, rotation, bold, do_background, fg_color, bg_color);
  309. /* reset */
  310. D_text_size(5, 5);
  311. D_text_rotation(0.0);
  312. D_save_command(G_recreate_command());
  313. D_close_driver();
  314. exit(EXIT_SUCCESS);
  315. }
  316. if (!opt.input->answer || strcmp(opt.input->answer, "-") == 0)
  317. cmd_fp = stdin;
  318. else {
  319. cmd_fp = fopen(opt.input->answer, "r");
  320. if (!cmd_fp)
  321. G_fatal_error(_("Unable to open input file <%s>"), opt.input->answer);
  322. }
  323. if (isatty(fileno(cmd_fp)))
  324. fprintf(stderr,
  325. _("\nPlease enter text instructions. Enter EOF (ctrl-d) on last line to quit\n"));
  326. set_x = set_y = set_l = 0;
  327. first_text = 1;
  328. linefeed = 1;
  329. /* do the plotting */
  330. while (fgets(buf, sizeof(buf), cmd_fp)) {
  331. int buf_len;
  332. char *buf_ptr, *ptr;
  333. buf_len = strlen(buf) - 1;
  334. for (; buf[buf_len] == '\r' || buf[buf_len] == '\n'; buf_len--) ;
  335. buf[buf_len + 1] = 0;
  336. if (buf[0] == '.' && buf[1] != '.') {
  337. int i;
  338. double d;
  339. G_squeeze(buf); /* added 6/91 DBS @ CWU */
  340. for (buf_ptr = buf + 2; *buf_ptr == ' '; buf_ptr++) ;
  341. buf_len = strlen(buf_ptr);
  342. switch (buf[1] & 0x7f) {
  343. case 'F':
  344. /* font */
  345. if ((ptr = strchr(buf_ptr, ':')))
  346. *ptr = 0;
  347. D_font(buf_ptr);
  348. if (ptr)
  349. D_encoding(ptr + 1);
  350. break;
  351. case 'C':
  352. /* color */
  353. set_color(buf_ptr);
  354. fg_color = D_parse_color(buf_ptr, 1);
  355. break;
  356. case 'G':
  357. /* background color */
  358. bg_color = D_parse_color(buf_ptr, 1);
  359. do_background = 1;
  360. break;
  361. case 'S':
  362. /* size */
  363. i = 0;
  364. if (strchr("+-", buf_ptr[0]))
  365. i = 1;
  366. d = atof(buf_ptr);
  367. if (buf_ptr[buf_len - 1] != 'p')
  368. #ifdef BACKWARD_COMPATIBILITY
  369. d *= (win.b - win.t) / 100.0 / linespacing;
  370. #else
  371. d *= (win.b - win.t) / 100.0;
  372. #endif
  373. size = d + (i ? size : 0);
  374. D_text_size(size, size);
  375. break;
  376. case 'B':
  377. /* bold */
  378. bold = (atoi(buf_ptr) ? 1 : 0);
  379. break;
  380. case 'A':
  381. /* align */
  382. strncpy(align, buf_ptr, 2);
  383. break;
  384. case 'R':
  385. /* rotation */
  386. i = 0;
  387. if (strchr("+-", buf_ptr[0]))
  388. i = 1;
  389. d = atof(buf_ptr);
  390. if (buf_ptr[buf_len - 1] != 'r')
  391. d *= M_PI / 180.0;
  392. d += (i ? rotation : 0.0);
  393. rotation = fmod(d, 2.0 * M_PI);
  394. if (rotation < 0.0)
  395. rotation += 2.0 * M_PI;
  396. D_text_rotation(rotation * 180.0 / M_PI);
  397. break;
  398. case 'I':
  399. /* linespacing */
  400. linespacing = atof(buf_ptr);
  401. break;
  402. case 'X':
  403. /* x */
  404. set_l = 0;
  405. set_x = 1;
  406. i = 0;
  407. if (strchr("+-", buf_ptr[0]))
  408. i = 1;
  409. d = atof(buf_ptr);
  410. if (buf_ptr[buf_len - 1] == '%')
  411. /* percentage */
  412. d *= (win.r - win.l) / 100.0;
  413. else if (buf_ptr[buf_len - 1] != 'p')
  414. /* column */
  415. d = (d - 1) * size * linespacing + 0.5;
  416. x = prev_x = d + (i ? x : orig_x);
  417. break;
  418. case 'Y':
  419. /* y */
  420. set_l = 0;
  421. set_y = 1;
  422. i = 0;
  423. if (strchr("+-", buf_ptr[0]))
  424. i = 1;
  425. d = atof(buf_ptr);
  426. if (buf_ptr[buf_len - 1] == '%')
  427. /* percentage */
  428. d = win.b - d * (win.b - win.t) / 100.0;
  429. else if (buf_ptr[buf_len - 1] != 'p')
  430. /* row */
  431. d *= size * linespacing + 0.5;
  432. y = prev_y = d + (i ? y : orig_y);
  433. break;
  434. case 'L':
  435. /* linefeed */
  436. set_l = 1;
  437. linefeed = (atoi(buf_ptr) ? 1 : 0);
  438. break;
  439. case 'E':
  440. i = 0;
  441. if (strchr("+-", buf_ptr[0]))
  442. i = 1;
  443. d = atof(buf_ptr);
  444. if (buf_ptr[buf_len - 1] == '%')
  445. d *= (win.r - win.l) / 100.0;
  446. else if (buf_ptr[buf_len - 1] != 'p')
  447. d = D_u_to_d_col(d);
  448. x = prev_x = orig_x = d + (i ? orig_x : win.l);
  449. break;
  450. case 'N':
  451. i = 0;
  452. if (strchr("+-", buf_ptr[0]))
  453. i = 1;
  454. d = atof(buf_ptr);
  455. if (buf_ptr[buf_len - 1] == '%')
  456. d *= (win.b - win.t) / 100.0;
  457. else if (buf_ptr[buf_len - 1] != 'p')
  458. d = D_u_to_d_row(d);
  459. y = prev_y = orig_y = d + (i ? orig_y : win.t);
  460. break;
  461. }
  462. }
  463. else {
  464. buf_ptr = buf;
  465. if (buf[0] == '.' && buf[1] == '.')
  466. buf_ptr++;
  467. if (!first_text && (linefeed || set_l)) {
  468. /* if x is not given, increment x */
  469. if (!set_x)
  470. x = prev_x +
  471. (size * linespacing + 0.5) * sin(rotation);
  472. /* if y is not given, increment y */
  473. if (!set_y)
  474. y = prev_y +
  475. (size * linespacing + 0.5) * cos(rotation);
  476. prev_x = x;
  477. prev_y = y;
  478. }
  479. set_x = set_y = set_l = first_text = 0;
  480. draw_text(buf_ptr, &x, &y, size, align, rotation, bold, do_background, fg_color, bg_color);
  481. }
  482. }
  483. if (cmd_fp != stdin)
  484. fclose(cmd_fp);
  485. /* reset */
  486. D_text_size(5, 5);
  487. D_text_rotation(0.0);
  488. D_close_driver();
  489. exit(EXIT_SUCCESS);
  490. }
  491. static void set_color(char *tcolor)
  492. {
  493. int r, g, b, color;
  494. if (sscanf(tcolor, "%d:%d:%d", &r, &g, &b) == 3 ||
  495. sscanf(tcolor, "0x%02x%02x%02x", &r, &g, &b) == 3) {
  496. if (r >= 0 && r < 256 && g >= 0 && g < 256 && b >= 0 && b < 256) {
  497. D_RGB_color(r, g, b);
  498. }
  499. }
  500. else {
  501. color = D_translate_color(tcolor);
  502. if (!color) {
  503. G_warning(_("[%s]: No such color. Use '%s'"), tcolor,
  504. DEFAULT_COLOR);
  505. color = D_translate_color(DEFAULT_COLOR);
  506. }
  507. D_use_color(color);
  508. }
  509. }
  510. static void get_coordinates(double *x, double *y, double *east, double *north,
  511. struct rectinfo win, char **at, char pixel,
  512. char geocoor)
  513. {
  514. double e, n;
  515. if (!at)
  516. G_fatal_error(_("Invalid coordinates"));
  517. e = atof(at[0]);
  518. n = atof(at[1]);
  519. if (pixel) {
  520. *x = e + win.l;
  521. *y = n + win.t;
  522. e = D_d_to_u_col(*x);
  523. n = D_d_to_u_row(*y);
  524. }
  525. else if (geocoor) {
  526. *x = D_u_to_d_col(e);
  527. *y = D_u_to_d_row(n);
  528. }
  529. else {
  530. *x = win.l + (win.r - win.l) * e / 100.0;
  531. *y = win.t + (win.b - win.t) * (100.0 - n) / 100.0;
  532. e = D_d_to_u_col(*x);
  533. n = D_d_to_u_row(*y);
  534. }
  535. if (east)
  536. *east = e;
  537. if (north)
  538. *north = n;
  539. }
  540. static void draw_text(char *text, double *x, double *y, double size,
  541. char *align, double rotation, char bold,
  542. int do_background, int fg_color, int bg_color)
  543. {
  544. double w, h;
  545. double t, b, l, r;
  546. double c, s;
  547. int pt, pb, pl, pr;
  548. /* TODO: get text dimension */
  549. /* R_get_text_box() does not work with rotation and returns a little bit
  550. * bigger dimension than actual text size */
  551. if (rotation != 0.0)
  552. D_text_rotation(0.0);
  553. D_get_text_box(text, &t, &b, &l, &r);
  554. t = D_u_to_d_row(t);
  555. b = D_u_to_d_row(b);
  556. l = D_u_to_d_col(l);
  557. r = D_u_to_d_col(r);
  558. if (rotation != 0.0)
  559. D_text_rotation(rotation * 180.0 / M_PI);
  560. w = r - l;
  561. h = b - t;
  562. if (w > 0)
  563. w += 0.2 * size;
  564. else
  565. /* D_text() does not draw " ". */
  566. w = 0.8 * size;
  567. if (h > 0)
  568. h += 0.2 * size;
  569. else
  570. /* D_text() does not draw " ". */
  571. h = 0.8 * size;
  572. c = cos(rotation);
  573. s = sin(rotation);
  574. if (strcmp(align, "ll") != 0) {
  575. switch (align[0]) {
  576. case 'l':
  577. break;
  578. case 'c':
  579. *x += h / 2.0 * s;
  580. *y += h / 2.0 * c;
  581. break;
  582. case 'u':
  583. *x += h * s;
  584. *y += h * c;
  585. break;
  586. }
  587. switch (align[1]) {
  588. case 'l':
  589. break;
  590. case 'c':
  591. *x -= w / 2.0 * c;
  592. *y += w / 2.0 * s;
  593. break;
  594. case 'r':
  595. *x -= w * c;
  596. *y += w * s;
  597. break;
  598. }
  599. }
  600. if (do_background) {
  601. pl = D_d_to_u_col(*x - size/2); /* some pixels margin for both sides */
  602. pt = D_d_to_u_row(*y + size/2);
  603. pr = D_d_to_u_col(*x + w + size/2);
  604. pb = D_d_to_u_row(*y - h - size/2);
  605. D_use_color(bg_color);
  606. D_box_abs(pl, pt, pr, pb); /* draw the box */
  607. D_use_color(fg_color); /* restore */
  608. }
  609. D_pos_abs(D_d_to_u_col(*x), D_d_to_u_row(*y));
  610. D_text(text);
  611. if (bold) {
  612. D_pos_abs(D_d_to_u_col(*x), D_d_to_u_row(*y + 1));
  613. D_text(text);
  614. D_pos_abs(D_d_to_u_col(*x + 1), D_d_to_u_row(*y));
  615. D_text(text);
  616. }
  617. *x += w * c;
  618. *y -= w * s;
  619. }