From 815bbbf75f254ce5eeb337fd01e6122b79ca79e9 Mon Sep 17 00:00:00 2001 From: Beldaa Date: Sat, 18 Apr 2026 16:40:05 +0200 Subject: [PATCH] Fix StyleManager cache key using nullable parameter instead of resolved value The style cache key used fontWidth (the nullable parameter, often null) instead of rFontWidth (the resolved value). This caused styles with different font widths to collide in the cache, returning incorrect styles. --- Topten.RichTextKit/StyleManager.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Topten.RichTextKit/StyleManager.cs b/Topten.RichTextKit/StyleManager.cs index d8b1f72..1c09235 100644 --- a/Topten.RichTextKit/StyleManager.cs +++ b/Topten.RichTextKit/StyleManager.cs @@ -1,4 +1,4 @@ -// RichTextKit +// RichTextKit // Copyright © 2019-2020 Topten Software. All Rights Reserved. // // Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -301,7 +301,7 @@ public IStyle Update( var rReplacementCharacter = replacementCharacter ?? _currentStyle.ReplacementCharacter; // Format key - var key = $"{rFontFamily}.{rFontSize}.{rFontWeight}.{fontWidth}.{rFontItalic}.{rUnderline}.{rStrikeThrough}.{rLineHeight}.{rTextColor}.{rBackgroundColor}.{rHaloColor}.{rHaloWidth}.{rHaloBlur}.{rLetterSpacing}.{rFontVariant}.{rTextDirection}.{rReplacementCharacter}"; + var key = $"{rFontFamily}.{rFontSize}.{rFontWeight}.{rFontWidth}.{rFontItalic}.{rUnderline}.{rStrikeThrough}.{rLineHeight}.{rTextColor}.{rBackgroundColor}.{rHaloColor}.{rHaloWidth}.{rHaloBlur}.{rLetterSpacing}.{rFontVariant}.{rTextDirection}.{rReplacementCharacter}"; // Look up... if (!_styleMap.TryGetValue(key, out var style))