diff --git a/Directory.Packages.props b/Directory.Packages.props index 597c51dce..7ca9b6f46 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -19,8 +19,8 @@ - - + + diff --git a/main/HSSF/UserModel/EscherGraphics.cs b/main/HSSF/UserModel/EscherGraphics.cs index a72eb58b2..c4441e40f 100644 --- a/main/HSSF/UserModel/EscherGraphics.cs +++ b/main/HSSF/UserModel/EscherGraphics.cs @@ -301,8 +301,7 @@ public void DrawString(String str, int x, int y) string fontName = font.Typeface.FamilyName.Equals("SansSerif", StringComparison.OrdinalIgnoreCase) ? "Arial" : font.Typeface.FamilyName; using SKFont excelFont = CreateFont(fontName, (int)(fontSizeInPoints / verticalPixelsPerPoint)); { - using var paint = new SKPaint { Typeface = excelFont.Typeface, TextSize = excelFont.Size }; - int width = (int)((paint.MeasureText(str) * 8) + 12); + int width = (int)((excelFont.MeasureText(str) * 8) + 12); int height = (int)((font.Size / verticalPixelsPerPoint) + 6) * 2; y -= Convert.ToInt32((font.Size / verticalPixelsPerPoint) + 2 * verticalPixelsPerPoint); // we want to Draw the shape from the top-left HSSFTextbox textbox = escherGroup.CreateTextbox(new HSSFChildAnchor(x, y, x + width, y + height)); diff --git a/main/SS/Util/SheetUtil.cs b/main/SS/Util/SheetUtil.cs index 076651716..c3f54ad59 100644 --- a/main/SS/Util/SheetUtil.cs +++ b/main/SS/Util/SheetUtil.cs @@ -430,8 +430,7 @@ private static double GetRotatedContentHeight(ICell cell, string stringValue, SK var angle = cell.CellStyle.Rotation * 2.0 * Math.PI / 360.0; try { - using var paint = new SKPaint { Typeface = windowsFont.Typeface, TextSize = windowsFont.Size }; - float textWidth = paint.MeasureText(stringValue); + float textWidth = windowsFont.MeasureText(stringValue); // Use the em-square height (font size in pixels) for the vertical component, // consistent with GetContentHeight and SixLabors.Fonts MeasureAdvance. float textHeight = windowsFont.Size; @@ -558,9 +557,8 @@ private static double GetCellWidth(int defaultCharWidth, int colspan, double actualWidth; try { - using var paint = new SKPaint { Typeface = windowsFont.Typeface, TextSize = windowsFont.Size }; - float textWidth = paint.MeasureText(str); - paint.GetFontMetrics(out SKFontMetrics metrics); + float textWidth = windowsFont.MeasureText(str); + windowsFont.GetFontMetrics(out SKFontMetrics metrics); float textHeight = metrics.Descent - metrics.Ascent; if (style.Rotation != 0) @@ -666,8 +664,7 @@ public static int GetDefaultCharWidth(IWorkbook wb) try { - using var paint = new SKPaint { Typeface = font.Typeface, TextSize = font.Size }; - return (int)Math.Ceiling(paint.MeasureText(new string(defaultChar, 1))); + return (int)Math.Ceiling(font.MeasureText(new string(defaultChar, 1))); } catch (Exception) {