MCPcopy Create free account
hub / github.com/CruiserOne/Astrolog / SvgText

Function SvgText

xdevice.cpp:1782–1824  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1780// Output a string of text to an SVG file.
1781
1782void 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);
1809LChar:
1810 // Encode certain Unicode characters that need to be in XML files.
1811 if (wch == '&')
1812 fprintf(gi.file, "&amp;");
1813 else if (wch == '<')
1814 fprintf(gi.file, "&lt;");
1815 else if (wch == '>')
1816 fprintf(gi.file, "&gt;");
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

Callers 6

DrawSzFunction · 0.85
DrawSignFunction · 0.85
DrawHouseFunction · 0.85
DrawObjectFunction · 0.85
DrawAspectFunction · 0.85
DrawNakshatraFunction · 0.85

Calls 3

SvgSetColorFunction · 0.85
SzColorHTMLFunction · 0.85
PchToWchFunction · 0.85

Tested by

no test coverage detected