aboutsummaryrefslogtreecommitdiff
path: root/Emby.Drawing.Skia
diff options
context:
space:
mode:
authorLuke Pulverenti <luke.pulverenti@gmail.com>2017-11-21 17:14:56 -0500
committerLuke Pulverenti <luke.pulverenti@gmail.com>2017-11-21 17:14:56 -0500
commit77695f8abed3156de04c6bb2496c14a2ab3d90a8 (patch)
treee45797a21eaf7d5046cdab4bc362099512e24bae /Emby.Drawing.Skia
parent46be272ec840ba8f9de1307d97dea8b593fbbf93 (diff)
3.2.40.1
Diffstat (limited to 'Emby.Drawing.Skia')
-rw-r--r--Emby.Drawing.Skia/Emby.Drawing.Skia.csproj3
-rw-r--r--Emby.Drawing.Skia/PlayedIndicatorDrawer.cs48
-rw-r--r--Emby.Drawing.Skia/UnplayedCountIndicator.cs2
3 files changed, 12 insertions, 41 deletions
diff --git a/Emby.Drawing.Skia/Emby.Drawing.Skia.csproj b/Emby.Drawing.Skia/Emby.Drawing.Skia.csproj
index f2b32d52cb..2b61561cbc 100644
--- a/Emby.Drawing.Skia/Emby.Drawing.Skia.csproj
+++ b/Emby.Drawing.Skia/Emby.Drawing.Skia.csproj
@@ -60,9 +60,6 @@
<Compile Include="UnplayedCountIndicator.cs" />
</ItemGroup>
<ItemGroup>
- <EmbeddedResource Include="fonts\robotoregular.ttf" />
- </ItemGroup>
- <ItemGroup>
<Reference Include="SkiaSharp, Version=1.58.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756, processorArchitecture=MSIL">
<HintPath>..\packages\SkiaSharp.1.58.1\lib\portable-net45+win8+wpa81+wp8\SkiaSharp.dll</HintPath>
</Reference>
diff --git a/Emby.Drawing.Skia/PlayedIndicatorDrawer.cs b/Emby.Drawing.Skia/PlayedIndicatorDrawer.cs
index 48f2da62bc..2417043d60 100644
--- a/Emby.Drawing.Skia/PlayedIndicatorDrawer.cs
+++ b/Emby.Drawing.Skia/PlayedIndicatorDrawer.cs
@@ -15,7 +15,6 @@ namespace Emby.Drawing.Skia
{
public class PlayedIndicatorDrawer
{
- private const int FontSize = 42;
private const int OffsetFromTopRightCorner = 38;
private readonly IApplicationPaths _appPaths;
@@ -44,48 +43,23 @@ namespace Emby.Drawing.Skia
{
paint.Color = new SKColor(255, 255, 255, 255);
paint.Style = SKPaintStyle.Fill;
- paint.Typeface = SKTypeface.FromFile(await DownloadFont("webdings.ttf", "https://github.com/MediaBrowser/Emby.Resources/raw/master/fonts/webdings.ttf",
- _appPaths, _iHttpClient, _fileSystem).ConfigureAwait(false));
- paint.TextSize = FontSize;
- paint.IsAntialias = true;
-
- canvas.DrawText("a", (float)x-20, OffsetFromTopRightCorner + 12, paint);
- }
- }
-
- internal static string ExtractFont(string name, IApplicationPaths paths, IFileSystem fileSystem)
- {
- var filePath = Path.Combine(paths.ProgramDataPath, "fonts", name);
-
- if (fileSystem.FileExists(filePath))
- {
- return filePath;
- }
- var namespacePath = typeof(PlayedIndicatorDrawer).Namespace + ".fonts." + name;
- var tempPath = Path.Combine(paths.TempDirectory, Guid.NewGuid().ToString("N") + ".ttf");
- fileSystem.CreateDirectory(fileSystem.GetDirectoryName(tempPath));
+ paint.TextSize = 30;
+ paint.IsAntialias = true;
- using (var stream = typeof(PlayedIndicatorDrawer).GetTypeInfo().Assembly.GetManifestResourceStream(namespacePath))
- {
- using (var fileStream = fileSystem.GetFileStream(tempPath, FileOpenMode.Create, FileAccessMode.Write, FileShareMode.Read))
- {
- stream.CopyTo(fileStream);
- }
- }
+ var text = "✔️";
+ var emojiChar = StringUtilities.GetUnicodeCharacterCode(text, SKTextEncoding.Utf32);
+ // or:
+ //var emojiChar = 0x1F680;
- fileSystem.CreateDirectory(fileSystem.GetDirectoryName(filePath));
+ // ask the font manager for a font with that character
+ var fontManager = SKFontManager.Default;
+ var emojiTypeface = fontManager.MatchCharacter(emojiChar);
- try
- {
- fileSystem.CopyFile(tempPath, filePath, false);
- }
- catch (IOException)
- {
+ paint.Typeface = emojiTypeface;
+ canvas.DrawText(text, (float)x-20, OffsetFromTopRightCorner + 12, paint);
}
-
- return tempPath;
}
internal static async Task<string> DownloadFont(string name, string url, IApplicationPaths paths, IHttpClient httpClient, IFileSystem fileSystem)
diff --git a/Emby.Drawing.Skia/UnplayedCountIndicator.cs b/Emby.Drawing.Skia/UnplayedCountIndicator.cs
index 56a2519a3a..b59bc1026a 100644
--- a/Emby.Drawing.Skia/UnplayedCountIndicator.cs
+++ b/Emby.Drawing.Skia/UnplayedCountIndicator.cs
@@ -40,7 +40,7 @@ namespace Emby.Drawing.Skia
{
paint.Color = new SKColor(255, 255, 255, 255);
paint.Style = SKPaintStyle.Fill;
- paint.Typeface = SKTypeface.FromFile(PlayedIndicatorDrawer.ExtractFont("robotoregular.ttf", _appPaths, _fileSystem));
+
paint.TextSize = 24;
paint.IsAntialias = true;