| 5403 | } |
| 5404 | |
| 5405 | int PSL_plottext (struct PSL_CTRL *PSL, double x, double y, double fontsize, char *text, double angle, int justify, int mode) { |
| 5406 | /* General purpose text plotter for single line of text. For paragraphs, see PSL_plotparagraph. |
| 5407 | * PSL_plottext positions and justifies the text string according to the parameters given. |
| 5408 | * The adjustments requires knowledge of font metrics and characteristics; hence all such |
| 5409 | * adjustments are passed on to the PostScript interpreter who will calculate the offsets. |
| 5410 | * The arguments to PSL_plottext are as follows: |
| 5411 | * |
| 5412 | * x,y: location of string |
| 5413 | * fontsize: fontsize in points. If negative, assume currentpoint is already set, |
| 5414 | * else we use x, y to set a new currentpoint. |
| 5415 | * text: text string to be plotted in the current color (set by PSL_setcolor). |
| 5416 | * If NULL is given then we assume PSL_plottextbox has just been called. |
| 5417 | * angle: angle between text baseline and the horizontal. |
| 5418 | * justify: indicates where on the textstring the x,y point refers to, see fig below. |
| 5419 | * If negative then we strip leading and trailing blanks from the text. |
| 5420 | * 0 means no justification (already done separately). |
| 5421 | * mode: 0 = normal text filled with solid color; 1 = draw outline of text using |
| 5422 | * the current line width and color; the text is filled with the current fill |
| 5423 | * (if set, otherwise no filling is taking place); 2 = no outline, but text fill |
| 5424 | * is a pattern so we use the outline path and not the show operator; |
| 5425 | * 3 = same as 1, except that half the outline width is plotted on the outside |
| 5426 | * of the filled text, so none of the text font is obscured by the outline |
| 5427 | * (If the text is not filled, 1 operates the same as 3). |
| 5428 | * |
| 5429 | * 9 10 11 |
| 5430 | * |----------------| |
| 5431 | * 5 6 7 |
| 5432 | * |----------------| |
| 5433 | * 1 2 3 |
| 5434 | */ |
| 5435 | |
| 5436 | char *piece = NULL, *piece2 = NULL, *ptr = NULL, *string = NULL, previous[BUFSIZ] = {""}, *plast = NULL; |
| 5437 | /* PS strings to be used dependent on "mode" */ |
| 5438 | const char *op[4] = {"Z", "false charpath fs", "false charpath fs", "false charpath V S U fs"}; |
| 5439 | /* PS strings to be used dependent on "justify". Empty strings added for unused values. */ |
| 5440 | const char *justcmd[12] = {"", "bl ", "bc ", "br ", "", "ml ", "mc ", "mr ", "", "tl ", "tc ", "tr "}; |
| 5441 | /* PS strings to be used dependent on "justify%4". Empty string added for unused value. */ |
| 5442 | const char *align[4] = {"0", "-2 div", "neg", ""}; |
| 5443 | int dy, i = 0, j, font, font2, x_just, y_just, upen, ugap; |
| 5444 | int sub_on, super_on, scaps_on, symbol_on, font_on, size_on, color_on, under_on, old_font, n_uline, start_uline, stop_uline, last_chr, kase = PSL_LC; |
| 5445 | bool last_sub = false, last_sup = false, supersub; |
| 5446 | double orig_size, small_size, size, scap_size, ustep[2], dstep, last_rgb[4] = {0.0, 0.0, 0.0, 0.0}; |
| 5447 | |
| 5448 | if (fontsize == 0.0) return (PSL_NO_ERROR); /* Nothing to do if text has zero size */ |
| 5449 | |
| 5450 | if (fontsize > 0.0) { /* Set a new anchor point */ |
| 5451 | PSL->internal.ix = psl_ix (PSL, x); |
| 5452 | PSL->internal.iy = psl_iy (PSL, y); |
| 5453 | PSL_command (PSL, "%d %d M ", PSL->internal.ix, PSL->internal.iy); |
| 5454 | } |
| 5455 | else |
| 5456 | fontsize = -fontsize; |
| 5457 | psl_encodefont (PSL, PSL->current.font_no); |
| 5458 | psl_putfont (PSL, fontsize); |
| 5459 | |
| 5460 | if (text) { |
| 5461 | if (strlen (text) >= (PSL_BUFSIZ-1)) { /* We gotta have some limit on how long a single string can be... */ |
| 5462 | PSL_message (PSL, PSL_MSG_ERROR, "Warning: text_item > %d long - text not plotted!\n", PSL_BUFSIZ); |
no test coverage detected