Trying to install custom font in xcode 4.2, iOS 5.0, but receiving error "Validation failed: [duplicate] - ios4

I want to use font "MgOpen Modata" in my iphone App. But I dont see it in the font list in Property inspector.
How do I include that font so that I can use it?

Add the font files to your resource files
Edit your Info.plist: Add a new entry with the key Fonts provided by application.
For each of your files, add the file name to this array
On the example below, I've added the font "DejaVu Sans Mono":
In your application you can the use [UIFont fontWithName:#"DejaVuSansMono-Bold" size:14.f].
Or if you want to use it in html/css, just use font-family:DejaVu Sans Mono;
Note: this is available in iOS 3.2 and later.

I found this walkthrough was the best
Although the above accepted answer does work I found that if you added text into an XIB file and then set the font to our new font then the text didn't update.
Making sure the new font is included in resources fixed this problem (taken directly from walkthrough):
"This should not be a problem but sometimes when you’re having trouble getting your font face to show up, this can be a source of headache so let’s double check now to rule it out as a potential pitfall.
Go to your project Build Phases pane by highlighting the XCode project file in your solution explorer and on the right hand side, select “Build Phases”. You’ll see that one of the sections you can expand is “Copy Bundle Resources”. Open that list and make sure that your fonts are included in that list."
The other stuff in the walkthrough is the same kind of stuff (add the file to your project and to the plist file too)
All credit to Code with Chris for this answer which saved me a lot of time and effort and I am merely copying a shot from his page to allow this answer to stand on its own feet instead of requiring you to click the link.

I think is better for a dev to have the plist structure as raw source code. I'm leaving it for copy/paste:
<key>UIAppFonts</key>
<array>
<string>Roboto-BoldItalic.ttf</string>
<string>Roboto-Medium.ttf</string>
<string>Roboto-MediumItalic.ttf</string>
<string>Roboto-Regular.ttf</string>
<string>Roboto-Bold.ttf</string>
</array>
Copy this snippet and modify the strings keys into the array to your desired fonts. Hint: To view the plist as raw source code please click secondary button over the file and select Open As -> Source code.
EDIT
// Logs fonts ordered by name
for (NSString* family in [[UIFont familyNames] sortedArrayUsingSelector:#selector(compare:)])
{
NSLog(#"%#", family);
for (NSString* name in [[UIFont fontNamesForFamilyName:family] sortedArrayUsingSelector:#selector(compare:)])
{
NSLog(#" %#", name);
}
}
After adding the fonts could be useful to add to (for example) the AppDelegate.m class to see what are the real fonts names (on the bundle). A problem I encountered various times that I was loading the fonts with a wrong name assuming that the font filename as the correct one. Sometimes it differs from the bundle real name.
In addition to this you can check the file full name using the file info window (cmd+i) on finder (macOS).
Example to clarify:
File Name = "DroidSansEthiopic-Regular"
Processed Name in bundle = "Droid Sans Ethiopic"

Don't forget to add the fonts to the targets compile bundle resources by going to 'Targets' -> 'Build Phases' -> 'Copy Bundle Resources' and add all the fonts manually

Most of the time we forget to add font to the application Target. Make sure you did not forget this important step. Mind checking right panel File Inspector > Target Membership checkbox.
Also you can check wether font is added well to your application or not by running this code snippet in anywhere on your app.
for (NSString* family in [UIFont familyNames])
{
NSLog(#"%#", family);
for (NSString* name in [UIFont fontNamesForFamilyName: family])
{
NSLog(#" %#", name);
}
}
EDIT
ALPHABETIC ORDER:
for (NSString* family in [[UIFont familyNames] sortedArrayUsingSelector:#selector(compare:)])
{
NSLog(#"%#", family);
for (NSString* name in [[UIFont fontNamesForFamilyName:family] sortedArrayUsingSelector:#selector(compare:)])
{
NSLog(#" %#", name);
}
}
This will populate a list of available fonts in your app, where your added font will also appear.

Its Easy and simple now- Tested in Xcode 9.2 and swift 4
Steps to add font to your Xcode
Select your UILabel, UITextField or whatever then under fonts section and follow
Step 1
Select settings menu from left corner of font selection screen. And choose font manager option.
Step 2
Click on the add button as marked below.
Step 3
Select the folder that contains your font. It will be loaded into XCode fonts list.
Steps to add fonts to your project
Don't forget to add description to your plist with the key Fonts provided by application. and put font files inside copy bundle resources under project target settings.
Yes! thats it.. njoy..

You can use [UIFont fontWithName:#"ArialMT" size:14]; method directly, if you want to change your font style. Also all the fonts may not be available in iphone library.Just refer this for available font styles.

If you have .otf format. sometime this format doesnt work. Convert .otf format to .ttf. There are bunch of font converter online.
Once you add the custom font to your .plist file under Fonts provided by application as explained above. Make sure in your Project Target under Build Phase -> copy Bundel Resourse that file is present. If not then add it.
Then just in your code add this [UIFont fontWithName:#"your custom font" size:your choice of size];

In Xamarin iOS
Step 1:
First of all you have to add your .ttf or .otf file into your Project.
like Roboto-BoldItalic.ttf .
Step 2 :
Right click on the Font and select property
Build Action --> Content
Copy to output directory --> Always Copy
Step 3:
go to info.plist
select property Fonts provided by application and add the font name.
Step 4:
set Font programatically below way
account.Font = UIFont.FromName("Roboto-BoldItalic", 18f);

Related

New to Android development. Why is my custom typeface font not showing up in the Type folder?

I'm pretty new to Android development (especially Jetpack Compose), so I'm sure I'm forgetting something stupidly easy!
I downloaded the custom Montserrat regular and bold fonts from Google (as .ttf files), created a font directory in my resources folder, renamed the fonts to follow naming conventions, dragged the fonts into the font directory, then tried to initialize them in the Type.kt file as a variable named Montserrat. I get an unresolved reference error and the Lint suggestion creates an XML file in the font directory. I have used custom fonts from Google many times before and followed the exact steps, but something is clearly not working!
I'd love to post screenshots, but I do not have enough reputation, unfortunately.
Any help is extremely appreciated!
Followed basic instructions to use custom fonts, and it is not initializing in the Type.kt folder.
If you're using Jetpack Compose to build your Android app, you can specify custom fonts in your app's typography object. You can then use the font property in the Text composable to apply the font to your text. Here's an example
#Composable
fun MyApp() {
val customFont = font(R.font.montserrat)
Typography(
h1 = TextStyle(
font = customFont,
fontSize = 24.sp
)
)
// ...
}
You can then use this style in your app like this
#Composable
fun MyScreen() {
Text("My headline", style = Typography.h1)
}

How to Embed text file in Adobe Flash for Adobe Air application

I've been searching for several days now a way to embed a data file, which is in text format, inside an app I'm trying to build in Adobe Flash for Adobe Air (for Android for now). The text file has a lot of data I want to use in my app, so I want to embed it inside the app, so when the app launches I can use it.
I've been reading about how to read and write text file in Flash and Adobe Air, but couldn't find a way to add this file to be part of my app. The Adobe Flash Library that is used for saving various assert (File > Import > Import to Library), doesn't support text file (only image, sound, video, and other graphic formats). Is there an other way to add a different (i.e. Text) file to the app?
As a last resort, and to help me proceed with the implementation, I tried manually copying the file to the Android "Documents" folder, and reading it from the app using this:
var myFile:File = File.documentsDirectory.resolvePath("MyText.txt");
var fileStream:FileStream = new FileStream();
fileStream.open(myFile, FileMode.READ);
var fileContents:String = fileStream.readUTFBytes(fileStream.bytesAvailable);
This worked on the PC when testing, but on Android it couldn't find my text file. I placed it in "My Files > Internal storage > Documents" (on Samsung phone). Is there a different "Documents" folder I should use to be found by documentsDirectory.resolvePath() function...
Anyway, as said, this was last resort solution, and much less preferred, because I don't want the users of my app to need to copy internal data files for the app to work, it should be part of the APK... So embedding the text file somehow inside the app is a much better solution, but I couldn't find a way to do that.
Thanks Organis for your answer, I didn't yet try it but I guess it should work.
I found another answer few hours ago, and will share it now, in case someone else encounters this problem.
You could embed a file from the "Publish Settings" dialog, then going into "AIR for Android Setting" (small wrench icon). On the "AIR for Android Setting" under "General" tab, at the bottom there is "Include files". You can click the [+] icon and add any file you want.
From the code you can access this file using standard file read method, using URLLoader & URLRequest functions and Event.COMPLETE to get the data when the file finishes loading.
see screenshot here

UIImagePickerController to set a background image, not working

I am writing an iPhone app, where the user should be able to choose, an in-app background picture from his own photo album.
I am trying to enable this feature using a UIImagePickerController.
At this point I get the the box asking me to choose a picture and I save the picture.
But after that, when I want to use the image chosen as background, with this kind of code (which is the same as how I set the default background at start):
UIColor *backGrndPict=[[UIColor alloc] initWithPatternImage:
[UIImage imageNamed:pngPath]];
self.view.backgroundColor=backGrndPict;
Nothing works. I just get a white background.
Thanks for any tip.
Michel,
Just for clarification, are you saving the picture that the user selects as a .png file or in an UIImage?
If you did use the UIImage method, try double checking the retain count of the UIImage. Again, it may not be as simple as this, but that is what I did with my app and was getting the exact same issue.
If you did save it as a .png file, did you do an error check? Also, I have the "Applications" folder for my iOS simulator loaded on the screen perchance I have to verify both the availability and the integrity of the file in question.
Also, I tend to slip on the path sometimes too. I have have messed up the path one too many times by forgetting to use the saved path (the file that my app saved, almost always under the documents folder) vs. the default bundle path for the app which is where the bundled images are saved.
Hope it helps.

silverstripe - adding styles to 'styles' drop down menu on editor

from the question above, I thought it would be relatively easy but i can not find any documentation on on how to add styles to the 'styles' drop down menu. can anyone push me in the right direction?
The styles dropdown is automatically populated based on classes found in your theme's typography.css file. To add classes, just ensure that they are defined there. Alternatively, if you want to give the classes friendlier names or to remove some classes from the list, you can explicitly define the styles that you want listed by putting this in your _config.php file.
HtmlEditorConfig::get('cms')->setOption('theme_advanced_styles',
'Name 1=class1;Name 2=class2');
It's a feature provided by TinyMCE, the WYSIWYG editor component, and this line is just setting the theme_advanced_styles setting of TinyMCE when used by the CMS. This thread on the TinyMCE site also discusses it.
Also note Markus' answer below: editor.css needs to be in the theme css folder and include the typography.css.
The answer of #Sam Minnée only works, if the editor.css is also in the theme css folder and includes the typography.css.
Here is a more detailed description of how these two play together.
If you have troubles getting the new styles appear in the editor, try the following:
yoursite.com/admin/?flush=1
Check the file permissions on your mythemes/css/editor.css file. It should be readable by the webserver user.

Expression Blend's default LayoutRoot

Is there a way to change the default LayoutRoot type in Expression Blend 3? Currently, I'm prototyping in SketchFlow, and I prefer Canvas over the Grid, and it's annoying to change it for every new screen.
Here is answer that will work, but you will need to change the templates:
Back up the contents of the template directory which resides here:
%ProgramFiles%\Microsoft Expression\Blend 3\Templates\
Find the templates being used in:
%ProgramFiles%\Microsoft Expression\Blend 3\Templates\(CSharp|VisualBasic)\
In that directory there will be 4 relevant templates:
SketchFlowCompScreen,
SketchFlowCompScreenSL,
SketchFlowNavScreen,
SketchFlowNavScreenSL
If you edit the xaml files within these, whenever you create a new screen in SketchFlow the screens will use your changes.

Resources