dotnet / maui

.NET MAUI is the .NET Multi-platform App UI, a framework for building native device applications spanning mobile, tablet, and desktop.
https://dot.net/maui
MIT License
22.28k stars 1.76k forks source link

System.ArgumentException occurs with Font Family in Win2D Controls on Windows in VS Code #24609

Open BrundhaVelusamy opened 2 months ago

BrundhaVelusamy commented 2 months ago

Description

When running a .NET MAUI application in Visual Studio Code on Windows, a System.ArgumentException with the message "Value does not fall within the expected range" occurs if the font family is set for any Win2D-drawn custom controls. The exception does not occur when running the same project in Visual Studio.

Replication sample: FontFamilyIssue.zip

Steps to Reproduce

  1. Run the project on VS code.
  2. System.ArgumentException will occur.
  3. Remove the font family from the custom control, the exception will not occur.

Link to public reproduction project repository

No response

Version with bug

8.0.82 SR8.2

Is this a regression from previous behavior?

Not sure, did not test other versions

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

No response

Did you find any workaround?

No

Relevant log output

No response

github-actions[bot] commented 2 months ago

Hi I'm an AI powered bot that finds similar issues based off the issue title.

Please view the issues below to see if they solve your problem, and if the issue describes your problem please consider closing this one and thumbs upping the other issue to help us prioritize it. Thank you!

Open similar issues:

Closed similar issues:

Note: You can give me feedback by thumbs upping or thumbs downing this comment.

ninachen03 commented 2 months ago

I can repro this issue at Windows platform on the latest 17.12.0 Preview 1.0(8.0.82 &8.0.80 & 8.0.3). image

mattleibow commented 2 months ago

This may be a packaged/unpackaged difference. Because Windows apps cannot be launched via the CLI/VSCode :( we use an unpackaged app. VS uses packaged by default.

Now, does this help you? Not really, but it will explain why the different IDEs behave differently.

What is the value that eventually gets to the font family? format.FontFamily = fontFamily?.Source;

BrundhaVelusamy commented 2 months ago

This may be a packaged/unpackaged difference. Because Windows apps cannot be launched via the CLI/VSCode :( we use an unpackaged app. VS uses packaged by default.

Now, does this help you? Not really, but it will explain why the different IDEs behave differently.

What is the value that eventually gets to the font family? format.FontFamily = fontFamily?.Source;

@mattleibow, Thank you for your details.

format.FontFamily = fontFamily?.Source; --> Here format.FontFamily will get the details of the assigned font family of the custom control, like ms-appx:///Cinzel-Regular.ttf#Cinzel.

There is already an existing issue in WinUI when building the project on the Unpackaged version on Visual Studio: CanvasTextFormat throws in Unpackaged apps

BrundhaVelusamy commented 2 months ago

Any update on this issue?

BrundhaVelusamy commented 2 months ago

Please provide high priority for this issue.