@ -41,32 +41,34 @@ public class ChannelLogoGenerator : IChannelLogoGenerator
@@ -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 = 3 0 ;
SKPaint paint = new SKPai nt
var fontSize = 3 0 ;
var font = new SKFo nt
{
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 - 1 0 & & fontSize > 1 6 )
{
fontSize - = 2 ;
paint . Text Size = fontSize ;
pai nt. MeasureText ( text , ref textBounds ) ;
font . Size = fontSize ;
fo nt. 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 ( ) ;