I have downloaded custom font through code and want to apply it on my text view for that I want to know the exact name of font.
Note:
I want to know the font internal name not the font file name.let a font is abc.tff and when open the font the Name at top is "Arial", so i need the name Arial.
I have found method for pure windows 8/7 desktop applications not for UWP.
There is no way that I've found to extract the metadata from a font in order to find the name.
What you could do is create an observable collection that lists the data yourself... not ideal, but realistic.
Add(new Font("ABeeZee", "/Fonts/ABeeZee-regular.ttf#ABeeZee", "Sans Serif")
Then when you call the font, you can grab the data from your collection.
Related
I am very tired of providing fonts for my application. It would be a lot easier to have some ready-to-use fonts collection that I can use.
See this
//I need to add text to image, no matter what font is
var fo = SystemFonts.Find("Mono");
var font = new Font(fo, 10f, FontStyle.Regular);
x.DrawText("123", font,color,point);
I need to be sure that computer running this piece of code have font Mono installed. But it is not always the case, so I had to keep font file in my project folder and so on...
This is just annoying.
What I want to do
//this must be a font that included into library itself.
var font = FontCollection.Any;
x.DrawText("123", font,color,point);
With this I can be sure that I will be able to print text on image no matter what system is.
I want to show some custom shapes through font icons in my UWP project. I have created my own .ttf file for custom shapes. But I don't know how to apply it programmatically.
TextBlock text = new TextBlock();
string font = "Assets/mycustomfont.webfont.ttf#MyCustomFont";
text.FontFamily= new Windows.UI.Xaml.Media.FontFamily(font);
this.grid1.Children.Add(text);
Anyone please help me on this.
The approach you are using is practically correct, but make sure to check the following:
The .ttf file must be included in the project and have Build Action set to Content in the Properties window
Start the path to the font with / to make sure it begins in root.
Ensure the # suffix actually matches the font metadata. A font viewer app like dp4 Font Viewer can help you with that. Use the Font Family name as the suffix.
I have written an article on my blog about using custom fonts in UWP so check it out to see if you haven't missed some of the steps there.
I want to make an application for auto finding font.
Therefore, I try to get a font and font size from PDF text with Acrobat SDK.
I examined samples and documents, but I could not find it.
CAcroPDDoc pdDoc = new AcroPDDocClass();
pdDoc.Open(filename);
Object jsObj = pdDoc.GetJSObject();
Type T = jsObj.GetType();
// no idea for getting font and font size...
My tools : Visual Studio, C#, Acrobat DC, Acrobat DC SDK
For example PDF text, font and font size on Acrobat DC
Best regards
Acrobat JavaScript and, therefore, the JSO doesn't have access to the properties of text in the page content. The best you're going to be able to do is infer the size from the bounding box height but that won't be accurate since the bbox includes the leading. You can't get the font name at all.
You can get that information if you create a plugin but that would require C++ which you don't have listed as an option in your question.
So I have a few custom cells using ViewCell in my app. Inside my ViewCell are Labels. I want the font size of those labels to be dependent on the text size of the device just like how the TextCell's text changes when you adjust the text size of your device.
Below image is using a built-in TextCell.
Below image is using a custom cell ViewCell
Im testing this in an iOS device and the text size is set to the smallest available. Whenever I change the device text size the cells using TextCells will just automatically changed. The labels inside the ViewCell doesn't change at all. Any suggestion pointing me to the right direction is very much appreciated.
Short answer
The TextCell uses the native UITableViewCell on iOS. This native view takes the device accessibility settings into account. When you use the Xamarin Forms Label, it does not. Xamarin Forms does not support iOS Dynamic Type (yet).
Explanation
The Forms Label uses the FontSizeConverter to set the actual font size. This font size defaults to the value -1 if you don't set any value yourself. The value -1 results in the use of NamedSize.Default (see the Font class).
When you take a look at the FontSizeConverter, if it can't parse the value as an absolute value, it will try to convert to a NamedSize value. In that case, it will use Device.GetNamedSize to get the actual size. This is done through the IPlatformServices interface, which converts these to absolute values (see the IOSPlatformServices).
There is also a FontExtensions class, that implements the same conversion from Named Size to an absolute value. Not very DRY at first sight, but there could be a good reason for this, that I'm not aware of.
Unfortunately, both the FontExtensions and the IOSPlatformServices don't take the accessibility options of iOS into account, but just return absolute values.
Possible solution
On iOS, you could use UIKit.UIApplication.SharedApplication.PreferredContentSizeCategory to get the current accessibility category. Based on this value, you could determine a scale for your fonts (use DynamicResource for the font sizes if you use them in XAML, so they can change at runtime).
Or take a look at SushiHangover's answer on a similar question.
See the preferredContentSizeCategory on the Apple Developer API reference.
I'm trying to define a custom font in a C# WinRT app. I can define a single-file font in XAML like so:
<Page.Resources>
<FontFamily x:Key="Cousine">/Fonts/Cousine-Regular.ttf#Cousine</FontFamily>
</Page.Resources>
But I have several other font files that I would like to be used where appropriate:
Cousine-Bold.ttf
Cousine-BoldItalic.ttf
Cousine-Italic.ttf
How do I define a font family that uses the different fonts for the different font weights/variants?
They should all be in the same ttf file and you reference them like:
/Fonts/Cousine-Regular.ttf#Cousine
/Fonts/Cousine-Regular.ttf#Cousine Bold
/Fonts/Cousine-Regular.ttf#Cousine Italic
/Fonts/Cousine-Regular.ttf#Cousine Bold Italic
I don't know if the last one is right. I came here looking for the answer to that question. It might be BoldItalic. Whatever it is, I believe you create that name when you create the ttf file so you would be able to figure it out.