It is ok on windows platform. But on android, non-English characters could not be correctly displayed. I checked the project setting, it is set "UTF-8". What should I do?
Thanks for your reply. I create the project from template "Gluon Mobile - Single View Project", and do not modify the build.gradle file.
I just modify the BasicView class, to add some Chinese characters:
public BasicView(String name)
{
super(name);
Label label = new Label("Hello 中文");
...
}
The "中文" is shown correctly on Windows, but can not show on Android.
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 am currently developing a Xamarin.Forms application. I am using IconizePlugin. The app is tabbedPage based and on toolbar I'm trying to include icons for some actions.
This is whay I'm getting:
Icons are showing well and in Xamarin.iOS gets the click event, while it is not working in Xamarin.Droid.
I included the corresponding nugets and followed every steps told in documentation and can't archive this. Other iconize controls in Droid are working fine except the IconToolbarItem.
Please help!
The workaround I found was to declare de IconToolbarItem in the c# code instead of xaml. Although I don't know why it wasn't working while on xaml.
Declaring the item li
ToolbarItems.Add(new IconToolbarItem
{
Icon = "fa-plus",
IconColor = Color.White,
Command = new Command(this.addBono)
});
Is there any way to change the window title of installer that created by Qt installer framework?
The window title set by <Title> tag from the config.xml that concatenated with "Setup".
there is a title property for pages but it change the title of page contained inside the tab controller.
Thanks.
I know it's late, but I recently had to deal with the same.
You have to change the sources
src\libs\installer\packagemanagergui.cpp - line 300 (v3.0.2)
PackageManagerGui::PackageManagerGui(PackageManagerCore *core, QWidget *parent)
: QWizard(parent)
, d(new Private)
, m_core(core)
{
if (m_core->isInstaller())
setWindowTitle(tr("%1 Setup").arg(m_core->value(scTitle)));
else
setWindowTitle(tr("Maintain %1").arg(m_core->value(scTitle)));
setWindowFlags(windowFlags() &~ Qt::WindowContextHelpButtonHint);
}
I recompiled the code without any changes to source code and only changed the translation files of Qt Installer Framework.
Hello Everyone I want to share the Text on Xamarin Form using Library plugin.share. I have successfully implemented the library and on android i can able to share the text but in iOS it returns me nothing. i have done the share code on button click event so when i click on button in iOS its doesn't returns me anything.i tried the Below code but doesn't got succeed
CrossShare.Current.Share("Hii alll", "Share");
please help me to get out of this,thanks in advance
You want to take a look at UIActivityViewController, you can find the documentation here https://developer.xamarin.com/api/type/MonoTouch.UIKit.UIActivityViewController/
And Xamarin.Forms specific example http://devcenter.wintellect.com/jwood/implementing-sharing-in-xamarin-forms
This is a bit old, but I was having a similar issue and was able to resolve it.
First of all, you need to add the plugin Plugin.Share to ALL Xamarin.Forms projects (Portable, iOS, Android, UWP).
In the class that references the share code, add...
using Plugin.Share;
using Plugin.Share.Abstractions;
CrossShare.Share() doesn't work with strings, directly. You need to new up a ShareMessage.
var title = "Title For The Share";
var message = "Text to share.";
await CrossShare.Current.Share(new ShareMessage { Text = message, Title = title });
I can't say specifically to iOS, as I don't have a Mac and can't test that project, but Android and Windows 10 is working.
I try to use custom fonts in my swift app, but they don't load.
I copy the fonts.ttf in my resources folder, and I added the names in Info.plist under "Fonts provided by application " key.
I've try with "Application fonts resource path" key from .plist , but no results.
Here is the code I used to apply my font. I've try with : "MyFont.ttf" , and "MyFont"
#IBOutlet weak var label:NSTextField!
override func awakeFromNib() {
label.font = NSFont(name: "MyFont.ttf", size: 15)
}
As "Application fonts resource path" is now a string type in XCode 7.3.1 and I couldn't seem to find a way to use an Array for multiple fonts, I used "." in the Info.plist:
Application fonts resource path String .
and this seemed to work to pick up all my custom fonts in a Resources folder dynamically e.g. using Swift
labelText.font = NSFont(name: "DS-Digital", size: 48)
However, to see it in XCode design mode (to choose a font from drop-down menu), I needed to first add the font to Font Book.
However, Font Book was not required for the dynamic method to work :)
ATSApplicationFontsPath is for macOS:
ATSApplicationFontsPath (String - macOS) identifies the location of a
font file or directory of fonts in the bundle’s Resources directory.
If present, macOS activates the fonts at the specified path for use by
the bundled app. The fonts are activated only for the bundled app and
not for the system as a whole. The path itself should be specified as
a relative directory of the bundle’s Resources directory. For example,
if a directory of fonts was at the path
/Applications/MyApp.app/Contents/Resources/Stuff/MyFonts/, you should
specify the string Stuff/MyFonts/ for the value of this key.
macOS app Instructions:
Select your Xcode project in the project navigator
Select your
app target
Click the + button and to add a New Copy Files Phase
Select Resources for the destination
Under subpath specify the directory (e.g. Fonts) where your embedded fonts will be copied to within your application bundle's Resources directory.
Drag and drop the font files into the file list of the Copy Files build phase.
UIAppFonts is for iOS:
UIAppFonts (Array - iOS) Specifies any app-provided fonts that should
be made available through the normal mechanisms. Each item in the
array is a string containing the name of a font file (including
filename extension) that is located in the app’s bundle. The system
loads the specified fonts and makes them available for use by the app
when that app is run.
This key is supported in iOS 3.2 and later.
By directly setting the Application fonts resource path as my font file's name, I solved this problem by sheer luck.
For those whose font family is called something like My-Custom-Font-Family:
be aware that in code you should instantiate your custom font like this: NSFont(name: "MyCustomFontFamily-Bold", size: 20)
Spaces and "-" are ignored and font type is written after "-". I did not see this in any docs and spend a few hours trying to figure out wtf was wrong.
Also if you want to get list of all available fonts you can use this code
for font in NSFontManager.shared.availableFonts {
print(font)
}
First add the desired font you want to embed to your OSX app to your project:
Then click project > Info, then click the plus sign and add a new key "Application fonts resource path" and type the name of your fonts there creating an array of strings:
Now you can select custom font and the name of the font will show there, you still need to use the Font Book to make it available inside Xcode.
Try doing this from the interface builder, in the attributes inspector .