Parcourir la source

minor fix to font change method to better handle nulls

randoman il y a 6 ans
Parent
commit
5f2f19adde
1 fichiers modifiés avec 2 ajouts et 2 suppressions
  1. 2 2
      src/XUnity.AutoTranslator.Plugin.Core/TranslationInfo.cs

+ 2 - 2
src/XUnity.AutoTranslator.Plugin.Core/TranslationInfo.cs

@@ -66,9 +66,9 @@ namespace XUnity.AutoTranslator.Plugin.Core
             var ui = graphic as Text;
 
             var previousFont = ui.font;
-            var newFont = FontCache.GetOrCreate( previousFont.fontSize );
+            var newFont = FontCache.GetOrCreate( previousFont?.fontSize ?? ui.fontSize );
 
-            if( newFont != previousFont )
+            if( !ReferenceEquals( newFont, previousFont ) )
             {
                ui.font = newFont;
                _unfont = obj =>