Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<PackageVersion Include="NUnit" Version="4.3.2" />
<PackageVersion Include="NUnit3TestAdapter" Version="5.0.0" />
<PackageVersion Include="SharpZipLib" Version="1.4.2" />
<PackageVersion Include="SkiaSharp" Version="2.88.9" />
<PackageVersion Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="2.88.9" />
<PackageVersion Include="SkiaSharp" Version="3.119.2" />
<PackageVersion Include="SkiaSharp.NativeAssets.Linux.NoDependencies" Version="3.119.2" />
<PackageVersion Include="System.Configuration.ConfigurationManager" Version="8.0.1" />
<PackageVersion Include="System.Formats.Asn1" Version="8.0.1" />
<PackageVersion Include="System.Security.Cryptography.Xml" Version="8.0.2" />
Expand Down
3 changes: 1 addition & 2 deletions main/HSSF/UserModel/EscherGraphics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
11 changes: 4 additions & 7 deletions main/SS/Util/SheetUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down
Loading