From 8af2d99ba9bffc8986f83944f6e8a6d90fb7fb6c Mon Sep 17 00:00:00 2001 From: Kevin Cozens Date: Fri, 27 Apr 2018 16:48:35 -0400 Subject: [PATCH] Do dispose and new Font only once when handling FontProp drawing command. --- .../VectorRender/VectorRenderModule.cs | 45 +++++-------------- 1 file changed, 12 insertions(+), 33 deletions(-) diff --git a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs index 8a26ab7b37..f4efb0a3c2 100644 --- a/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/VectorRender/VectorRenderModule.cs @@ -493,6 +493,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender Point endPoint = new Point(0, 0); Pen drawPen = null; Font myFont = null; + FontStyle myFontStyle; SolidBrush myBrush = null; try @@ -663,59 +664,37 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender } else if (nextLine.StartsWith("FontProp")) { + myFontStyle = FontStyle.Regular; + nextLine = nextLine.Remove(0, 8); nextLine = nextLine.Trim(); string[] fprops = nextLine.Split(partsDelimiter); foreach (string prop in fprops) { - switch (prop) { case "B": - if (!(myFont.Bold)) - { - Font newFont = new Font(myFont, myFont.Style | FontStyle.Bold); - myFont.Dispose(); - myFont = newFont; - } + myFontStyle |= FontStyle.Bold; break; case "I": - if (!(myFont.Italic)) - { - Font newFont = new Font(myFont, myFont.Style | FontStyle.Italic); - myFont.Dispose(); - myFont = newFont; - } + myFontStyle |= FontStyle.Italic; break; case "U": - if (!(myFont.Underline)) - { - Font newFont = new Font(myFont, myFont.Style | FontStyle.Underline); - myFont.Dispose(); - myFont = newFont; - } + myFontStyle |= FontStyle.Underline; break; case "S": - if (!(myFont.Strikeout)) - { - Font newFont = new Font(myFont, myFont.Style | FontStyle.Strikeout); - myFont.Dispose(); - myFont = newFont; - } + myFontStyle |= FontStyle.Strikeout; break; case "R": - // We need to place this newFont inside its own context so that the .NET compiler - // doesn't complain about a redefinition of an existing newFont, even though there is none - // The mono compiler doesn't produce this error. - { - Font newFont = new Font(myFont, FontStyle.Regular); - myFont.Dispose(); - myFont = newFont; - } + myFontStyle = FontStyle.Regular; break; } } + + Font newFont = new Font(myFont, myFontStyle); + myFont.Dispose(); + myFont = newFont; } else if (nextLine.StartsWith("FontName")) {