mirror of
https://github.com/greenshot/greenshot
synced 2025-08-22 06:23:24 -07:00
Compress TwemojiMozilla
This commit is contained in:
parent
4e36be535b
commit
128436eafd
3 changed files with 28 additions and 6 deletions
|
@ -38,8 +38,8 @@ Source: {#ReleaseDir}\System.Memory.dll; DestDir: {app}; Components: greenshot;
|
|||
Source: {#ReleaseDir}\System.Numerics.Vectors.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
|
||||
Source: {#ReleaseDir}\System.Runtime.CompilerServices.Unsafe.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
|
||||
Source: {#ReleaseDir}\System.Buffers.dll; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
|
||||
Source: {#ReleaseDir}\TwemojiMozilla.ttf; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
|
||||
Source: {#ReleaseDir}\emoji-test.txt; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
|
||||
Source: {#ReleaseDir}\TwemojiMozilla.ttf.gz; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
|
||||
Source: {#ReleaseDir}\emoji-test.txt.gz; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
|
||||
Source: {#GreenshotProjectDir}\log4net.xml; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion
|
||||
Source: {#ReleaseDir}\checksum.SHA256; DestDir: {app}; Components: greenshot; Flags: overwritereadonly ignoreversion replacesameversion
|
||||
;Source: ..\greenshot-defaults.ini; DestDir: {app}; Flags: overwritereadonly ignoreversion replacesameversion
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Reflection;
|
||||
|
@ -41,15 +42,31 @@ namespace Greenshot.Editor.Drawing.Emoji
|
|||
private static readonly Lazy<FontFamily> TwemojiFontFamily = new(() =>
|
||||
{
|
||||
var exeDirectory = Path.GetDirectoryName(Assembly.GetCallingAssembly().Location);
|
||||
var twemojiFontFile = Path.Combine(exeDirectory, "TwemojiMozilla.ttf");
|
||||
var twemojiFontFile = Path.Combine(exeDirectory, "TwemojiMozilla.ttf.gz");
|
||||
if (!File.Exists(twemojiFontFile))
|
||||
{
|
||||
throw new FileNotFoundException($"Can't find {twemojiFontFile}, bad installation?");
|
||||
}
|
||||
|
||||
Stopwatch sw = new();
|
||||
sw.Start();
|
||||
using var fileStream = new FileStream(twemojiFontFile, FileMode.Open, FileAccess.Read);
|
||||
TwemojiFontCollection.Add(fileStream);
|
||||
using var gzStream = new GZipStream(fileStream, CompressionMode.Decompress);
|
||||
using var memoryStream = new MemoryStream();
|
||||
gzStream.CopyTo(memoryStream);
|
||||
memoryStream.Seek(0, SeekOrigin.Begin);
|
||||
sw.Stop();
|
||||
|
||||
Console.WriteLine($"Uncompress .ttf: {sw.ElapsedMilliseconds} ms");
|
||||
|
||||
sw.Reset();
|
||||
sw.Start();
|
||||
TwemojiFontCollection.Add(memoryStream);
|
||||
TwemojiFontCollection.TryGet("Twemoji Mozilla", out var fontFamily);
|
||||
sw.Stop();
|
||||
|
||||
Console.WriteLine($"Parse .ttf: {sw.ElapsedMilliseconds} ms");
|
||||
|
||||
return fontFamily;
|
||||
});
|
||||
|
||||
|
|
|
@ -20,6 +20,11 @@
|
|||
OutputFile="Controls\Emoji\emoji-test.txt.gz" />
|
||||
</Target>
|
||||
|
||||
<Target Name="CompressTwemojiMozillaTtfResource" BeforeTargets="BeforeBuild" Condition="!Exists('Drawing\Emoji\TwemojiMozilla.ttf.gz')">
|
||||
<GZipTask InputFile="Drawing\Emoji\TwemojiMozilla.ttf"
|
||||
OutputFile="Drawing\Emoji\TwemojiMozilla.ttf.gz" />
|
||||
</Target>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Controls\BindableToolStripButton.cs">
|
||||
<SubType>Component</SubType>
|
||||
|
@ -98,9 +103,9 @@
|
|||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<TargetPath>emoji-test.txt.gz</TargetPath>
|
||||
</ContentWithTargetPath>
|
||||
<ContentWithTargetPath Include="Drawing\Emoji\TwemojiMozilla.ttf">
|
||||
<ContentWithTargetPath Include="Drawing\Emoji\TwemojiMozilla.ttf.gz">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<TargetPath>TwemojiMozilla.ttf</TargetPath>
|
||||
<TargetPath>TwemojiMozilla.ttf.gz</TargetPath>
|
||||
</ContentWithTargetPath>
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
Add table
Add a link
Reference in a new issue