unoplatform / uno.toolkit.ui

A set of custom controls for the WinUI and the Uno Platform not offered out of the box by WinUI, such as Card, TabBar, NavigationBar, etc.
https://platform.uno/
MIT License
83 stars 27 forks source link

Cross-platform API to get all system font families #643

Open hungnd1475 opened 3 years ago

hungnd1475 commented 3 years ago

What would you like to be added:

A cross-platform API that can be used to retrieve all system font families.

Why is this needed:

Right now there is no easy way for developers to get all system font families across all platforms. This enhancement might be very useful for LOB applications with rich text editing capabilities.

For which Platform:

Anything else we need to know?

carldebilly commented 3 years ago

For Windows, you can use that: http://microsoft.github.io/Win2D/html/M_Microsoft_Graphics_Canvas_Text_CanvasTextFormat_GetSystemFontFamilies.htm (from the Win2D.uwp NuGet package.

But it's not part of the UWP/WinUI contract, so not available right now on Uno. But...

CanvasTextFormat.GetSystemFontFamilies Method
Gets a list of font families available.
hungnd1475 commented 3 years ago

@carldebilly I am aware of using platform-specific code, but it would be nicer if we have a single API handling this use case. Right now we need to stick with this workaround I guess. Anyway thanks for pointing me to those links, it would save me some time searching for them.

carldebilly commented 3 years ago

I agree it would be a good idea to create a unified API for that. But since it's not present in UWP/WinUI, it would need to be in the Uno toolkit.

LeftTwixWand commented 3 years ago

For me, System.Drawing.Font is not working on a droid project.... I also tried to add System.Drawing.Common package to project, but it didn't help. Is this problem relates to this issue?

c-npolyak commented 1 year ago

Guys, unless I do not understand something, it should not be very difficult to create a platform independent way of getting the fonts. Why has not it been done?

jeromelaban commented 1 year ago

@c-npolyak we mostly work by priorities on our customers, and this has not been requested yet.

That being said, at the time this question was asked, UWP was not providing this and while WinAppSDK does not, Uno.Toolkit may be good place to provide an API for such a feature that could be available for more platforms, WinAppSDK included.

MartinZikmund commented 1 year ago

I think Uno Extensions would be a better place for this - can we move this issue there @jeromelaban ?

jeromelaban commented 1 year ago

This looks like a toolkit feature rather than extensions, I'll move it there.