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

Label:[WinUI] FontFamily is not recognized in Unpackaged application. #9104

Closed
1 of 4 tasks
Tracked by #10564
anjPetrov opened this issue Aug 1, 2022 · 17 comments · Fixed by #14783 or #15400
Closed
1 of 4 tasks
Tracked by #10564

Label:[WinUI] FontFamily is not recognized in Unpackaged application. #9104

anjPetrov opened this issue Aug 1, 2022 · 17 comments · Fixed by #14783 or #15400
Labels
area/desktop 🖥️ Windows / WinUI / Project Reunion & Mac Catalyst / macOS specifics (Menus & other Controls)) area/publishing 🏁 blocked Work that is currently blocked external fixed-in-7.0.92 Look for this fix in 7.0.92! fixed-in-7.0.100 fixed-in-7.0.101 fixed-in-8.0.0-preview.4.8333 Look for this fix in 8.0.0-preview.4.8333! fixed-in-8.0.0-preview.5.8529 Look for this fix in 8.0.0-preview.5.8529! fixed-in-8.0.0-preview.6.8686 Look for this fix in 8.0.0-preview.6.8686! p/1 Work that is critical for the release, but we could probably ship without partner/cat 😻 Client CAT Team partner/winui WinUI / Project Reunion platform/windows 🪟 t/bug Something isn't working

Comments

@anjPetrov
Copy link

anjPetrov commented Aug 1, 2022

Description

Label FontFamily is not recognized when App is published as type Unpackaged.
I have set up a .NET MAUI project with only a label inside of it using "Font Awesome" and declaring an icon.
Label works as expected in Debug and Release. However when the app is published as Unpackaged the FontFamily is no longer recognized. I have tried different Font families but none seem to work.

Sample app:
DemoApp.zip

App look in Release:
AppRelease

App look in Unpackaged application:
AppPublish

Steps to Reproduce

1.Open the Sample project.
2. Use the following command: dotnet publish -f net6.0-windows10.0.19041.0 -c Release -p:WindowsPackageType=None -p:SelfContained=true -p:WindowsAppSDKSelfContained=true
3. Run the App from the exe file

Expected: User sees the icon of the label.
Actual: User sees an empty rectangle

Version with bug

6.0.408 (current)

Last version that worked well

Unknown/Other

Affected platforms

Windows

Affected platform versions

net6.0-windows10.0.19041.0

Did you find any workaround?

No response

Relevant log output

No response

VS bug #1778184

Depends on

@anjPetrov anjPetrov added s/needs-verification Indicates that this issue needs initial verification before further triage will happen t/bug Something isn't working labels Aug 1, 2022
@Eilon Eilon added the area/desktop 🖥️ Windows / WinUI / Project Reunion & Mac Catalyst / macOS specifics (Menus & other Controls)) label Aug 1, 2022
@jfversluis jfversluis removed the s/needs-verification Indicates that this issue needs initial verification before further triage will happen label Aug 24, 2022
@MartyIX
Copy link
Collaborator

MartyIX commented Oct 17, 2022

Is there any workaround for this issue?

@mattleibow
Copy link
Member

I think we use the ms-appx:/// scheme to load fonts, and I wonder if this is not working in unpackanged apps. I will test and both create a WinUI issue and see if I can create a workaround/fix.

@mattleibow
Copy link
Member

Seems to work in WinUI, so I will have to check a bit more...

WinUI-Test-App.zip

@mattleibow
Copy link
Member

This is a workaround for apps that are experiencing this:

#if WINDOWS
Microsoft.Maui.Handlers.LabelHandler.Mapper.AppendToMapping("FontFamily", (handler, element) =>
{
    if (element.Font.Family == "FontAwesome")
    {
        const string FontAwesomeFamily = "ms-appx:///Fontawesome6brands.otf#Font Awesome 6 Brands";
        handler.PlatformView.FontFamily = new Microsoft.UI.Xaml.Media.FontFamily(FontAwesomeFamily);
    }
});
#endif

I am looking into why this is happening as the code is the same and should produce the same result packaged/unpackaged...

@mattleibow
Copy link
Member

Seems to be related to Win2D:

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

