| 4856 | } |
| 4857 | |
| 4858 | int PSL_setdash (struct PSL_CTRL *PSL, char *style, double offset) { |
| 4859 | /* Line structure in points |
| 4860 | * offset from currentpoint in points |
| 4861 | * style = "1 2", offset = 0: |
| 4862 | * 1 point of line, 2 points of space, start at current point |
| 4863 | * style = "5 3 1 3", offset = 2: |
| 4864 | * 5 points line, 3 points space, 1 points line, 3 points space, |
| 4865 | * starting 2 points from current point. |
| 4866 | */ |
| 4867 | |
| 4868 | if (PSL->current.style[0] == '\0') { /* No previous style, so previous offset does not matters */ |
| 4869 | if (!style || style[0] == '\0') return (PSL_NO_ERROR); /* No new style given, so just return */ |
| 4870 | } |
| 4871 | /* Here, we have a previous non-NULL style */ |
| 4872 | if (!style || style[0] == '\0') { /* No style wanted going forwards, so we do a full reset */ |
| 4873 | memset (PSL->current.style, 0, PSL_PEN_LEN); |
| 4874 | PSL->current.offset = 0; |
| 4875 | PSL_command (PSL, "[] 0 B\n"); |
| 4876 | return (PSL_NO_ERROR); |
| 4877 | } |
| 4878 | /* Here we have a previous style AND we have specified a (possibly) new style */ |
| 4879 | if (PSL_eq(offset,PSL->current.offset) && !strcmp (style, PSL->current.style)) return (PSL_NO_ERROR); /* Same as before, so just return */ |
| 4880 | /* Finally, a new style has been given that differs from the previous and we need to update our settings */ |
| 4881 | PSL->current.offset = offset; |
| 4882 | strncpy (PSL->current.style, style, PSL_PEN_LEN); |
| 4883 | PSL_command (PSL, "%s\n", psl_putdash (PSL, style, offset)); |
| 4884 | return (PSL_NO_ERROR); |
| 4885 | } |
| 4886 | |
| 4887 | int PSL_setfont (struct PSL_CTRL *PSL, int font_no) { |
| 4888 | if (font_no == PSL->current.font_no) return (PSL_NO_ERROR); /* Already set */ |
no test coverage detected