Download and use FontFamily in Xamarin Android app - xamarin

I am trying to download and use the Montserrat font family but I can't understand how to use the ttf file in my xamarin android project. I am downloading the ttf from this site https://fonts.google.com/ . Can anyone help me? Thanks a lot.

You can work with fonts in android using Typeface.
To use your custom downloaded fonts put them in your assets folder (better to make a subfolder named Fonts) then make a typeface using:
Typeface.CreateFromAsset(Application.Context.Assets, "Fonts/yourfontname.ttf");

Related

How to use Font Awesome in Xamarin.iOS?

I am trying to use Font Awesome Icons in my Xamarin.iOS project.
In my Xamarin.Android project it was pretty simple:
I downloaded the Font Awesome WebKit from here
I copied the .ttf-Files of the fonts I want to use in my Assets folder
I create a new Typeface for my TextView with the font and use the unicode of the icon
Code:
var myIcon = new TextView(Context);
var regularFont = Typeface.CreateFromAsset(Context.Assets, "fonts/fa-regular-400.ttf");
myIcon.SetTypeface(regularFont, TypefaceStyle.Normal);
myIcon.Text = "\uf007";
I can change TextColor, BackgroundColor, etc. like a normal text.
My problem is, I can't figure out, how to use Font Awesome in my Xamarin.iOS project. Most tutorials and How-Tos are directed to Xamarin.Forms. I tried to merge many of these approaches, but it failed.
The only approach I found is to draw the .svg-Files with SkiaSharp, but that is no option for my use case.
Add .ttf files in your Xamarin iOS project (I have added it in resources)
Now inside info.plist Add a new key “Fonts provided by application”
Expand the array, and in string value add your fontname (eg: fa-solid-900.ttf) which you have added in your project
Setup Done:
Now Just wherever you want to add fontawesome icon just select font awesome as font family in storyboard but make sure to add text programmatically
SushiHangovers comment leads me to the solution for my problem.
FontAwesome Pro and xamarin.ios only one font can be active
It was not possible to use 3 Font Awesome fonts at the same time in the Designer, but it works when they are used during runtime via code.

how to add custom Icons fonts on nativescript

I am trying to use Icon Fonts on my NativeScript app.
So I followed the oficial documentation and those were my steps:
(1) - Downloaded the ttf files into my app/fonts folder:
(2) - On my app.css I declared the font global class like so:
.fa {
font-family: "Font Awesome 5 Free", "fa-regular-400", "fa-solid-
900";
}
.fa-solid {
font-family: "Font Awesome 5 Free", "fa-solid-900";
}
(3) - Then on my html component:
<Label text="" class="far"></Label>
But My Icon does not appear on the screen. I am using NativeScript 6+ with Angular 8.
Any Help ?
I figure it out why the Font Icons wasn't showing up!
I was using NativeScript 5.1 and since version 6.0 was released I migrated the project:
tns migrate
The problem is that I was using NS with Angular 8 and according to the docs I have to place my fonts on the project's root folder.
In your root application folder (This is the app folder for NativeScript Core, and the src folder for Angular 6+), create a folder called fonts and place the .ttf there.
So, Clearly the problem was that my fonts folder was inside /app when it should be inside /src folder.
It took me too long to realize that because for some strange reason my imported text fonts like 'Montserrat.tff' was working just fine. So I thought the problem was related with NativeScript or whatever.
In short, the Wrong way to do it with NativeScript and Angular 6+:
The right way:
I hope this helps newcomers who may stumble in the same problem/situation.

Loading PCL sourced HTML page in Cross Browser project (Xamarin)

I am using Xamarin to support
Android
iOS
Windows 8.1
WPF
I can create a PCL project that each of those platforms can see from their platform specific project.
What I want to be able to do is host a HTML page and associated javascript files in the PCL.
All the examples I have seen for loading Local Html files are when there is a copy of the HTML in each platform specific project. I don't want 4 copies of the HTML I want one copy in the PCL.
Can this be done?
We tried to do the same thing a few months ago and as far as I remember we couldn't. The solution for us to make it work was downloading (or extracting in your case) html files to the local directory for each platform using PCLStorage nuget and load directly from local path with custom renderers.
We used custom renderers for each platform for WebView instead of crossx webview. One thing to note that instead of using UIWebView you must use WKWebView if you're targeting iOS9+.
Simply pass your main directory of html files to each renderer and try native controls to use local content. Unfortunately xamarin's crossx WebView does not provide flexible actions when it comes to local content.

Xamarin cross platform UWP images are missing

I am working on Xamarin cross platform project where if I placed the images inside the sub folder it is not loading on the screen.
Please refer my code and folder structure along with properties
Put your Images folder under Assets Folder like this:
Assets/Images/*.png
and if you are using Localizing make like this:
Assets/Images/en/*.png
Assets/Images/another language/*.png
for more information you can check this Working with Images
i hope that answer you question.

How to Integrate non supported fonts in WP7

I am creating a English to Mangolean Dictionary app; So i need to display mangolean word corresponding to my english word; i read from a blog that wp7 only supports limited language set. So how can i over come my issue. Please help me to solve this issue.
There's a tutorial on embedding fonts in Silverlight here: http://paulyanez.com/interactive/index.php/2009/12/embedding-fonts-in-silverlight/ The implementation for Windows Phone is exactly the same. The tutorial uses Expression Blend (which is part of the developer tools download and also free for Windows Phone), which is the simplest, quickest, and easiest way to embed fonts for Silverlight.
Apart from the supported Fonts you can add your on fonts to you project. For example create a folder named Fonts in you project and add you *.TTF files(Font Files). By referring this font files you can resolve your issues.

Resources