From 97e776d6c6aec0251396ba4712573b54d4c247a5 Mon Sep 17 00:00:00 2001 From: Jason Dove <1695733+jasongdove@users.noreply.github.com> Date: Mon, 23 Jun 2025 08:47:54 -0500 Subject: [PATCH] migrate skiasharp to 3.x api --- ErsatzTV.Core/ErsatzTV.Core.csproj | 4 ++-- ErsatzTV.Core/Images/ChannelLogoGenerator.cs | 22 +++++++++++--------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/ErsatzTV.Core/ErsatzTV.Core.csproj b/ErsatzTV.Core/ErsatzTV.Core.csproj index 498d1512..03abd0d9 100644 --- a/ErsatzTV.Core/ErsatzTV.Core.csproj +++ b/ErsatzTV.Core/ErsatzTV.Core.csproj @@ -27,8 +27,8 @@ - - + + diff --git a/ErsatzTV.Core/Images/ChannelLogoGenerator.cs b/ErsatzTV.Core/Images/ChannelLogoGenerator.cs index c3f507db..12d892ce 100644 --- a/ErsatzTV.Core/Images/ChannelLogoGenerator.cs +++ b/ErsatzTV.Core/Images/ChannelLogoGenerator.cs @@ -41,32 +41,34 @@ public class ChannelLogoGenerator : IChannelLogoGenerator //Custom Font string fontPath = Path.Combine(FileSystemLayout.ResourcesCacheFolder, "Sen.ttf"); using SKTypeface fontTypeface = SKTypeface.FromFile(fontPath); - int fontSize = 30; - SKPaint paint = new SKPaint + var fontSize = 30; + var font = new SKFont { Typeface = fontTypeface, - TextSize = fontSize, + Size = fontSize + }; + + var paint = new SKPaint + { IsAntialias = true, Color = SKColors.White, - Style = SKPaintStyle.Fill, - TextAlign = SKTextAlign.Center + Style = SKPaintStyle.Fill }; - SKRect textBounds = new SKRect(); - paint.MeasureText(text, ref textBounds); + font.MeasureText(text, out SKRect textBounds, paint); // Ajuster la taille de la police si nécessaire while (textBounds.Width > logoWidth - 10 && fontSize > 16) { fontSize -= 2; - paint.TextSize = fontSize; - paint.MeasureText(text, ref textBounds); + font.Size = fontSize; + font.MeasureText(text, out textBounds, paint); } // Dessiner le texte float x = logoWidth / 2f; float y = logoHeight / 2f - textBounds.MidY; - canvas.DrawText(text, x, y, paint); + canvas.DrawText(text, x, y, SKTextAlign.Center, font, paint); using SKImage image = surface.Snapshot(); using MemoryStream ms = new MemoryStream();