Iconize
Iconize copied to clipboard
Iconize May Conflict With FontImageSource on Andorid
-----------sorry for my mistaken operation Xamarin.Forms 3.6 Iconize 3.5.117 +
A page With IconLabel and Image using FontImageSource , both these use a same fontfamily.
On Android the icon shown as a [x] symbol,the image is correct.
On iOS it seem works.
this is the sample xaml
<OnPlatform x:Key="FontAwesomeSolid" x:TypeArguments="system:String">
<On Platform="iOS" Value="FontAwesome5Free-Solid" />
<On Platform="Android" Value="iconize-fontawesome-solid.ttf#" />
</OnPlatform>
<Image >
<Image.Source>
<FontImageSource FontFamily="{StaticResource ExFontAwesomeSolid}" Color="Red" Glyph=""/>
</Image.Source>
</Image>
<iconize:IconLabel Text="fas-check" />
the IconLabel is incorrect on Android . Or I can't use the `iconize-fontawesome-solid.ttf#' or what is the right result to reuse the font file?
If anyone stumbles upon this I did this
public class MaterialFontImageSource : FontImageSource
{
public MaterialFontImageSource()
{
FontFamily = "iconize-material.ttf#";
}
public string Icon
{
get
{
return base.Glyph;
}
set
{
if(string.IsNullOrEmpty(value))
{
base.Glyph = string.Empty;
}
else
{
if (!value.StartsWith("md-"))
{
value = $"md-{value}";
}
var query = MaterialCollection.Icons.FirstOrDefault(x => x.Key == value);
if (query != null)
{
base.Glyph = $"{query.Character}";
}
else
{
base.Glyph = value;
}
}
}
}
}
This worked for me on Android, you could check for Platform on the constructor to change the font Its usage is as follows
<ToolbarItem.IconImageSource>
<assets:MaterialFontImageSource
Icon="face" Size="12"/>
</ToolbarItem.IconImageSource>