aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj2
-rw-r--r--src/Jellyfin.Drawing.Skia/SkiaEncoder.cs18
-rw-r--r--src/Jellyfin.Drawing.Skia/StripCollageBuilder.cs20
-rw-r--r--src/Jellyfin.Drawing/ImageProcessor.cs2
-rw-r--r--src/Jellyfin.Extensions/AlphanumericComparator.cs15
-rw-r--r--src/Jellyfin.Extensions/Json/Converters/JsonBoolStringConverter.cs1
-rw-r--r--src/Jellyfin.Extensions/StringExtensions.cs2
7 files changed, 44 insertions, 16 deletions
diff --git a/src/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj b/src/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj
index 3b0333299..034691322 100644
--- a/src/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj
+++ b/src/Jellyfin.Drawing.Skia/Jellyfin.Drawing.Skia.csproj
@@ -21,6 +21,8 @@
<PackageReference Include="SkiaSharp" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" />
<PackageReference Include="SkiaSharp.Svg" />
+ <PackageReference Include="SkiaSharp.HarfBuzz" />
+ <PackageReference Include="HarfBuzzSharp.NativeAssets.Linux" />
</ItemGroup>
<ItemGroup>
diff --git a/src/Jellyfin.Drawing.Skia/SkiaEncoder.cs b/src/Jellyfin.Drawing.Skia/SkiaEncoder.cs
index 6da77ad95..2d980db18 100644
--- a/src/Jellyfin.Drawing.Skia/SkiaEncoder.cs
+++ b/src/Jellyfin.Drawing.Skia/SkiaEncoder.cs
@@ -120,8 +120,18 @@ public class SkiaEncoder : IImageEncoder
if (extension.Equals(".svg", StringComparison.OrdinalIgnoreCase))
{
var svg = new SKSvg();
- svg.Load(path);
- return new ImageDimensions(Convert.ToInt32(svg.Picture.CullRect.Width), Convert.ToInt32(svg.Picture.CullRect.Height));
+ try
+ {
+ svg.Load(path);
+ return new ImageDimensions(Convert.ToInt32(svg.Picture.CullRect.Width), Convert.ToInt32(svg.Picture.CullRect.Height));
+ }
+ catch (FormatException skiaColorException)
+ {
+ // This exception is known to be thrown on vector images that define custom styles
+ // Skia SVG is not able to handle that and as the repository is quite stale and has not received updates we just catch them
+ _logger.LogDebug(skiaColorException, "There was a issue loading the requested svg file");
+ return default;
+ }
}
using var codec = SKCodec.Create(path, out SKCodecResult result);
@@ -132,10 +142,10 @@ public class SkiaEncoder : IImageEncoder
return new ImageDimensions(info.Width, info.Height);
case SKCodecResult.Unimplemented:
_logger.LogDebug("Image format not supported: {FilePath}", path);
- return new ImageDimensions(0, 0);
+ return default;
default:
_logger.LogError("Unable to determine image dimensions for {FilePath}: {SkCodecResult}", path, result);
- return new ImageDimensions(0, 0);
+ return default;
}
}
diff --git a/src/Jellyfin.Drawing.Skia/StripCollageBuilder.cs b/src/Jellyfin.Drawing.Skia/StripCollageBuilder.cs
index eee24c423..a7a3338df 100644
--- a/src/Jellyfin.Drawing.Skia/StripCollageBuilder.cs
+++ b/src/Jellyfin.Drawing.Skia/StripCollageBuilder.cs
@@ -3,13 +3,14 @@ using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using SkiaSharp;
+using SkiaSharp.HarfBuzz;
namespace Jellyfin.Drawing.Skia;
/// <summary>
/// Used to build collages of multiple images arranged in vertical strips.
/// </summary>
-public class StripCollageBuilder
+public partial class StripCollageBuilder
{
private readonly SkiaEncoder _skiaEncoder;
@@ -22,6 +23,9 @@ public class StripCollageBuilder
_skiaEncoder = skiaEncoder;
}
+ [GeneratedRegex(@"\p{IsArabic}|\p{IsArmenian}|\p{IsHebrew}|\p{IsSyriac}|\p{IsThaana}")]
+ private static partial Regex IsRtlTextRegex();
+
/// <summary>
/// Check which format an image has been encoded with using its filename extension.
/// </summary>
@@ -144,7 +148,19 @@ public class StripCollageBuilder
textPaint.TextSize = 0.9f * width * textPaint.TextSize / textWidth;
}
- canvas.DrawText(libraryName, width / 2f, (height / 2f) + (textPaint.FontMetrics.XHeight / 2), textPaint);
+ if (string.IsNullOrWhiteSpace(libraryName))
+ {
+ return bitmap;
+ }
+
+ if (IsRtlTextRegex().IsMatch(libraryName))
+ {
+ canvas.DrawShapedText(libraryName, width / 2f, (height / 2f) + (textPaint.FontMetrics.XHeight / 2), textPaint);
+ }
+ else
+ {
+ canvas.DrawText(libraryName, width / 2f, (height / 2f) + (textPaint.FontMetrics.XHeight / 2), textPaint);
+ }
return bitmap;
}
diff --git a/src/Jellyfin.Drawing/ImageProcessor.cs b/src/Jellyfin.Drawing/ImageProcessor.cs
index 533baba4f..4e5d3b4d5 100644
--- a/src/Jellyfin.Drawing/ImageProcessor.cs
+++ b/src/Jellyfin.Drawing/ImageProcessor.cs
@@ -50,14 +50,12 @@ public sealed class ImageProcessor : IImageProcessor, IDisposable
/// <param name="appPaths">The server application paths.</param>
/// <param name="fileSystem">The filesystem.</param>
/// <param name="imageEncoder">The image encoder.</param>
- /// <param name="mediaEncoder">The media encoder.</param>
/// <param name="config">The configuration.</param>
public ImageProcessor(
ILogger<ImageProcessor> logger,
IServerApplicationPaths appPaths,
IFileSystem fileSystem,
IImageEncoder imageEncoder,
- IMediaEncoder mediaEncoder,
IServerConfigurationManager config)
{
_logger = logger;
diff --git a/src/Jellyfin.Extensions/AlphanumericComparator.cs b/src/Jellyfin.Extensions/AlphanumericComparator.cs
index 6e451d40e..299e2f94a 100644
--- a/src/Jellyfin.Extensions/AlphanumericComparator.cs
+++ b/src/Jellyfin.Extensions/AlphanumericComparator.cs
@@ -20,11 +20,13 @@ namespace Jellyfin.Extensions
{
return 0;
}
- else if (s1 is null)
+
+ if (s1 is null)
{
return -1;
}
- else if (s2 is null)
+
+ if (s2 is null)
{
return 1;
}
@@ -37,11 +39,13 @@ namespace Jellyfin.Extensions
{
return 0;
}
- else if (len1 == 0)
+
+ if (len1 == 0)
{
return -1;
}
- else if (len2 == 0)
+
+ if (len2 == 0)
{
return 1;
}
@@ -82,7 +86,8 @@ namespace Jellyfin.Extensions
{
return -1;
}
- else if (span1Len > span2Len)
+
+ if (span1Len > span2Len)
{
return 1;
}
diff --git a/src/Jellyfin.Extensions/Json/Converters/JsonBoolStringConverter.cs b/src/Jellyfin.Extensions/Json/Converters/JsonBoolStringConverter.cs
index 2936fe4d6..6895eadb8 100644
--- a/src/Jellyfin.Extensions/Json/Converters/JsonBoolStringConverter.cs
+++ b/src/Jellyfin.Extensions/Json/Converters/JsonBoolStringConverter.cs
@@ -1,7 +1,6 @@
using System;
using System.Buffers;
using System.Buffers.Text;
-using System.Linq;
using System.Text.Json;
using System.Text.Json.Serialization;
diff --git a/src/Jellyfin.Extensions/StringExtensions.cs b/src/Jellyfin.Extensions/StringExtensions.cs
index 7c6124875..b22eb7c4e 100644
--- a/src/Jellyfin.Extensions/StringExtensions.cs
+++ b/src/Jellyfin.Extensions/StringExtensions.cs
@@ -1,6 +1,4 @@
using System;
-using System.Globalization;
-using System.Text;
using System.Text.RegularExpressions;
namespace Jellyfin.Extensions