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

new FontFamily( "file:///absolutepath#fontname" ) doesn't load TTF #3766

Closed
Red-Rover opened this issue Dec 4, 2020 · 6 comments
Closed
Labels

Comments

@Red-Rover
Copy link

Describe the bug
Loading a font dynamically from the file system doesn't work correctly in a WinUI 3 Desktop application. Loading fonts dynamically using the file:///absolutepath#fontname syntax works in WPF.

Steps to reproduce the bug
Steps to reproduce the behavior:

  1. Create a blank project using the "Blank App, Packaged (WinUI Desktop)" Visual Studio Template
  2. Add a TextBlock to the to the MainWindow.xaml file with the following properties:
  1. In the MainWindow.cs file add the following after InitializeComponent() in the MainWindow() constuctor:

_textBlock.FontFamily = new FontFamily(@"file:///absoluatepath#fontname");

// replace absolutepath with the path to a TTF and fontname with the name of the font.

  1. Run the application.

Expected behavior
It should load the font and apply it to the component.

Version Info

NuGet package version:
[Microsoft.WinUI 3.0.0-preview3.201113.0]

Windows app type:

UWP Win32
Yes

Windows 10 2004 20262.1010 Windows Feature Experience Pack 120.27510.103230.0

Device form factor Saw the problem?
Desktop Yes
Xbox
Surface Hub
IoT
@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Dec 4, 2020
@StephenLPeters StephenLPeters added area-Resources product-winui3 WinUI 3 issues and removed needs-triage Issue needs to be triaged by the area owners labels Dec 5, 2020
@StephenLPeters
Copy link
Contributor

@MikeHillberg FYI

@StephenLPeters StephenLPeters added needs-triage Issue needs to be triaged by the area owners team-Framework labels Dec 5, 2020
@chrisglein
Copy link
Member

Not a surprising gap given that WinUI3 is coming from the code written to target UWP and not Win32, and in UWP absolute file paths are not so much a thing.

To be clear, this is a mismatch with WPF, not a mismatch between inbox OS XAML and WinUI3?

@chrisglein chrisglein removed the needs-triage Issue needs to be triaged by the area owners label Jan 12, 2021
@github-actions
Copy link

This issue is stale because it has been open 180 days with no activity. Remove stale label or comment or this will be closed in 5 days.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 3, 2023
@thecco
Copy link

thecco commented Aug 26, 2024

So how can I load fontfamily from file path?
I need to publish as a single file. (can't use 'Copy to Output Directory')
I want to use EmbeddedResource, but I can't do this either.

Finally, I wrote the ttf file in AppData folder from EmbeddedResource.
How do I load this now?

@microsoft-github-policy-service microsoft-github-policy-service bot added the needs-triage Issue needs to be triaged by the area owners label Aug 26, 2024
@castorix
Copy link

Finally, I wrote the ttf file in AppData folder from EmbeddedResource. How do I load this now?

It works with relative path for custom fonts or full path for System fonts
I used it in DWriteCore test to fill the ComboBoxes with fonts ({x:Bind FontFamilyPath} in XAML, pFonts.Add in code)

@PetrMinar
Copy link

Hello to all,

I just discovered this old issue while searching for the same thing. And I found an workaround, though a bit limited. Hope it might help you a bit.

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

No branches or pull requests

6 participants