mirror of
https://github.com/greenshot/greenshot
synced 2025-08-24 07:06:23 -07:00
SixLabors vanillia
This commit is contained in:
parent
9e45eb29d6
commit
4f1478ec34
6 changed files with 32 additions and 32 deletions
|
@ -30,9 +30,9 @@ Source: {#ReleaseDir}\Svg.dll; DestDir: {app}; Components: greenshot; Flags: ove
|
||||||
Source: {#ReleaseDir}\Fizzler.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
|
Source: {#ReleaseDir}\Fizzler.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
|
||||||
Source: {#ReleaseDir}\HtmlAgilityPack.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
|
Source: {#ReleaseDir}\HtmlAgilityPack.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
|
||||||
Source: {#ReleaseDir}\Newtonsoft.Json.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
|
Source: {#ReleaseDir}\Newtonsoft.Json.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
|
||||||
Source: {#ReleaseDir}\Emoji.Wpf.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
|
Source: {#ReleaseDir}\SixLabors.ImageSharp.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
|
||||||
Source: {#ReleaseDir}\Typography.GlyphLayout.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
|
Source: {#ReleaseDir}\SixLabors.ImageSharp.Drawing.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
|
||||||
Source: {#ReleaseDir}\Typography.OpenFont.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
|
Source: {#ReleaseDir}\SixLabors.Fonts.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
|
||||||
Source: {#GreenshotProjectDir}\log4net.xml; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion
|
Source: {#GreenshotProjectDir}\log4net.xml; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion
|
||||||
Source: {#ReleaseDir}\checksum.SHA256; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
|
Source: {#ReleaseDir}\checksum.SHA256; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
|
||||||
;Source: ..\greenshot-defaults.ini; DestDir: {app}; Flags: overwritereadonly ignoreversion replacesameversion
|
;Source: ..\greenshot-defaults.ini; DestDir: {app}; Flags: overwritereadonly ignoreversion replacesameversion
|
||||||
|
|
|
@ -19,6 +19,7 @@ using System.Reflection;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Greenshot.Editor.Drawing;
|
using Greenshot.Editor.Drawing;
|
||||||
|
using SixLabors.Fonts.Unicode;
|
||||||
|
|
||||||
namespace Greenshot.Editor.Controls
|
namespace Greenshot.Editor.Controls
|
||||||
{
|
{
|
||||||
|
@ -44,7 +45,7 @@ namespace Greenshot.Editor.Controls
|
||||||
|
|
||||||
public static void Load()
|
public static void Load()
|
||||||
{
|
{
|
||||||
_init = Task.Run(() =>
|
_init ??= Task.Run(() =>
|
||||||
{
|
{
|
||||||
ParseEmojiList();
|
ParseEmojiList();
|
||||||
|
|
||||||
|
@ -194,6 +195,12 @@ namespace Greenshot.Editor.Controls
|
||||||
var unqualified = text.Replace("\ufe0f", "");
|
var unqualified = text.Replace("\ufe0f", "");
|
||||||
if (qualified_lut.ContainsKey(unqualified))
|
if (qualified_lut.ContainsKey(unqualified))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// Fix simple fully-qualified emojis
|
||||||
|
if (CodePoint.GetCodePointCount(text.AsSpan()) == 2)
|
||||||
|
{
|
||||||
|
text = text.TrimEnd('\ufe0f');
|
||||||
|
}
|
||||||
|
|
||||||
qualified_lut[unqualified] = text;
|
qualified_lut[unqualified] = text;
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Concurrent;
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -13,6 +14,7 @@ using SixLabors.ImageSharp.Formats.Png;
|
||||||
using SixLabors.ImageSharp.PixelFormats;
|
using SixLabors.ImageSharp.PixelFormats;
|
||||||
using SixLabors.ImageSharp.Processing;
|
using SixLabors.ImageSharp.Processing;
|
||||||
using Font = SixLabors.Fonts.Font;
|
using Font = SixLabors.Fonts.Font;
|
||||||
|
using FontFamily = SixLabors.Fonts.FontFamily;
|
||||||
using FontStyle = SixLabors.Fonts.FontStyle;
|
using FontStyle = SixLabors.Fonts.FontStyle;
|
||||||
using Image = System.Drawing.Image;
|
using Image = System.Drawing.Image;
|
||||||
using TextOptions = SixLabors.Fonts.TextOptions;
|
using TextOptions = SixLabors.Fonts.TextOptions;
|
||||||
|
@ -21,23 +23,19 @@ namespace Greenshot.Editor.Drawing
|
||||||
{
|
{
|
||||||
internal static class EmojiRenderer
|
internal static class EmojiRenderer
|
||||||
{
|
{
|
||||||
private static SixLabors.Fonts.FontFamily? _fontFamily;
|
private static Lazy<FontFamily> _fontFamily = new Lazy<FontFamily>(() =>
|
||||||
|
{
|
||||||
|
using var stream = Assembly.GetCallingAssembly().GetManifestResourceStream("Greenshot.Editor.Resources.TwemojiMozilla.ttf");
|
||||||
|
var fontCollection = new FontCollection();
|
||||||
|
fontCollection.Add(stream);
|
||||||
|
fontCollection.TryGet("Twemoji Mozilla", out var fontFamily);
|
||||||
|
return fontFamily;
|
||||||
|
});
|
||||||
|
|
||||||
private static ConcurrentDictionary<string, BitmapSource> _iconCache = new ConcurrentDictionary<string, BitmapSource>();
|
private static ConcurrentDictionary<string, BitmapSource> _iconCache = new ConcurrentDictionary<string, BitmapSource>();
|
||||||
|
|
||||||
public static Image<Rgba32> GetImage(string emoji, int iconSize)
|
public static Image<Rgba32> GetImage(string emoji, int iconSize)
|
||||||
{
|
{
|
||||||
if (_fontFamily == null)
|
|
||||||
{
|
|
||||||
using var stream = Assembly.GetCallingAssembly().GetManifestResourceStream("Greenshot.Editor.Resources.TwemojiMozilla.ttf");
|
|
||||||
var fontCollection = new FontCollection();
|
|
||||||
fontCollection.Add(stream);
|
|
||||||
if (fontCollection.TryGet("Twemoji Mozilla", out var fontFamily))
|
|
||||||
{
|
|
||||||
_fontFamily = fontFamily;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var font = _fontFamily.Value.CreateFont(iconSize, FontStyle.Regular);
|
var font = _fontFamily.Value.CreateFont(iconSize, FontStyle.Regular);
|
||||||
|
|
||||||
var image = new Image<Rgba32>(iconSize, iconSize);
|
var image = new Image<Rgba32>(iconSize, iconSize);
|
||||||
|
@ -51,8 +49,8 @@ namespace Greenshot.Editor.Drawing
|
||||||
var verticalOffset = font.Size * 0.045f;
|
var verticalOffset = font.Size * 0.045f;
|
||||||
var textOptions = new TextOptions(font)
|
var textOptions = new TextOptions(font)
|
||||||
{
|
{
|
||||||
Origin = new SixLabors.ImageSharp.PointF(0, font.Size / 2.0f - verticalOffset),
|
Origin = new SixLabors.ImageSharp.PointF(font.Size / 2.0f, font.Size / 2.0f - verticalOffset),
|
||||||
HorizontalAlignment = HorizontalAlignment.Left, VerticalAlignment = VerticalAlignment.Center
|
HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center
|
||||||
};
|
};
|
||||||
|
|
||||||
image.Mutate(x => x.DrawText(textOptions, emoji, SixLabors.ImageSharp.Color.Black));
|
image.Mutate(x => x.DrawText(textOptions, emoji, SixLabors.ImageSharp.Color.Black));
|
||||||
|
@ -103,10 +101,14 @@ namespace Greenshot.Editor.Drawing
|
||||||
|
|
||||||
public static void FillIconCache(IEnumerable<string> emojis)
|
public static void FillIconCache(IEnumerable<string> emojis)
|
||||||
{
|
{
|
||||||
Parallel.ForEach(emojis, emoji =>
|
var font = _fontFamily.Value.CreateFont(64, FontStyle.Regular);
|
||||||
|
var metric = font.FontMetrics;
|
||||||
|
foreach (var emoji in emojis)
|
||||||
{
|
{
|
||||||
GetIcon(emoji);
|
var image = new Image<Rgba32>(64, 64);
|
||||||
});
|
RenderEmoji(emoji, font, image);
|
||||||
|
_iconCache[emoji] = image.ToBitmapSource();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BitmapSource GetIcon(string emoji)
|
public static BitmapSource GetIcon(string emoji)
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
</None>
|
</None>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="SixLabors.ImageSharp" Version="2.0.0-alpha.0.156" />
|
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta13.15" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -86,13 +86,4 @@
|
||||||
<EmbeddedResource Include="Resources\emoji-test.txt" />
|
<EmbeddedResource Include="Resources\emoji-test.txt" />
|
||||||
<EmbeddedResource Include="Resources\TwemojiMozilla.ttf" />
|
<EmbeddedResource Include="Resources\TwemojiMozilla.ttf" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Reference Include="SixLabors.Fonts">
|
|
||||||
<HintPath>..\SixLabors.Fonts.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="SixLabors.ImageSharp.Drawing">
|
|
||||||
<HintPath>..\SixLabors.ImageSharp.Drawing.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue