Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CanvasFontSet throws in Unpackaged apps #891

Closed
mattleibow opened this issue Oct 25, 2022 · 6 comments
Closed

CanvasFontSet throws in Unpackaged apps #891

mattleibow opened this issue Oct 25, 2022 · 6 comments

Comments

@mattleibow
Copy link

Description

I am trying to load a font in an unpackaged app:

using var fontSet = new CanvasFontSet(new Uri("ms-appx:///Fontawesome6brands.otf"));

This results in an exception:

System.ArgumentException: Value does not fall within the expected range.
   at WinRT.ExceptionHelpers.<ThrowExceptionForHR>g__Throw|20_0(Int32 hr)
   at Microsoft.Graphics.Canvas.Text.CanvasFontSet._ICanvasFontSetFactory.Create(Uri uri)
   at Microsoft.Graphics.Canvas.Text.CanvasFontSet.<>c__DisplayClass11_0.<.ctor>b__0()
   at Microsoft.Graphics.Canvas.Text.CanvasFontSet..ctor(Uri uri)
   at Microsoft.Maui.FontManager.FindFontFamilyName(String fontFile) in C:\Projects\maui\src\Core\src\Fonts\FontManager.Windows.cs:line 152

Related Issues

Version Information

<PackageReference Include="Microsoft.Graphics.Win2D" Version="1.0.4" />
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.1.5" />
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22000.194" />

Reproduction Sample

App8.zip

@SBProX
Copy link

SBProX commented Nov 12, 2022

I have the same issue when loading Font file (with unpackaged app WinApp SDK 1.2)

@SBProX
Copy link

SBProX commented Nov 12, 2022

It looks like it's a bug in the SDK when you try to use resources or content via ms-appx:///

I tried many possible options, specified the absolute path to the file, but ABI.System.Uri.СreateMarshaller(...) throws an exception.

As soon as you make the application packaged, everything works.

@Redth
Copy link
Member

Redth commented Mar 23, 2023

@AllenD-MSFT
Copy link

@mattleibow This looks fixed. Can you close this issue?

@mattleibow
Copy link
Author

This was fixed. Thanks!

@marossi7
Copy link

marossi7 commented May 16, 2024

Hi

Was this actually fixed ? I still have the issue here with .NET 7 and WinAppSDK (1.5.240428000)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants