From d9f1e5e7b74072f5407a62724566797f274d00ae Mon Sep 17 00:00:00 2001 From: Yann Salmon Date: Sat, 7 Oct 2023 12:47:47 +0200 Subject: [PATCH 1/5] Managing text color closes #152 --- svg2tikz/tikz_export.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/svg2tikz/tikz_export.py b/svg2tikz/tikz_export.py index 2dbcbcc..5ed801e 100644 --- a/svg2tikz/tikz_export.py +++ b/svg2tikz/tikz_export.py @@ -792,7 +792,7 @@ 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( From f85c35f7840b13496aae13c6de32c7944f3392fc Mon Sep 17 00:00:00 2001 From: Devillez Louis Date: Mon, 9 Oct 2023 08:10:25 +0200 Subject: [PATCH 2/5] Follow black coding style --- svg2tikz/tikz_export.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/svg2tikz/tikz_export.py b/svg2tikz/tikz_export.py index 5ed801e..d20fc23 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 ([("fill", "text")] if node.TAG=="text" else [("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( From e28f99862d6d3f1f321fae49e3e88681a4175d6f Mon Sep 17 00:00:00 2001 From: ldevillez Date: Mon, 9 Oct 2023 08:13:35 +0200 Subject: [PATCH 3/5] FIX: rerun black --- svg2tikz/tikz_export.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/svg2tikz/tikz_export.py b/svg2tikz/tikz_export.py index d20fc23..bc5e2d0 100644 --- a/svg2tikz/tikz_export.py +++ b/svg2tikz/tikz_export.py @@ -793,8 +793,8 @@ def style_to_tz(self, node=None): # Stroke and fill for use_path in ( - [("fill", "text")] - if node.TAG=="text" + [("fill", "text")] + if node.TAG == "text" else [("stroke", "draw"), ("fill", "fill")] ): value = style.get(use_path[0]) From b66b6c52de88d6063f96cba0971438cf6b768aa5 Mon Sep 17 00:00:00 2001 From: ldevillez Date: Mon, 9 Oct 2023 08:24:13 +0200 Subject: [PATCH 4/5] add test file --- svg2tikz/tikz_export.py | 6 ++- tests/test_complete_files.py | 5 ++ tests/testfiles/text_fill_color.svg | 75 +++++++++++++++++++++++++++++ tests/testfiles/text_fill_color.tex | 34 +++++++++++++ 4 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 tests/testfiles/text_fill_color.svg create mode 100644 tests/testfiles/text_fill_color.tex 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} From f94d6f4afe08f4c13d94126378468fd2b95bee86 Mon Sep 17 00:00:00 2001 From: ldevillez Date: Mon, 9 Oct 2023 08:27:46 +0200 Subject: [PATCH 5/5] update changelog --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) 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