-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Conversation
"Lobster-Regular.ttf#Lobster-Regular" now works as just "Lobster-Regular"
UWP now supports `PTM55FT#PTMono`
…into CustomFonts
"Lobster-Regular.ttf#Lobster-Regular" now works as just "Lobster-Regular"
UWP now supports `PTM55FT#PTMono`
…into CustomFonts
@Clancey Any chance you could fix the conflicts? Thanks! |
var fontStream = GetEmbeddedResourceStream(foundFont.assembly, font); | ||
|
||
var type = Registrar.Registered.GetHandlerType(typeof(EmbeddedFont)); | ||
var fontHandler = (IEmbeddedFontLoader)Activator.CreateInstance(type); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was noticing you're using the Activator here... for consistency I believe this should be using the DependencyResolver/DependencyService in Xamarin.Forms... also if someone for some insane reason decided to provide their own IEmbeddedFontLoader this would give them the ability to use DI...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure what benefit this would give us, Right now, it gets the embedded font loader from the registrar. So you can still replace it if you want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well I'm the first to admit I would have to ask what on earth someone is doing replacing the FontLoader... that said I just see this as a consistency issue. Anything other types that Xamarin.Forms may require can at the dev's choosing be generated by a DI container... this would explicitly prevent that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am still wondering why this is considered an inconsistency issue. When you retrieve something from the Registrar, we always created it using activator. I am wondering when/where that changed? The the registrar is DI.. You can already swap things out whenever you want. You can register your own FontLoader, then it will load yours. Still failing to see an issue. This is the same thing as saying we should move all Renderers to DI instead of the registrar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The consistency has to do with the refactoring that was done around the DependencyResolver to add support for those who want their DI Container to be the source of truth for resolving types. The intent was that the only place in the code base that Activator.CreateType should called should be in the DependencyResolver itself for the 99% of the time where people aren't using the hook.
@PureWeen The failing test is |
Xamarin.Forms.Core/Registrar.cs
Outdated
else | ||
{ | ||
if (attribute.ShouldRegister()) | ||
Registered.Register(attribute.HandlerType, attribute.TargetType, attribute.SupportedVisuals); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registered.Register(attribute.HandlerType, attribute.TargetType, attribute.SupportedVisuals); | |
Registered.Register(attribute.HandlerType, attribute.TargetType, attribute.SupportedVisuals, attribute.Priority); |
@samhouts just curious what's going on with this... would really love to be using this... |
@dansiegel Assuming the build goes well, this will be merged into master for release in 4.5.0. |
Fantastic.. so glad to see this merged! thanks @samhouts |
I just try to run this new feature. But I can't see the fonts rendering. Then on my XAML using: Also on the release note: |
Does this new feature do anything to deal with FontAttributes on Android? If, for example, you register fonts fontfamily-regular.ttf, fontfamily-bold.ttf, fontfamily-italic.ttf, and fontfamily-bolditalic.ttf, is there away to use just "fontfamily" as the name and then if you set FontAttributes to "Bold", will it select the correct font automatically? I've been trying to find a solution for this. When you register a font resource, is there a way to tie it directly to specific FontAttributes? Are there any plans to add support for font weights? I made this modification to Xamarin.Forms.Platform.Android.FontExtensions as a proof of concept that works great, and am wondering if there is anything that will work like this in the new version?
Thanks, and if this is the wrong place, my apologies. |
It's not working for me when I try IconFont Here for example:
I am setting IconFont for Syncfusion TabView I added the Taqyeem.ttf to my shared project and set the Build to Embedded Resources Then In the Shared resources also I added the following line to the AssemblyInfo.cs:
Although I try the old way for custom fonts I get the images shown properly |
Description of Change
This pull request unifies the way Custom Fonts are specified cross platform.
API Changes
Added:
New classes
Platforms Affected
Behavioral/Visual Changes
This is Backwards compatible. Users can continue to use fonts as they want. However it now allows us to embed fonts as Resources. This also allows us to declare custom fonts in a uniformed way.
PR Checklist