aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua M. Boniface <joshua@boniface.me>2020-12-27 22:29:35 -0500
committerJoshua M. Boniface <joshua@boniface.me>2020-12-30 18:55:51 -0500
commit2dab55a8f283379a864bb803ebed3a71db2ab2d8 (patch)
tree82018d43be2618f4e351fa5fd489f200a2e573ec
parent124ab090bc1cb2f833c907e4f00338a92d57c8a5 (diff)
Merge pull request #4863 from nyanmisaka/boxes-backdrop
Fix boxes in library name backdrop (cherry picked from commit f2e05bd183239e40f15ffcd7de1ad4eef0cb3beb) Signed-off-by: Joshua M. Boniface <joshua@boniface.me>
-rw-r--r--Jellyfin.Drawing.Skia/StripCollageBuilder.cs13
1 files changed, 12 insertions, 1 deletions
diff --git a/Jellyfin.Drawing.Skia/StripCollageBuilder.cs b/Jellyfin.Drawing.Skia/StripCollageBuilder.cs
index 0e94f87f6..e9f9aad57 100644
--- a/Jellyfin.Drawing.Skia/StripCollageBuilder.cs
+++ b/Jellyfin.Drawing.Skia/StripCollageBuilder.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
+using System.Text.RegularExpressions;
using SkiaSharp;
namespace Jellyfin.Drawing.Skia
@@ -118,6 +119,16 @@ namespace Jellyfin.Drawing.Skia
};
canvas.DrawRect(0, 0, width, height, paintColor);
+ var typeFace = SKTypeface.FromFamilyName("sans-serif", SKFontStyleWeight.Bold, SKFontStyleWidth.Normal, SKFontStyleSlant.Upright);
+
+ // use the system fallback to find a typeface for the given CJK character
+ var nonCjkPattern = @"[^\p{IsCJKUnifiedIdeographs}\p{IsCJKUnifiedIdeographsExtensionA}\p{IsKatakana}\p{IsHiragana}\p{IsHangulSyllables}\p{IsHangulJamo}]";
+ var filteredName = Regex.Replace(libraryName ?? string.Empty, nonCjkPattern, string.Empty);
+ if (!string.IsNullOrEmpty(filteredName))
+ {
+ typeFace = SKFontManager.Default.MatchCharacter(null, SKFontStyleWeight.Bold, SKFontStyleWidth.Normal, SKFontStyleSlant.Upright, null, filteredName[0]);
+ }
+
// draw library name
var textPaint = new SKPaint
{
@@ -125,7 +136,7 @@ namespace Jellyfin.Drawing.Skia
Style = SKPaintStyle.Fill,
TextSize = 112,
TextAlign = SKTextAlign.Center,
- Typeface = SKTypeface.FromFamilyName("sans-serif", SKFontStyleWeight.Bold, SKFontStyleWidth.Normal, SKFontStyleSlant.Upright),
+ Typeface = typeFace,
IsAntialias = true
};