Make icon badge independent of the view box of the SVG

(grafted from 7173c77acabbd6f8d9af4412d20b18d701e591dd)

--HG--
branch : 6.0
This commit is contained in:
Cédric Krier committed 2025-12-02 13:39:07 +01:00
1 parent 0b121da0fc
commit ff0c7c86a8
1 file changed
+8 -3
+8 -3
View File
@@ -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)