From 67e8dbfe3a17b791916e52600e226c6218ebfbbd Mon Sep 17 00:00:00 2001 From: George Taylor Date: Fri, 17 Oct 2025 11:59:21 +0100 Subject: [PATCH 1/3] fix: icon image positioning --- diagrams/__init__.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/diagrams/__init__.py b/diagrams/__init__.py index 66c3458f..b8497301 100644 --- a/diagrams/__init__.py +++ b/diagrams/__init__.py @@ -315,14 +315,13 @@ class Node: self.label = prefix # fmt: off - # If a node has an icon, increase the height slightly to avoid - # that label being spanned between icon image and white space. - # Increase the height by the number of new lines included in the label. - padding = 0.4 * (self.label.count('\n')) + # If a node has an icon, set the imagepos attr so + # that that the icon image is top centered. self._attrs = { "shape": "none", - "height": str(self._height + padding), + "height": str(self._height), "image": self._load_icon(), + "imagepos": "tc", } if self._icon else {} # fmt: on From c6d40178de4a9e5a3b492c38efad1229346fe652 Mon Sep 17 00:00:00 2001 From: georgepstaylor <3026030+georgepstaylor@users.noreply.github.com> Date: Thu, 30 Oct 2025 09:54:58 +0000 Subject: [PATCH 2/3] fix: add imagepos tc to default node attrs --- diagrams/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diagrams/__init__.py b/diagrams/__init__.py index b8497301..a7c4573c 100644 --- a/diagrams/__init__.py +++ b/diagrams/__init__.py @@ -62,7 +62,7 @@ class Diagram: # imagepos attribute is not backward compatible # TODO: check graphviz version to see if "imagepos" is available >= 2.40 # https://github.com/xflr6/graphviz/blob/master/graphviz/backend.py#L248 - # "imagepos": "tc", + "imagepos": "tc", "imagescale": "true", "fontname": "Sans-Serif", "fontsize": "13", From 73446bd2509b082f73fb2929484024af225bd151 Mon Sep 17 00:00:00 2001 From: georgepstaylor <3026030+georgepstaylor@users.noreply.github.com> Date: Thu, 30 Oct 2025 09:55:10 +0000 Subject: [PATCH 3/3] Revert "fix: icon image positioning" This reverts commit 67e8dbfe3a17b791916e52600e226c6218ebfbbd. --- diagrams/__init__.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/diagrams/__init__.py b/diagrams/__init__.py index a7c4573c..2db6d8db 100644 --- a/diagrams/__init__.py +++ b/diagrams/__init__.py @@ -315,13 +315,14 @@ class Node: self.label = prefix # fmt: off - # If a node has an icon, set the imagepos attr so - # that that the icon image is top centered. + # If a node has an icon, increase the height slightly to avoid + # that label being spanned between icon image and white space. + # Increase the height by the number of new lines included in the label. + padding = 0.4 * (self.label.count('\n')) self._attrs = { "shape": "none", - "height": str(self._height), + "height": str(self._height + padding), "image": self._load_icon(), - "imagepos": "tc", } if self._icon else {} # fmt: on