| 1780 | // Output a string of text to an SVG file. |
| 1781 | |
| 1782 | void SvgText(CONST char *sz, int ch, int x, int y, int nFont, int nScale, |
| 1783 | flag fCenter) |
| 1784 | { |
| 1785 | CONST char *pch; |
| 1786 | wchar wch; |
| 1787 | int n; |
| 1788 | |
| 1789 | SvgSetColor(); |
| 1790 | fprintf(gi.file, "<text x=\"%d\" y=\"%d\" fill=\"%s\" stroke=\"none\"", |
| 1791 | x, y, SzColorHTML(gi.kiSvgAct)); |
| 1792 | if (fCenter) |
| 1793 | fprintf(gi.file, " text-anchor=\"middle\" dominant-baseline=\"middle\""); |
| 1794 | fprintf(gi.file, " style=\"font-family:%s; font-size:%dpx;", |
| 1795 | rgszFontName[nFont], nScale); |
| 1796 | if (sz != NULL) |
| 1797 | fprintf(gi.file, " white-space:pre"); |
| 1798 | fprintf(gi.file, "\">"); |
| 1799 | if (sz == NULL) { |
| 1800 | // Empty input string means to use the input char as a length one string. |
| 1801 | wch = ch; |
| 1802 | pch = ""; |
| 1803 | n = 0; |
| 1804 | goto LChar; |
| 1805 | } else |
| 1806 | pch = sz; |
| 1807 | while (*pch) { |
| 1808 | n = PchToWch((uchar *)pch, &wch); |
| 1809 | LChar: |
| 1810 | // Encode certain Unicode characters that need to be in XML files. |
| 1811 | if (wch == '&') |
| 1812 | fprintf(gi.file, "&"); |
| 1813 | else if (wch == '<') |
| 1814 | fprintf(gi.file, "<"); |
| 1815 | else if (wch == '>') |
| 1816 | fprintf(gi.file, ">"); |
| 1817 | else if (wch < 128) |
| 1818 | fprintf(gi.file, "%c", (uchar)wch); |
| 1819 | else |
| 1820 | fprintf(gi.file, "&#%d;", (int)wch); |
| 1821 | pch += n; |
| 1822 | } |
| 1823 | fprintf(gi.file, "</text>\n"); |
| 1824 | } |
| 1825 | #endif // SVG |
| 1826 | |
| 1827 |
no test coverage detected