@mattleibow
Copy link
Member

I managed to isolate the issue and it is a result of Win2D throwing an exception: microsoft/Win2D#891

@mattleibow mattleibow added the partner/winui WinUI / Project Reunion label Oct 25, 2022
@danies8
Copy link

danies8 commented Oct 26, 2022

@mattleibow this bug still exists in window platform on last version.
See all icons are corrupted:
image

@mattleibow
Copy link
Member

@danies8 are those using your custom MAUI fonts or is that default controls? Was this packaged or unpackaged.

Unless you are using custom fonts from the maui app yourself, I think the issue lies in WinUI and can be resolved here:microsoft/microsoft-ui-xaml#7866

Have you checked to see if all the system fonts are available on windows server? Like Segoe and Segoe UI?

@danies8
Copy link

danies8 commented Oct 26, 2022

  1. I'm using this fonts in MAUI app:
    .ConfigureFonts(fonts => { fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular"); fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold"); })
  2. I'm using unpackaged installation on window 10 and server 2019
  3. How do i check if all the system fonts are available on windows server? Like Segoe and Segoe UI?

@mattleibow
Copy link
Member

mattleibow commented Oct 26, 2022

@danies8 those glyphs I do not think are part of your cusotm fonts as they are OS fonts.

For server, I am not super familiar, but can you just see the Fonts in the Control Panel? However, that discussion is best on the WinUI issue (microsoft/microsoft-ui-xaml#7866) - this issue is for tracking missing custom fonts in labels and things which is actually tracked here: microsoft/Win2D#891

Not sure this issue is worth keeping open as we can't really do anything as both issues are bugs in Windows - either the OS or the SDK.

@samhouts samhouts added the p/1 Work that is critical for the release, but we could probably ship without label Nov 2, 2022
@samhouts samhouts added this to the .NET 8 Planning milestone Jan 26, 2023
@samhouts samhouts modified the milestones: .NET 8 Planning, Backlog Jan 26, 2023
@ghost
Copy link

ghost commented Jan 26, 2023

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@Redth
Copy link
Member

Redth commented Mar 23, 2023

@Scottj1s
Copy link

See also: microsoft/microsoft-ui-xaml#8304
Which in turn mentions the APIs unsupported in unpackaged apps: microsoft/microsoft-ui-xaml#6325

@samhouts samhouts added the blocked Work that is currently blocked label Apr 6, 2023
@mattleibow
Copy link
Member

Reopening as we have fixed the issue in maui, but we need the win2d to be updated and released first.

@samhouts samhouts modified the milestones: Backlog, .NET 8 May 24, 2023
mattleibow added a commit that referenced this issue Jun 1, 2023
github-actions bot pushed a commit that referenced this issue Jun 1, 2023
rmarinho pushed a commit that referenced this issue Jun 1, 2023
rmarinho pushed a commit that referenced this issue Jun 2, 2023
Fixes #9104

Co-authored-by: Matthew Leibowitz <mattleibow@live.com>
github-actions bot pushed a commit that referenced this issue Jun 2, 2023
mattleibow added a commit that referenced this issue Jun 3, 2023
Fixes #9104

Co-authored-by: Matthew Leibowitz <mattleibow@live.com>
@samhouts samhouts added the fixed-in-8.0.0-preview.4.8333 Look for this fix in 8.0.0-preview.4.8333! label Jun 8, 2023
rmarinho added a commit that referenced this issue Jun 14, 2023
* Update Win2D (#15400)

Fixes #9104

* Fix broken button when adding PGR implicitly (#15419)

* Fix broken button when adding PGR implicitly

* - fix conditional

* Bump Xamarin.GooglePlayServices.Maps from 118.1.0.1 to 118.1.0.2 (#15409)

Bumps [Xamarin.GooglePlayServices.Maps](https://github.com/xamarin/GooglePlayServicesComponents) from 118.1.0.1 to 118.1.0.2.
- [Release notes](https://github.com/xamarin/GooglePlayServicesComponents/releases)
- [Commits](https://github.com/xamarin/GooglePlayServicesComponents/commits)

---
updated-dependencies:
- dependency-name: Xamarin.GooglePlayServices.Maps
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Correct docs for Grid ColumnSpacing/RowSpacing (#15425)

* Bump Xamarin.Firebase.AppIndexing from 120.0.0.11 to 120.0.0.12 (#15406)

Bumps [Xamarin.Firebase.AppIndexing](https://github.com/xamarin/GooglePlayServicesComponents) from 120.0.0.11 to 120.0.0.12.
- [Release notes](https://github.com/xamarin/GooglePlayServicesComponents/releases)
- [Commits](https://github.com/xamarin/GooglePlayServicesComponents/commits)

---
updated-dependencies:
- dependency-name: Xamarin.Firebase.AppIndexing
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Modify generated ID starting point to prevent collision with ItemViewType (#15438)

* Move Windows and iOS Frame measure and arrange to xplat layer (#14987)

* Fix Windows frame not resizing with screen

Fixes #13552

* Make iOS Frame renderer us shared implementation

Moving some frame border calculations to the xplat layer with more shared code

* Add test

* Auto-format source code

* Remove padding update

Windows was double counting padding

* Fix test for other platforms

* Auto-format source code

* Fix typo

* Add padding test

---------

Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>

* Bump Microsoft.NET.Test.Sdk from 17.6.0 to 17.6.1 (#15408)

Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.6.0 to 17.6.1.
- [Release notes](https://github.com/microsoft/vstest/releases)
- [Changelog](https://github.com/microsoft/vstest/blob/main/docs/releases.md)
- [Commits](microsoft/vstest@v17.6.0...v17.6.1)

---
updated-dependencies:
- dependency-name: Microsoft.NET.Test.Sdk
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Pin main branch to net7 (#15452)

* [uitests] Fix appium versions (#15453)

* Upload appium

* Pin all versions

* Use variables

* Prep better the script

* Update dependencies from https://github.com/dotnet/xharness build 20230529.1 (#15450)

Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Common , Microsoft.DotNet.XHarness.TestRunners.Xunit
 From Version 8.0.0-prerelease.23272.1 -> To Version 8.0.0-prerelease.23279.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

* [net8.0] Don't pin sdk on net8 branch

* Add the drag and drop gestures back to the appium ui tests for mac/ios targets

* Update ModalNavigationManager.cs (#15483)

* Don't reset App.Current OnResume if it's already set (#15496)

* First pass at adding developer layout docs (#15426)

* First pass at adding developer layout docs

* Update docs/design/layout.md

Co-authored-by: MartyIX <203266+MartyIX@users.noreply.github.com>

---------

Co-authored-by: MartyIX <203266+MartyIX@users.noreply.github.com>

* Clear window from ContextStub after it's closed (#15495)

* Remove legacy launch settings (#15511)

* Skip tests currently having issues on WinUI (#15527)

* Skip tests currently having issues

* Update AssertionExtensions.Windows.cs

* - Update skip notes

* - update notes

* - update test notes

* - update tests that have always been failing

* - update test notes

* - fix compile errors

* Fix incorrect calculation of expansion size when *s have different scalars (#15532)

Fixes #15494

* Change the tokens to null (#15560)

Co-authored-by: tj-devel709 <tjlambert@microsoft.com>

* Add all platforms if build args don't restrict to a single platform (#15561)

* Restore & obsolete Windows MauiWebView ctor (#15541)

* Restore & obsolete Windows MauiWebView ctor

* Reinstate functionality for obsoleted ctor

* Ignore additional tests for iOS (#15513)

* Bump Microsoft.NET.Test.Sdk from 17.6.1 to 17.6.2 (#15502)

Bumps [Microsoft.NET.Test.Sdk](https://github.com/microsoft/vstest) from 17.6.1 to 17.6.2.
- [Release notes](https://github.com/microsoft/vstest/releases)
- [Changelog](https://github.com/microsoft/vstest/blob/main/docs/releases.md)
- [Commits](microsoft/vstest@v17.6.1...v17.6.2)

---
updated-dependencies:
- dependency-name: Microsoft.NET.Test.Sdk
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update dependencies from https://github.com/dotnet/xharness build 20230607.1 (#15581)

Microsoft.DotNet.XHarness.CLI , Microsoft.DotNet.XHarness.TestRunners.Common , Microsoft.DotNet.XHarness.TestRunners.Xunit
 From Version 8.0.0-prerelease.23279.1 -> To Version 8.0.0-prerelease.23307.1

Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>

* Update Versions.props

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Matthew Leibowitz <mattleibow@live.com>
Co-authored-by: Shane Neuville <shneuvil@microsoft.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: E.Z. Hart <hartez@users.noreply.github.com>
Co-authored-by: Michael Cao <poppop208@gmail.com>
Co-authored-by: Juan Diego Herrera <juherrera@microsoft.com>
Co-authored-by: GitHub Actions Autoformatter <autoformat@example.com>
Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com>
Co-authored-by: Scott Banning <scoban@microsoft.com>
Co-authored-by: MartyIX <203266+MartyIX@users.noreply.github.com>
Co-authored-by: scoban <sbanni@users.noreply.github.com>
Co-authored-by: TJ Lambert <50846373+tj-devel709@users.noreply.github.com>
Co-authored-by: tj-devel709 <tjlambert@microsoft.com>
Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>
@samhouts samhouts added the fixed-in-8.0.0-preview.5.8529 Look for this fix in 8.0.0-preview.5.8529! label Jun 21, 2023
@ss1969
Copy link

ss1969 commented Jul 3, 2023

This is a workaround for apps that are experiencing this:

#if WINDOWS
Microsoft.Maui.Handlers.LabelHandler.Mapper.AppendToMapping("FontFamily", (handler, element) =>
{
    if (element.Font.Family == "FontAwesome")
    {
        const string FontAwesomeFamily = "ms-appx:///Fontawesome6brands.otf#Font Awesome 6 Brands";
        handler.PlatformView.FontFamily = new Microsoft.UI.Xaml.Media.FontFamily(FontAwesomeFamily);
    }
});
#endif

I am looking into why this is happening as the code is the same and should produce the same result packaged/unpackaged...

Don't know how to apply this workaround. Can you please paste a full MauiProgram.cs ?

@ghost
Copy link

ghost commented Jul 3, 2023

Hello lovely human, thank you for your comment on this issue. Because this issue has been closed for a period of time, please strongly consider opening a new issue linking to this issue instead to ensure better visibility of your comment. Thank you!

@SeccoMaracuja
Copy link

This is a workaround for apps that are experiencing this:

#if WINDOWS
Microsoft.Maui.Handlers.LabelHandler.Mapper.AppendToMapping("FontFamily", (handler, element) =>
{
    if (element.Font.Family == "FontAwesome")
    {
        const string FontAwesomeFamily = "ms-appx:///Fontawesome6brands.otf#Font Awesome 6 Brands";
        handler.PlatformView.FontFamily = new Microsoft.UI.Xaml.Media.FontFamily(FontAwesomeFamily);
    }
});
#endif

I am looking into why this is happening as the code is the same and should produce the same result packaged/unpackaged...

Please post a full MauiProgram.cs

@samhouts samhouts added fixed-in-8.0.0-preview.6.8686 Look for this fix in 8.0.0-preview.6.8686! fixed-in-7.0.92 Look for this fix in 7.0.92! labels Jul 11, 2023
@dotnet dotnet locked as resolved and limited conversation to collaborators Sep 8, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/desktop 🖥️ Windows / WinUI / Project Reunion & Mac Catalyst / macOS specifics (Menus & other Controls)) area/publishing 🏁 blocked Work that is currently blocked external fixed-in-7.0.92 Look for this fix in 7.0.92! fixed-in-7.0.100 fixed-in-7.0.101 fixed-in-8.0.0-preview.4.8333 Look for this fix in 8.0.0-preview.4.8333! fixed-in-8.0.0-preview.5.8529 Look for this fix in 8.0.0-preview.5.8529! fixed-in-8.0.0-preview.6.8686 Look for this fix in 8.0.0-preview.6.8686! p/1 Work that is critical for the release, but we could probably ship without partner/cat 😻 Client CAT Team partner/winui WinUI / Project Reunion platform/windows 🪟 t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.