Do dispose and new Font only once when handling FontProp drawing command.

httptests
Kevin Cozens 2018-04-27 16:48:35 -04:00
parent f29358744d
commit 8af2d99ba9
1 changed files with 12 additions and 33 deletions

View File

@ -493,6 +493,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
Point endPoint = new Point(0, 0); Point endPoint = new Point(0, 0);
Pen drawPen = null; Pen drawPen = null;
Font myFont = null; Font myFont = null;
FontStyle myFontStyle;
SolidBrush myBrush = null; SolidBrush myBrush = null;
try try
@ -663,59 +664,37 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
} }
else if (nextLine.StartsWith("FontProp")) else if (nextLine.StartsWith("FontProp"))
{ {
myFontStyle = FontStyle.Regular;
nextLine = nextLine.Remove(0, 8); nextLine = nextLine.Remove(0, 8);
nextLine = nextLine.Trim(); nextLine = nextLine.Trim();
string[] fprops = nextLine.Split(partsDelimiter); string[] fprops = nextLine.Split(partsDelimiter);
foreach (string prop in fprops) foreach (string prop in fprops)
{ {
switch (prop) switch (prop)
{ {
case "B": case "B":
if (!(myFont.Bold)) myFontStyle |= FontStyle.Bold;
{
Font newFont = new Font(myFont, myFont.Style | FontStyle.Bold);
myFont.Dispose();
myFont = newFont;
}
break; break;
case "I": case "I":
if (!(myFont.Italic)) myFontStyle |= FontStyle.Italic;
{
Font newFont = new Font(myFont, myFont.Style | FontStyle.Italic);
myFont.Dispose();
myFont = newFont;
}
break; break;
case "U": case "U":
if (!(myFont.Underline)) myFontStyle |= FontStyle.Underline;
{
Font newFont = new Font(myFont, myFont.Style | FontStyle.Underline);
myFont.Dispose();
myFont = newFont;
}
break; break;
case "S": case "S":
if (!(myFont.Strikeout)) myFontStyle |= FontStyle.Strikeout;
{
Font newFont = new Font(myFont, myFont.Style | FontStyle.Strikeout);
myFont.Dispose();
myFont = newFont;
}
break; break;
case "R": case "R":
// We need to place this newFont inside its own context so that the .NET compiler myFontStyle = FontStyle.Regular;
// 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;
}
break; break;
} }
} }
Font newFont = new Font(myFont, myFontStyle);
myFont.Dispose();
myFont = newFont;
} }
else if (nextLine.StartsWith("FontName")) else if (nextLine.StartsWith("FontName"))
{ {