I am binding string to label's text property. and string is containing (C). but when it's loading on Label it's converted to copyright symbol ©.
Code Snippets:
<ContentPage>
<Label Text="This is Testing for copyright (c)"/>
</ContentPage>
Note: It's showing copyright symbol if we used custom fonts. I using Manrope-Bold.ttf font in app.
Related
I'm new to Xamarin development, but try to be exact.
Using Visual Studio 2022, with Xamarin version 17.0.0.182 (as displayed in VS About).
Found this great article on how to use Bootstrap icons, but it seems to be out of date. When I followed the steps and provided hex codes for the characters, I didn't get the expected glyiphs.
I found that
new Xamarin needs new methods,
new Bootstrap fonts need new ways.
Here they are.
1.) Get the font from the Bootstrap github repo at https://github.com/twbs/icons
Go to releases (https://github.com/twbs/icons/releases), choose latest, scroll down to Assets, download the bootstrap-icons-x.x.x.xip file.
Unzip it, and find fonts/bootstrap-icons.woff.
Not something you can use in Xamarin right away :-(
2.) Convert the woff file to ttf
I googled for a converter and used https://cloudconvert.com/woff-to-ttf
Now you have the ttf you need :-)
3.) Now follow the current Xamarin method of adding a font to your app.
The process is described here: https://devblogs.microsoft.com/xamarin/embedded-fonts-xamarin-forms/
In short:
add the ttf file to the shared Xamarin project, Embedded Resources / Fonts
change file properties / Build Action to "Embedded resource"
register the font by adding a line to the end of Assemblyinfo.cs:
[assembly: ExportFont("bootstrap-icons.ttf", Alias = "Bootstrap")]
4.) Use it in xaml like
<Label FontFamily="Bootstrap" Text=""/>
to display a magnifying glass.
You may also define a Label style, but I'll skip that for now.
4/b.) To use it in xaml via binding
Oh, if things were easy...
When using a binding to display a glyph, there's one more hoop to jump, thanks to these guys for the solution: Using data binding, how do I bind text which contains emojis to a label and have it display correctly?
So, in xaml:
<!-- set BindingContext to MyViewModel -->
<Label FontFamily="Bootstrap" Text="{Binding StateIconName}" />
in your MyViewModel:
public string StateIconName
{
get => WebUtility.HtmlDecode("");
}
5.) To browse available glyphs (icons)
Open the overview page: https://icons.getbootstrap.com/
6.) To find the unicode character code, also referred to as "Unicode HTML Entity"
Check the name of the icon above in step 5.
Open the Bootstrap-icons.css file from Github: https://github.com/twbs/icons/blob/main/font/bootstrap-icons.css
Search for the name of the glyph to find the character code, something like:
.bi-zoom-in::before { content: "\f62c"; }
Use this code in xaml like
I'm Working on Xamarin Forms project using Visual Studio 2017 , I want to show few texts in side label using different styles so i used span text as below but it gives me compile error "No property, bindable property, or event found for 'Text', or mismatching type between value and property." My code is below .
<Label TextColor="{Binding ColorStatus}" Margin="0,0,0,0" HorizontalTextAlignment="Start" FontSize="Medium">
<Label.FormattedText>
<FormattedString>
<Span Text="Thank you." FontAttributes="Bold"/>
<Span Text="You have tagged-" FontAttributes="Bold"/>
<Span Text= "{Binding ActivityName}" FontAttributes="Bold"/>
</FormattedString>
</Label.FormattedText>
</Label>
Update your Xamarin.Forms nuget package to the latest one. Bindable spans are available from Xamarin.Forms 3.1.0+ version.
More about releases and features you can find it here.
I have the following XAML code:
<Label Text="Hello Forms with XAML">
<Label.FontFamily>
<OnPlatform x:TypeArguments="x:String">
<OnPlatform.iOS>Roboto-Light</OnPlatform.iOS>
<OnPlatform.Android>Roboto-Light.ttf#Roboto-Light</OnPlatform.Android>
<OnPlatform.WinPhone>Assets/Fonts/Roboto-Light.ttf#Roboto-Light</OnPlatform.WinPhone>
</OnPlatform>
</Label.FontFamily>
</Label>
However I get the error "Java.Lang.RuntimeException: Font asset not found Roboto-Light" even though the font is placed in the Assets folder:
What can I do to fix this?
On Android you must ensure that the part after the # is the actual name of the font. This part is NOT directly the same as the file name. I also use Roboto in one of my apps and it's declared as:
<OnPlatform.Android>fonts/Roboto-Regular.ttf#Roboto</OnPlatform.Android>
<OnPlatform.Android>fonts/Roboto-Bold.ttf#Roboto Bold</OnPlatform.Android>
You might want to try yours as:
<OnPlatform.Android>Roboto-Light.ttf#Roboto Light</OnPlatform.Android>
You can find out this name on Mac by selecting the font in FontBook and checking its Full Name property.
You can find a comprehensive guide to using custom fonts in Xamarin.Forms at this Xamarin Developers Guide Link.
As Steven highlighted, it's important to ensure that your font ttf file is in the right place, in this instance you appear to have got it right, the location for the android project is indeed the 'assets' folder.
Xamarin.Forms for Android can reference a custom font that has been
added to the project by following a specific naming standard. First
add the font file to the Assets folder in the application project and
set Build Action: AndroidAsset.
Setting a custom font in C# backing classes, snippet amended from the above source:
public class SomeMethod()
{
new Label
{
Text = "Hello, Forms!",
FontFamily = Device.OnPlatform(null, "Roboto-Light.ttf#Roboto-Light", null)
}
}
The xaml should actually be:
<Label Text="Hello Forms with XAML">
<Label.FontFamily>
<OnPlatform x:TypeArguments="x:String">
<On Platform="Android">Roboto-Light.ttf#Roboto-Light</On>
</OnPlatform>
</Label.FontFamily>
</Label>
It is worth mentioning that the roboto theme should be part of the native android project already if your targeting API 14 or above. So on android you can actually just use the 'sans-serif-light' font which is infact Roboto. Follow this link to see an excellent answer on an android specific thread about the fonts they now include in API 14+
The file tempates in Xcode 4.5 contain the following in the header
// ___FILENAME___
// ___PROJECTNAME___
//
// Created by ___FULLUSERNAME___ on ___DATE___.
//___COPYRIGHT___
How does one set the ___COPYRIGHT___ to a custom value.
Thanks,
Joel
Changing the organization name will help you in set the COPYRIGHT value.
Please look at the screen , (Xcode4.5 screen shot)
When you create a new project in Xcode 4.4 or later, there is an Organization Name text field. The name you enter in the text field goes in the copyright notice, which looks similar to the following:
Copyright (c) 2012 Company Name. All rights reserved.
If you make a mistake entering a company name when creating the project, you can change the company name by selecting the project file from the project navigator and opening the file inspector.
Being able to set the company name is enough customization for most people. If you need to further customize the copyright notice, I recommend making a copy of Apple's file templates, and adding a custom copyright notice to the comments. More information on file templates is available in the following article:
Creating Custom Xcode 4 File Templates
when i type text in radeditor and apply font and font style and color to the text and then export to rtf and save the file and open that file all formatting that made with text like font,font size,color is not in that file. And font is set to the times new Roman.
this thing also happens with radeditor export to rtf demo on telerik site Try
http://demos.telerik.com/aspnet-ajax/editor/examples/rtfexport/defaultcs.aspx
RadEditor uses two different free libraries to provide Import to RTF and Export to RTF features.
The first one used to provide RFT to HTML importation is available in this CodeProject's article: http://www.codeproject.com/KB/recipes/RtfConverter.aspx.
The library used for HTML to RTF exportation is available here http://www.codeproject.com/KB/recipes/RtfConverter.aspx.
As you can see both libraries are written by different developers and they are not fully compatible with each other.
For your convenience I prepared a list of know limitations of the Import and Export features of both libraries:
RFT to HTML (Import)
bold - supported. I was able to export bold formatting from the provided by you Bold.rtf file.
italic - supported
underline - supported
foreground and background colors - supported
table elements - unsupported
images- unsupported
indentations - unsupported
HTML to RTF (export)
bold - supported.
italic - supported
underline - unsupported
foreground and background colors - unsupported
table elements - partially supported - table borders are not exported
images- unsupported
indentations - supported
The unsupported scenarios are hard for development and require more time for implementations and testing. Our development is concentrated currently on producing valid XHTML content and the import and export problems are logged with medium priority in our ToDo list. That is why we could not provide firm estimate for when the required features will be available.
Please note that good RTF import and export tools are very expensive. That is why if you are currently not satisfied with the offered by RadEditor RTF functionality, you can search in Internet for another free or paid RTF to HTML importation and HTML to RTF exportation tools and we will help you to integrate them with RadEditor.