I have two fonts with the same name (the two fonts have different ascender properties). How can I include both fonts in my project and use them? I am unable to figure out how to change the name of one of the fonts without installing Font Forge, which seems like a day long project. Any ideas?
Related
I'm using Mapbox iOS SDK 6.2.0-beta.2 and it doesn't load the custom fonts we serve on our tile server. In order to expedite our iOS 14 preparation I'm trying to make Mapbox use locally available fonts, but I can't find a good example. The docs are a bit vague to me. Can you help me make Mapbox use local fonts instead of the fonts specified in the style JSON?
According to Mapbox docs on Customizing Fonts:
If the symbol layer does not specify an available font that contains the required glyphs, then the map tries to find a matching font in the MGLIdeographicFontFamilyName Info.plist key.
From Mapbox references on MGLIdeographicFontFamilyName:
This key specifies a fallback for all style layers in all map views and map snapshots.
This key can either be set to a single string or an array of strings, which the map tries to apply in order from most preferred to least preferred. Each string can be a family name (for example, “PingFang TC”), display name (“PingFang TC Ultralight”), or PostScript name (“PingFangTC-Ultralight”).
So if you need to use a locally bundled font for your map style, put a string (or array of strings in order of preference) of your locally embedded font name, family or PostScript name in MGLIdeographicFontFamilyName in your project's Info.plist file.
I use a third-party SDK in my iOS app which requires me to define the fonts I wish to use in a pre-defined .plist file. I have been using Lato-Regular all throughout the app but it seems I cannot use the same in a property list file for some reason. Is there any to achieve this?
P.S. I have checked and rechecked for the name of the font so that's not the problem.
I am wanting to use Helvetica Neue Ultra Light in my Watchkit app. I have followed all of the instructions for adding a custom font (added to Extension bundle and added in Info.plist for Extension and Watchkit app), but NOTHING is working and it will never get used.
Really strange thing is, other ttf fonts that I have added DO work, it seems to just be some strange issue with Helvetica.
Where is Helvetica, and why can't I add it?
Edit: To clear things up and prevent what people think might be obvious answers.
Watchkit only includes the system font (San Francisco), it doesn't
expose all of the fonts that iOS has. (Ref:
devforums.apple.com/message/1096179#1096179) THIS is why I am trying
to include Helvetica.
Option 1
I had the same issue. I fixed it by including the - character between the font name and the name of its weight. In some ways, Xcode could recognize the font.
Try changing HelveticaNeueUltraLight.ttf into HelveticaNeue-UltraLight.ttf wherever possible (info.plist file and in the project folder).
Option 2
Open up the FontBook that comes included within your Mac. Install the font if you haven't already and look closely at the PostScript name of the font. If it differs from the name you are currently using in Xcode, then change it.
Option 3
If you can't still get this working, download the same font from another source.
This is a topic that looks like many others have struggled with. I'm trying to add the 'Impact' font to my iOS project. To do so, I perform the following steps:
1. Add the Impact.ttf file to my project.
2. Ensure that the Impact.ttf file is in fact added to the project Target.
3. Check 'Copy Bundle with Resources' in the target Build Phases and make sure the Impact.ttf file is included .
4. In My-Project-Name-Info.plist, I added the "Fonts provided by application" option and set Impact.ttf as item 0 in the array.
5. Open the font file with Font Book and make sure I'm referencing the font by the correct name. In this case, Impact is the correct name.
I used the following code snipped to see all available fonts in the project, and 'Impact' is not one of them:
for (NSString *family in [UIFont familyNames]) {
NSLog(#"%#", family);
for (NSString *name in [UIFont fontNamesForFamilyName:family]) {
NSLog(#" %#", name);
}
}
When inspecting the value of UIFont in the following snippet, I get nil.
UIFont *impactFont = [UIFont fontWithName:#"Impact" size:36.0f];
I've quadruple checked all spellings and gone through each step multiple times. I've also used the following resources (and many more) to troubleshoot the problem.
Custom font in iOS not working
iOS custom font robot bold not working
Common mistakes with adding custom fonts to your iOS app
One item to note: If I open Impact.ttf with font book, it says that the font is not installed. I click to install the font, and get a warning that there are duplicate Impact fonts installed. To fix this warning, I click 'Resolve duplicates automatically' and the font shows as installed. However, if I open the file again, the font shows as not installed. I'm not sure if having the font installed in Font Book is necessary for it to correctly be recognized in my project .
Thank you very much for your help! I know this question has been asked multiple times, but I feel like I've exhausted all resources and links here on SO and other sites.
Maybe this is not the answer you want, but is a solution you could use to move on.
That is what i use on my projects, simple and useful https://github.com/deni2s/IBCustomFonts
Hope you can find a better solution!
There are some font files in my code repo for the font Nubian and Nubian-Alt. They are licensed and paid for and they need to be used. However I cannot use this font in iOS, and I cannot open the font with Font Book even though the font previews OK in Finder and is identified as a Truetype Font.
I started by trying to add Nubian-Medium to the iOS app - using the key "Fonts provided by application" in the app's Info.plist. The font did not appear in the list generated using:
for (NSString *familyName in [UIFont familyNames]) {
for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) {
NSLog(#"%#", fontName);
}
}
I checked the Target's "Copy Bundle Resources" Build Phase, saw the font had been added to the list.
I tried adding another font I have used in another app, "chess-merida-unicode.ttf", to check I was adding a font correctly - I copied it to the app and added it to the array of fonts provided by application, saw it appear in the "Copy Bundle Resources" list, it was reported as available using the above code snippet.
Next I took a look at the font in OS X - double-clicking does open Font Book but the font is not opened or added. When I tried to drag all the Nubian fonts into Font Book as a new collection it reported problems with all the files, specifically in tables contained within the font file.
Selecting all fonts and then choosing proceed did nothing.
I downloaded a trial of a third-party app named Font Agent Pro and it also could not load these fonts.
I found a sketchy site called fonts.com and downloaded another Nubian-Medium ("ufonts.com_nubian-medium_1_.ttf") - Xcode was able to recognise that file.
I checked the permissions on these files and made sure they were rw for all, no change.
At this point you would suspect the files are just broken or corrupted but they are in use on a web page (that is also part of the project) and that works fine. What other steps could I take? What can I do to get these files added to the iOS project? If there are certain kinds of TTF that cannot be used in an iOS project, how can I check whether these are that kind?
Step 1: Download Nubian Font From : http://www.fontpalace.com/font-download/Nubian-Thin/
Step 2: Add Font .ttf File in your project
Step 3: Register your Font With Application, set Fonts provided by application key in your info.plist file, See the ScreenShot for details.
Step 4: Create a Label and Assign the font to it ,as following
UILabel *lbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 50)];
[lbl setText:#"I am Nubian-Thin"];
[lbl setFont:[UIFont fontWithName:#"Nubian-Thin" size:26.0f]];
[self.view addSubview:lbl];
The answer seems to be that these fonts were "web" fonts. I don't know how to tell the difference, given a TTF file that looks just like a "desktop" font. Learning how to do this was kind of the aim of the question.
Practically speaking, digging out an old archive from someone's hard drive discovered another archive with TTF fonts that worked. These fonts still had 8.3 filenames and were all created as members of their own font family (so Nubian-Medium and Nubian-MediumItalic were in no way related). I renamed them, then ran them through the trial of RoboFonts to correct the family relationship. This resulted in TTFs all in the Nubian family. And then found a weird issue where a UILabel created with this font came with a 1-pixel horizontal rule at the top of the frame. Going through the process again but choosing to generate OTF output got rid of the line.
Fonts are easy, except when they aren't, then they are really hard.