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

CanvasTextFormat throws in Unpackaged apps #941

Open
mattleibow opened this issue Nov 29, 2023 · 22 comments
Open

CanvasTextFormat throws in Unpackaged apps #941

mattleibow opened this issue Nov 29, 2023 · 22 comments

Comments

@mattleibow
Copy link

This is very similar to #891

But instead of the CanvasFontSet API, I am trying to render an image using text with the CanvasTextFormat type. This thows a similar exception:

The URI specified in the CanvasTextFormat's FontFamily has an invalid scheme; the scheme may be omitted, or must be one of ms-appx:// or ms-appdata://.

This is our code:
https://github.com/dotnet/maui/blob/d8939fdfc48fb36d18a3bb6d9cafb1c09c19117b/src/Core/src/ImageSources/FontImageSourceService/FontImageSourceService.Windows.cs#L55-L95

We are basically rendering a character onto a canvas using some font properties. Fonts work fine in packaged and when I do unpackaged I get an exception.

I also tried a full path using the file:// and that does not crash, but it renders the placeholder/missing empty rectangle.

@mattleibow
Copy link
Author

This issue came up in our case of rendering text to a bitmap: dotnet/maui#15802

@AathifMahir
Copy link

Facing the same issue here as well:
AathifMahir/MauiIcons#79

@BurkusCat
Copy link

BurkusCat commented Feb 14, 2024

I have a .NET MAUI app where this issue is causing button icons to break in the unpackaged WinUI version of the app. There doesn't appear to be any workarounds with handlers which is disappointing. The only workaround would be to not use font icons at all and use .svgs which I'm hesitant to do specifically for WinUI unpackaged only.

Would it be possible to have a fix for this issue prioritised, please?

@jeremy-visionaid
Copy link

Agreed. this should be a priority issue for Win2D as it is a blocker for other downstream issues.

@AndreasReitberger
Copy link

Facing the same issue. Is there an ETA for this fix from Microsoft?

@mattleibow thanks for open this issue 😊

@jingliancui
Copy link

Hi team, I met the same issue on Maui, it impacted the unpacked program. Do you have any workaround or fixing plan on this. Thanks so much in advance.

@AndreasReitberger
Copy link

The issue at the MAUI repository has been closed now. Is the fix from Win2D already read?
@mattleibow

Thank you!

@BrundhaVelusamy
Copy link

Is there any update on this?

@BrundhaVelusamy
Copy link

Any update on this issue?

@AndreasReitberger
Copy link

@mattleibow
Any chances that this is checked by Microsoft soon? Thank you!

@mattleibow
Copy link
Author

Has anyone tried the latest Win2D? All the Maui use cases are now working in 1.2.0

@jeremy-visionaid
Copy link

It works OK for me since 1.2.0 and I don't see any newer versions

@AndreasReitberger
Copy link

@SF3969
Can you verify the fix? It seems that only Syncfusion controls have this issue now.
Maybe an update of the dependencies is needed here as well.

@mattleibow Thank you!

@AathifMahir
Copy link

Has anyone tried the latest Win2D? All the Maui use cases are now working in 1.2.0

When can we expect Maui Side to update the Win2D Dependency to v1.2.0? Next Service Release?

@jingliancui
Copy link

Has anyone tried the latest Win2D? All the Maui use cases are now working in 1.2.0

When can we expect Maui Side to update the Win2D Dependency to v1.2.0? Next Service Release?

Maybe it is better to raise an issue on maui repo

@mattleibow
Copy link
Author

@AathifMahir what version are you using because this has been fixed for months. Since 8.0.10.

@AathifMahir
Copy link

@AathifMahir what version are you using because this has been fixed for months. Since 8.0.10.

This is regarding below issue, more users keeps reporting on this, when it comes v8.0.10 I don't think that fixes the issue

AathifMahir/MauiIcons#79

@ArunachalamSyncfusion
Copy link

Is there any update on this issue?

@mattleibow
Copy link
Author

Since we are not able to repro, please attach a repro sample as well as a binlog so we can investigate.

@SwethavasanthSF3977
Copy link

We have created a repro sample and attached it. Kindly take a look.
FontFamilyIssue.zip

@BrundhaVelusamy
Copy link

Please provide high priority to resolve this issue.

@Redth
Copy link
Member

Redth commented Nov 8, 2024

It looks like there's some confusion here between packaged/unpackaged scenarios.

The sample provided by @SwethavasanthSF3977 is using an ms-appx:// scheme for the font source which won't work in unpackaged app scenarios.

For example, in the sample, the value being used in one case is: ms-appx:///Cinzel-Regular.ttf#Cinzel. If you instead change this to use file:// scheme and the full path to the font like this: file:///C:/code/FontFamilyIssue/bin/Debug/net8.0-windows10.0.19041.0/win10-x64/Cinzel-Regular.ttf#Cinzel it will work with an unpackaged app.

You can see the PR where MAUI started supporting unpackaged apps by detecting the packaging format and finding the correct path to the file for unpackaged: dotnet/maui#22646

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

10 participants