Skip to content

Commit

Permalink
Revert "chore: Switch to embedded resource"
Browse files Browse the repository at this point in the history
This reverts commit d64862d.
  • Loading branch information
Youssef1313 committed Jun 18, 2024
1 parent db465d3 commit 4482696
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
<ItemGroup>
<PackageReference Include="SkiaSharp" />
<PackageReference Include="SkiaSharp.NativeAssets.Linux" />

<EmbeddedResource Include="..\UITests.Shared\Assets\Fonts\OpenSans\OpenSans.ttf.manifest" LogicalName="SamplesApp.Skia.Generic.Assets.Fonts.OpenSans.OpenSans.ttf.manifest" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@

<ItemGroup>
<Compile Update="Program.cs" />
<EmbeddedResource Include="..\UITests.Shared\Assets\Fonts\OpenSans\OpenSans.ttf.manifest" LogicalName="SamplesApp.Skia.Gtk.Assets.Fonts.OpenSans.OpenSans.ttf.manifest" />
</ItemGroup>

<PropertyGroup>
Expand Down
1 change: 0 additions & 1 deletion src/SamplesApp/UITests.Shared/UITests.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -9576,7 +9576,6 @@
<Content Include="$(MSBuildThisFileDirectory)Assets\Fonts\Nillambari-K7y1W.ttf" />
<Content Include="$(MSBuildThisFileDirectory)Assets\Fonts\OpenSans\*.ttf" />
<Content Include="$(MSBuildThisFileDirectory)Assets\Fonts\OpenSans\OpenSans.ttf.manifest" />
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Assets\Fonts\OpenSans\OpenSans.ttf.manifest" />
<Content Include="$(MSBuildThisFileDirectory)Assets\Fonts\Renaiss-Italic.ttf" />
<Content Include="$(MSBuildThisFileDirectory)Assets\Fonts\RoteFlora.ttf" />
<Content Include="$(MSBuildThisFileDirectory)Assets\Formats\animated.gif" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,6 @@
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>

<EmbeddedResource Include="..\UITests.Shared\Assets\Fonts\OpenSans\OpenSans.ttf.manifest" LogicalName="UnoIslandsSamplesApp.Skia.Wpf.Assets.Fonts.OpenSans.OpenSans.ttf.manifest" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text.Json;
Expand Down Expand Up @@ -61,18 +60,19 @@ internal static void OnFontLoaded(string font, SKTypeface? typeface)
}
}

private static Assembly _entryAssembly = Assembly.GetEntryAssembly()!;
private static string _entryAssemblyName = _entryAssembly.GetName().Name!;

private static async Task<SKTypeface?> LoadTypefaceFromApplicationUriAsync(Uri uri, FontWeight weight, FontStyle style, FontStretch stretch)
{
try
{
var resourceName = uri.PathAndQuery.TrimStart('/').Replace('/', '.') + ".manifest";
resourceName = $"{_entryAssemblyName}.{resourceName}";
var manifestStream = _entryAssembly.GetManifestResourceStream(resourceName);
if (manifestStream is not null)
// TODO (This comment should be resolved during code review):
// Should the user be responsible for adding ".manifest" to the ms-appx path himself?
// The benefit of the user doing so is that we will not have to first check if a manifest exists.
var manifestUri = new Uri(uri.OriginalString + ".manifest");
var path = Uri.UnescapeDataString(manifestUri.PathAndQuery).TrimStart('/');
if (await StorageFileHelper.ExistsInPackage(path))
{
var manifestFile = await StorageFile.GetFileFromApplicationUriAsync(manifestUri);
var manifestStream = await manifestFile.OpenStreamForReadAsync();
uri = new Uri(FontManifestHelpers.GetFamilyNameFromManifest(manifestStream, weight, style, stretch));
}
}
Expand Down

0 comments on commit 4482696

Please sign in to comment.