MCPcopy Create free account
hub / github.com/GenericMappingTools/gmt / PSL_plotparagraph

Function PSL_plotparagraph

src/postscriptlight.c:5994–6036  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5992}
5993
5994int PSL_plotparagraph (struct PSL_CTRL *PSL, double x, double y, double fontsize, char *paragraph, double angle, int justify) {
5995 /* Typeset one or more paragraphs. Separate paragraphs by adding \r to end of last word in a paragraph.
5996 * To lay down a text box first, see PSL_plotparagraphbox. */
5997 int error = 0;
5998
5999 if (fontsize == 0.0) return (PSL_NO_ERROR); /* Nothing to do if text has zero size */
6000
6001 /* If paragraph is NULL then PSL_plotparagraphbox has been called so we don't need to write the paragraph info to the PS file */
6002 if (paragraph && (error = psl_paragraphprocess (PSL, y, fontsize, paragraph)) != PSL_NO_ERROR) return (error);
6003
6004 PSL_command (PSL, "V ");
6005 PSL_setorigin (PSL, x, y, angle, PSL_FWD); /* To original point */
6006
6007 /* Do the relative horizontal justification */
6008
6009 PSL_command (PSL, "0 0 M\n0 PSL_textjustifier");
6010 (PSL->internal.comments) ? PSL_command (PSL, "\t%% Just get paragraph height\n") : PSL_command (PSL, "\n");
6011
6012 /* Adjust origin for box justification */
6013
6014 PSL_command (PSL, "/PSL_justify %d def\n", justify);
6015 PSL_command (PSL, "/PSL_x0 PSL_parwidth PSL_justify 1 sub 4 mod 0.5 mul neg mul def\n");
6016 if (justify > 8) /* Top row */
6017 PSL_command (PSL, "/PSL_y0 0 def\n");
6018 else if (justify > 4) /* Middle row */
6019 PSL_command (PSL, "/PSL_y0 PSL_parheight 2 div def\n");
6020 else /* Bottom row */
6021 PSL_command (PSL, "/PSL_y0 PSL_parheight def\n");
6022 PSL_command (PSL, "/PSL_txt_y0 PSL_top neg def\n");
6023
6024 /* Make upper left textbox corner the origin */
6025
6026 PSL_command (PSL, "PSL_x0 PSL_y0 T\n");
6027
6028 /* Adjust origin so 0,0 is lower left corner of first character on baseline */
6029
6030 PSL_command (PSL, "0 PSL_txt_y0 T");
6031 PSL_command (PSL, (PSL->internal.comments) ? "\t%% Move to col 0 on first baseline\n" : "\n");
6032 PSL_command (PSL, "0 0 M\n1 PSL_textjustifier U");
6033 PSL_command (PSL, (PSL->internal.comments) ? "\t%% Place the paragraph\n" : "\n");
6034
6035 return (PSL_NO_ERROR);
6036}
6037
6038int PSL_defunits (struct PSL_CTRL *PSL, const char *param, double value) {
6039 PSL_command (PSL, "/%s %d def\n", param, psl_iz (PSL, value));

Callers 3

PSL_plotparagraph_Function · 0.85
pstext_output_wordsFunction · 0.85
mainFunction · 0.85

Calls 3

psl_paragraphprocessFunction · 0.85
PSL_commandFunction · 0.85
PSL_setoriginFunction · 0.85

Tested by

no test coverage detected