From ff0c7c86a87ee22145d138f05cdb9d1d96eb953c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Tue, 2 Dec 2025 13:39:07 +0100 Subject: [PATCH] Make icon badge independent of the view box of the SVG (grafted from 7173c77acabbd6f8d9af4412d20b18d701e591dd) --HG-- branch : 6.0 --- tryton/tryton/common/common.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tryton/tryton/common/common.py b/tryton/tryton/common/common.py index 2f9d96da17..d8f3620f2a 100644 --- a/tryton/tryton/common/common.py +++ b/tryton/tryton/common/common.py @@ -135,6 +135,11 @@ class IconFactory: ET.register_namespace('', 'http://www.w3.org/2000/svg') root = ET.fromstring(data) root.attrib['fill'] = color + view_box = root.attrib.get('viewBox') + if view_box: + min_x, min_y, width, height = map( + float, view_box.split(' ')) + factor = max(width, height) / 24 if badge: if not isinstance(badge, str): try: @@ -142,9 +147,9 @@ class IconFactory: except IndexError: badge = color ET.SubElement(root, 'circle', { - 'cx': '20', - 'cy': '4', - 'r': '4', + 'cx': str(20 * factor + min_x), + 'cy': str(4 * factor + min_y), + 'r': str(4 * factor), 'fill': badge, }) data = ET.tostring(root)