mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-09 03:04:24 -04:00
Fixed RTL text not beeing rendered properly on Lib images (#9612)
Co-authored-by: Cody Robibero <cody@robibe.ro>
This commit is contained in:
parent
e935d787ef
commit
3d635269eb
@ -67,6 +67,8 @@
|
||||
<PackageVersion Include="SharpFuzz" Version="2.1.0" />
|
||||
<PackageVersion Include="SkiaSharp.NativeAssets.Linux" Version="2.88.3" />
|
||||
<PackageVersion Include="SkiaSharp.Svg" Version="1.60.0" />
|
||||
<PackageVersion Include="SkiaSharp.HarfBuzz" Version="2.88.3" />
|
||||
<PackageVersion Include="HarfBuzzSharp.NativeAssets.Linux" Version="2.8.2.3" />
|
||||
<PackageVersion Include="SkiaSharp" Version="2.88.3" />
|
||||
<PackageVersion Include="SmartAnalyzers.MultithreadingAnalyzer" Version="1.1.31" />
|
||||
<PackageVersion Include="SQLitePCL.pretty.netstandard" Version="3.1.0" />
|
||||
|
@ -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>
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user