diff --git a/CHANGELOG.md b/CHANGELOG.md index c583da1..c9d7a55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ - Cleaning of the comments - Basic colors are not redefined anymore - Adding logo for SVG2TikZ +- Adding basic switch tag handle +- Adding failsafe for non defined sys.stdout.buffer ### Changed - Using style from new inkex - Using path from new inkex @@ -20,6 +22,7 @@ - Unify conversion of coordinate: (x, y) - Convert_file and convert_svg functions are now directly accesible from root - Fixing the installation of svg2tikz as command line tool +- Try excepting non existing tags in a svg ### Deprecated - Gradient are commented for the time being ### Removed diff --git a/svg2tikz/tikz_export.py b/svg2tikz/tikz_export.py index 2dbcbcc..bc5e2d0 100644 --- a/svg2tikz/tikz_export.py +++ b/svg2tikz/tikz_export.py @@ -792,7 +792,11 @@ def style_to_tz(self, node=None): options = [] # Stroke and fill - for use_path in [("stroke", "draw"), ("fill", "fill")]: + for use_path in ( + [("fill", "text")] + if node.TAG == "text" + else [("stroke", "draw"), ("fill", "fill")] + ): value = style.get(use_path[0]) if value != "none" and value is not None: options.append( diff --git a/tests/test_complete_files.py b/tests/test_complete_files.py index 6001353..2601239 100644 --- a/tests/test_complete_files.py +++ b/tests/test_complete_files.py @@ -107,6 +107,11 @@ def test_switch(self): filename = "switch_simple" create_test_from_filename(filename, self) + def test_text_fill_color(self): + """Test complete convert text with color case""" + filename = "text_fill_color" + create_test_from_filename(filename, self) + if __name__ == "__main__": unittest.main() diff --git a/tests/testfiles/text_fill_color.svg b/tests/testfiles/text_fill_color.svg new file mode 100644 index 0000000..54921c6 --- /dev/null +++ b/tests/testfiles/text_fill_color.svg @@ -0,0 +1,75 @@ + + + + + Default + Red + Green + Blue + Black + diff --git a/tests/testfiles/text_fill_color.tex b/tests/testfiles/text_fill_color.tex new file mode 100644 index 0000000..94c39ff --- /dev/null +++ b/tests/testfiles/text_fill_color.tex @@ -0,0 +1,34 @@ + +\documentclass{article} +\usepackage[utf8]{inputenc} +\usepackage{tikz} + +\begin{document} +\definecolor{lime}{RGB}{0,255,0} + + +\def \globalscale {1.000000} +\begin{tikzpicture}[y=1cm, x=1cm, yscale=\globalscale,xscale=\globalscale, inner sep=0pt, outer sep=0pt] + \node[anchor=south west] (text2) at (3.385, 6.5697){Default}; + + + + \node[text=red,anchor=south west] (text2-3) at (3.385, 6.2094){Red}; + + + + \node[text=lime,anchor=south west] (text2-6) at (3.385, 5.8491){Green}; + + + + \node[text=blue,anchor=south west] (text2-3-7) at (3.385, 5.4889){Blue}; + + + + \node[text=black,anchor=south west] (text2-5) at (3.3992, 5.1286){Black}; + + + + +\end{tikzpicture} +\end{document}