@@ -8,7 +8,7 @@ internal static class SvgNodeWriter
88 private const double DefaultLabelLineHeight = 1.15 ;
99 private const double AnnotationFontSizeRatio = 0.85 ;
1010 internal const double DefaultIconSize = 48 ;
11- private const double IconLabelGap = 6 ;
11+ internal const double IconLabelGap = 6 ;
1212
1313 internal static void AppendNode ( StringBuilder sb , Node node , Theme theme , int nodeIndex = 0 )
1414 {
@@ -151,7 +151,7 @@ internal static void AppendNode(StringBuilder sb, Node node, Theme theme, int no
151151 double iconAreaHeight = 0 ;
152152 if ( hasIcon && ! textOnly )
153153 {
154- AppendNodeIcon ( sb , node , theme ) ;
154+ AppendNodeIcon ( sb , node , theme , resolvedTextColor ) ;
155155 iconAreaHeight = DefaultIconSize + IconLabelGap ;
156156 }
157157
@@ -204,7 +204,11 @@ private static void AppendNodeLabel(
204204 /// Renders a resolved icon inside a node, centered horizontally and positioned
205205 /// in the upper portion to leave room for the label below.
206206 /// </summary>
207- private static void AppendNodeIcon ( StringBuilder sb , Node node , Theme theme )
207+ /// <param name="resolvedTextColor">
208+ /// The already-resolved text color for the node (same value used for the label),
209+ /// ensuring icon and label use a consistent, contrast-aware color.
210+ /// </param>
211+ private static void AppendNodeIcon ( StringBuilder sb , Node node , Theme theme , string resolvedTextColor )
208212 {
209213 var icon = node . ResolvedIcon ;
210214 if ( icon is null )
@@ -218,13 +222,10 @@ private static void AppendNodeIcon(StringBuilder sb, Node node, Theme theme)
218222 string [ ] viewBoxParts = icon . ViewBox . Split ( ' ' , StringSplitOptions . RemoveEmptyEntries ) ;
219223 string viewBox = viewBoxParts . Length == 4 ? icon . ViewBox : "0 0 24 24" ;
220224
221- // Use theme-aware icon color (the icon uses currentColor for stroke/fill).
222- string iconColor = SvgRenderSupport . Escape (
223- SvgRenderSupport . ResolveNodeTextColor (
224- node . FillColor ?? theme . NodeFillColor , theme ) ) ;
225-
225+ // Use the same resolved text color as the label so icon and label are always consistent,
226+ // including when the node fill is sourced from a theme palette.
226227 sb . AppendLine ( $ """ <g transform="translate({ SvgRenderSupport . F ( iconX ) } ,{ SvgRenderSupport . F ( iconY ) } )">""" ) ;
227- sb . AppendLine ( $ """ <svg width="{ SvgRenderSupport . F ( iconSize ) } " height="{ SvgRenderSupport . F ( iconSize ) } " viewBox="{ SvgRenderSupport . Escape ( viewBox ) } " overflow="visible" color="{ iconColor } ">""" ) ;
228+ sb . AppendLine ( $ """ <svg width="{ SvgRenderSupport . F ( iconSize ) } " height="{ SvgRenderSupport . F ( iconSize ) } " viewBox="{ SvgRenderSupport . Escape ( viewBox ) } " overflow="visible" color="{ resolvedTextColor } ">""" ) ;
228229 sb . AppendLine ( $ " { icon . SvgContent } ") ;
229230 sb . AppendLine ( " </svg>" ) ;
230231 sb . AppendLine ( " </g>" ) ;
0 commit comments