I'm trying to use the Xamarin Community Toolkit MaskedBehavior in my app for phone extensions which can be 2, 3 or even up to 6 digits long.
It's easy to define the mask if it's a set length but how do I use it in this case where I want the user to enter only numeric values but the length can be anywhere from 2 to 6 digits?
<Entry
Placeholder="Ext"
Text="{Binding Extension}"
Keyboard="Numeric">
<Entry.Behaviors>
<xct:MaskedBehavior
Mask="X?????"/>
</Entry.Behaviors>
</Entry>
Turns out, I don't have to do anything. When I set the mask as Mask="XXXXXX", it will accept any number of digits up to 6. It doesn't force the user to always enter six digits.
Related
From what I understand SF Pro is now the default font used in iOS mobile. I'm unclear as to how to use the different font weights of this font and even how to find out what is available.
Does anyone know how I can specify for example two different font resources NormalFont and BoldFont and have the app use the correct SF Pro fonts for the iOS?
<ResourceDictionary>
<OnPlatform x:TypeArguments="x:String" x:Key="NormalFont">
<On Platform="iOS" ???
<On Platform="Android" Value="Roboto-Regular.ttf#Roboto-Regular" />
</OnPlatform>
<OnPlatform x:TypeArguments="x:String" x:Key="BoldFont">
<On Platform="iOS" ???
<On Platform="Android" Value="Roboto-Bold.ttf#Roboto-Bold" />
</OnPlatform>
</ResourceDictionary>
To answer your question, we need to dug into several aspects of fonts & their mechanisms.
Let's start with how to get all weights for a specific font family. Referring to the official Apple docs, we can log all weights for all system fonts like this (in the iOS project):
foreach (var family in UIFont.FamilyNames)
{
var names = UIFont.FontNamesForFamilyName(family);
var namesAsString = string.Join(", ", names);
Debug.WriteLine($"Family: {family} Font names: {namesAsString}");
}
You can refer to system fonts by their name. System fonts are known to start with a dot (.) - e.g. San Francisco fonts can be .SFUIText-Bold, .SFUI-Regular, etc. Due to the nature of these fonts, being system ones, it was strongly discouraged for the developers to reference them by their name. One reason was that their name could change frequently.
The problem is that as of iOS 13, we're not supposed to load system fonts by name anymore. (Technically it's been advised against for a while, but iOS 13 actually enforces it by just giving you back Times New Roman when you ask for a system font.)
Here' a screenshot from WWDC 2019, regarding Font instantiation (by name):
Having said that, you can still refer to system fonts by name. After iOS 13 got released, this immediately broke everything in Xamarin. You can see in this GitHub issue. For now, they have implemented a workaround and system fonts (starting with a dot) are still possible to use. You can specify in your xaml something like this:
<OnPlatform x:TypeArguments="x:String" x:Key="NormalFont">
<On Platform="iOS" Value=".SFUI-Regular" />
<On Platform="Android" Value="Roboto-Regular.ttf#Roboto-Regular" />
</OnPlatform>
However, I would strongly suggest you to restrain from using the system fonts like this.
To sum up, you have 2 preferable options here:
Simply download & import the San Francisco font. The font can be downloaded for free form Apple's website. (link). After that, just refer to Xamarin's official docs (Use a custom font)
Stay with the default system font and add weight attributes in xaml (bold, italic, etc).
Personally, I would go with the first approach. That way, you will always be sure that you have the font files and no update would change the font. Going with the second approach, will always refer to the system font. This font may (and will surely) change at some point.
If we want to see what the default system font is, we can do it like so:
var systemFont = UIFont.SystemFontOfSize(17);
Debug.WriteLine($"System: {systemFont.FamilyName}");
Background
The Arabic letter noon ghunna (ں) is displayed incorrectly on my Windows 10 PC (in Chrome, Edge, Notepad and Word). The sequence ALEF, NOON GHUNNA, ALEF is displayed as:
The same sequence is displayed correctly on my Android phone without the dot:
For completeness, the actual unicode string (for copy/paste purposes) is:
اںا
There has been some controversy regarding this letter (L2-12/381) which has settled by now as seen from the Unicode Standard which states (since version 7 and up to the current 11):
Rendering systems should display U+06BA as a dual-joining letter, with all four contextual forms shown dotless, regardless of the language of the text.
But the dot appears in word-initial (ںا) and mid-word (اںا) positions. Final (اں) and isolated (ں) forms are fine.
Question
Now my question is, how can this be fixed, other than by waiting for Microsoft to fix it? I want to understand where the problem lies. Is it in the Uniscribe library, or is it down to the font being used? Can it be fixed by using a specifically crafted TrueType/OpenType font?
This turned out to be a font problem. Quite a few fonts on fonts.google.com show this letter correctly:
https://fonts.google.com/?subset=arabic&selection.family=Amiri|Aref+Ruqaa|Cairo|El+Messiri|Harmattan|Lemonada|Mada|Reem+Kufi|Scheherazade
I have a phone input on my app:
<TextField id="FieldTelefone" class="textArea"></TextField>
I want to creat a telephone mask, preferably with REGEX, but I am having a hard time to do so on appcelerator.
I need it to be:
(xx)_xxxx-xxxx
or
(xx)_xxxx-xxxxx
the brazilian phone numbers pattern.
but I am not being able to do it with only javascript, I could however validate it, could anyone help me ?
This git repo will help you: https://github.com/Nyvra/titanium-appcelerator-fields-mask
You surely have to extend the script, but there you'll see how it works
I'm not expert in Delphi and I'm trying to add "Extended ASCII String" broken into individual character and then add into the TSgringGrid.Cells[x,y]. Some of the characters are getting displayed but rest of the characters are not shown in these cells. Another way for me is to convert these characters in Hex-Mode and then show it but this is not Required.
ChartSet used was OEM_CHARSET and Font = Terminal. I simply wish to display all 255 characters in Cell. Basically I wanted to created the Binary Editor like Edit.com in Delphi/ Lazarus which is available in XP.
I used AnsiToUtf8(chr(i)) and it was solved.
I need to create a view with multiple TextBlocks populating thousands words. Unfortunately, when I set the Text of the TextBlock to contain a string longer than approx. 2000 characters the later part of the string is not displayed. The size of the TextBlock is still as if it contained all the characters, but the bottom of it is just blank.
Do you know what is the constraint that limit the length of the TextBlock? And how can I override it?
This is a limitation of the TextBox implementation on Windows Phone. If the area is larger thatn 2048 x 2048 it gets clipped.
This blog post has a workaround.
No UIElement can be greater than 2048 pixels in either dimension, however, if you exceed this limit, the space for the larger element is still reserved.
As a workaround, see this blog post which has a simple technique for splitting text into multiple TextBlocks.