Forms9Patch v1.2.0.3 for Xamarin
Forms9Patch v1.2.0.3 for Xamarin
Xamarin Forms is great for developing apps on Android and iOS but it is missing some important features:
Scalable images
PCL and SharedLibrary, multi-screen / multi-resolution image management
HTML formatted text for labels and buttons
PCL and SharedLibrary custom font management
Android developers can use NinePatch bitmaps, the drawable directory naming convention, Html.FromHtml, and a bunch of complex file manipulations to address the image issue. Likewise, iOS developers can use ResizeableImageWithCapInsets, the @2x, @3x, @4x file naming convention, and some 3rd party libraries for this purpose. Forms 9 Patch enhances Xamarin Forms to make multi-resolution / multi-screen image management, custom fonts, and HTML text formatting easy for PCL and Shared Library apps for iOS and Android.
More about Forms9Patch.ImageSource
Xamarin Forms provides native iOS and Android multi-screen image management (described here). This requires storing your iOS images using the native iOS schema and storing your Android images using the Android schema. In other words, duplicative efforts to get the same results on both Android and iOS. Forms9Patch.ImageSource extends Xamarin.Forms.ImageSource capabilities to bring multi-screen image management to your Shared Library or PCL Assemblies - so you only have to generate and configure your app's image resources once. Forms9Patch.ImageSource is a cross-platform implementation to sourcing multi-screen images in Xamarin Forms PCL and Shared Library apps as embedded resources.
More about using custom fonts
Xamarin.Forms approach to custom fonts is very native - which doesn't save the developer time nor help with the learning curve. Form9Patch takes the approach I'm betting Xamarin would have taken if they had more time: everything is done in the PCL or Shared Library project and it's done only once. To outline the process of setting up a custom font:
Copy your custom font to the Resources.Fonts folder of your application's PCL or Shared Library project
Set the Build Action of the custom font to Embedded Resource
In the Solution view, right click on the font file, select Properties, and note the font's Resource ID
When you want to use your custom font, you specify it by setting one the following to the Embedded Resource ID of the font:
FontFace property of the Forms9Patch element (will apply the custom font to entire string and yet, can be overridden by any of the below)
face attribute of an HTML markup font tag you embed in the string you pass to Form9Patch element's HtmlText property
font-family value of style attribute for any valid tag you embed in the string you pass to Form9Patch element's HtmlText property
More about Forms9Patch.Label
Xamarin Forms provides the FormattedString and Span classes as a way to format text used in labels. However, there are a number of things that could be better:
Make it easier to use. There is a lot of work in setting up the Spans of a FormattedString and any changes to the string means you're likely having to build your spans all over again.
Custom Fonts. Xamarin's approach is the same as native, meaning you have to do everything in the platform projects. It should be easier and faster if this could all be done in the PCL or Shared Library project.
Make it work for Buttons as well.
Forms9Patch address all of these through one new property and one enhanced property for its Label AND its MaterialButton, Segment, ImageButtonState elements:
FontFamily: Before, you couldn't access custom fonts on all platforms without a lot of pain. Now, you just add your custom font to your PCL or Shared Library project as an Embedded Resource and then access it by setting FontFamily to the font's Embedded Resource ID.
HtmlText: Give it a string with HTML markup and it automatically does all the work. Plus, it does things you can't with Xamarin Form's FormattedString, like subscripts, superscripts, underlines, stikethoughs, and custom fonts.
Only for V.I.P
Warning! You are not allowed to view this text.