How can I add custom fonts to ios 8 Keyboard extenstion like this.Can anyone have a tutorial or example from which I can refer.Like this example https://itunes.apple.com/us/app/fontkeyboard-for-ios-8-use/id914787397?mt=8
1.In the above link they have the special characters as letters, Please refer below URL
http://fsymbols.com/letters/
2.In Your Extension,You have to maintain the two arrays one is with regular letter (A,B,C,D….)to show on your Keyboard
3.Second one is the Special character that you want to display in your target E.g..,(Ⓐ,Ⓑ,Ⓒ,Ⓓ..) (⒜,⒝,⒞,⒟….)
4.Use can directly copy the special characters from the above reference URL,and then you return the value of selected letter
5.If you want to give an options like the referred app,you need to maintain the array of those letters and return the value that you wanted to display for that selected letter.
Here is the keyboard button action,the insertText method used to insert your text to the target.
Please find my blog on how to creating third-party keyboards :Here's a link
Please find my sample project on github : Simple Custom Keyboard Sample
This is an old question but incase new people need the answer I will add mine. Gagan's answer (above) is quite elaborate and +1 for the github code; however, to my understanding the question is how to add font to custom keyboard, which could mean more than adding special characters to the keyboard keys (Gagan's answer), for example adding letters of languages not supported by apple.
In any case, to add a custom font to iOS keyboard extension, do the following steps:
Step 1. Drag/Add your ttf font to the Keyboard extension folder
(NOT to the host app) of your project in xcode.
Step 2. While importing make sure to check "Copy items if needed" and finish.
Step 3. Select Info.plist under Supporting Files section of the Keyboard extension folder
Step 4. At the end of the list add a string array
called "Fonts provided by the Application" xcode will autocomplete it
for you.
Step 5. Extend the newly added array and add the name of your
font/fonts eg. "Example.ttf"
Step 6. Now to make sure the font is copied to the final binary app, go to project properties and in the Targets section select the keyboard extension, then in the "Build Phases" tab and the "Copy Bundle Resources" subsection add/link the custom font.
That should get you a custom font in your keyboard extension!
Notice that in the steps the Keyboard extension is mentioned repeatedly on purpose, because thats the catching point when adding custom font to the extension compared to adding font to normal applications and it should not be confused with host app of the extension. iOS Custom Keyboard project in xcode usually comprises a host app which is pretty much a normal iOS app and the actual keyboard extension, both are displayed as folders in the Project Navigator.
If the custom font is needed to be used in the host app, then the steps are similar, only then make sure the destination is the host app folder and once again select the host app Target in the project properties when adding to the Bundle resources.
Related
I had a SwiftUI project that I essentially messed up pretty bad and had to make a new project and transfer all the files over. It's working as intended except for my custom fonts aren't working and the default font is taking over. Here is what I did:
Copied my fonts folder into my new project
Checked the Target Membership box for my project and made sure that the path to the directory was referring to the new path, not the old path (bc it was before I changed it).
Included the names of both fonts in my plist, exactly how they were in the initial project's plist, in the fonts provided by application array.
Deleted and readded the fonts folder in my project's Build Phases (again, to make sure it was referring to the correct directory).
And yeah, still not working. Any insight as to what I could be overlooking? Because it was working completely as intended before I had to create the new project, and all other elements are working as intended.
If you are struggling with this in 2022 and using SwiftUI where there seems to be no info.plist in sight, then in addition to adding the Fonts capability in Target Signing and Capabilities, then dragging the file into your project and don't forget to check Add to Targets, and finally add your InsertFontFileName.ttf to "Fonts provided by application" which is now in your Info tab on the Target as seen in the image below. Also, call me crazy but before you drag the font in remove any special characters. In addition, don't be fooled by the auto-generated info.plist, add your new fonts via the image below, it'll auto-populate to that other plist. Maybe some of my steps are superstitious, but I spent enough time futzing around with fonts that I'm done thinking about it and I'll just follow my formula... and if that font doesn't work, it wasn't meant to be and I'll move onto the next font!
After that
.font(Font.custom("InsertFontFileName", size: 32, relativeTo: .title))
Although it looks like you have already done this, just go through the following checklist once:
Fonts (.ttf files) are present inside the project
Entry in info.plist file
Entry in "Copy Bundle Resources" under "Build Settings" of your target
If this is missing, add by clicking on the plus (+) icon in this section
Make sure you are using the font correctly (check spelling errors?)
var FontRegular : Font = Font.custom("Poppins-Regular", size: 16)
var FontBold : Font = Font.custom("Poppins-Bold", size: 16)
...
Text("Sample Text")
.font(FontRegular)
I followed a bunch of tutorials but it doesn’t work: I simply want to add a custom font to a macOS app.
What I tried essentially:
Added the .ttf font-files to my project: Target Membership is set and I also made sure that the files are copied using Copy Files within Bundle Phases. After compiling I can see that all files are within the Bundle. So that seems to work perfectly fine.
Info.plist: I added Fonts provided by application and created an item for every font-file I want to add (values like myFont.tff).
I made sure that I use the correct font name. I installed the fonts on my system and configured a Label with Interface Builder so that it uses the desired font. I printed it’s value print(myLabel.font.fontName).
Confusing: If the exactly same font-file I want to add to the app is installed in the systems Fontbook and activated, everything works well. When I deactivate it, it doesn’t work. For me that indicates that I am using the correct font name.
I found ATSApplicationFontsPath and tried to add it to the Info.plist, but neither using a path (recommended by the docs) or values like . (which seemed to work for some people out there) worked out.
Appreciate any help!
I had a hard time getting this to work based on the previous answers, so I decided to write up an answer myself. This is based on previous answers by #ixany and #rob-keniger.
Create a folder named Fonts
Add fonts to the Fonts folder. Uncheck Add to targets and check Copy items if needed.
Add Application fonts resource path to Info.plist and enter Fonts.
Go to Build Phases and create a New Copy Files Phase.
Set the Destinations to Resources and Subpath to Fonts. Then add your font files to the list.
I solved my problem by accident.
I noticed that within the Bundle files, my fonts were included twice: They were copied to the "Resources" directory as well as to the subpath I declared in the "Copy Files" Build Phases.
I removed the fonts from my project, added them again (without checking the "Target Membership") and added them in the Build Phases so they were copied just to the subpath. After that it worked.
Additional notes:
Turned out that Fonts provided by application is a iOS only property so it is not needed for an macOS implementation.
Also, ATSApplicationFontsPath does not need any slashes. For example: Fonts should work just fine.
I had a difficult time finding the correct names for .ttf font files and sometimes discovered some strange behaviour: NSFont picked randomly fonts (regular, medium, bold...) from a font family without any code changes. By using .otf files instead I could solve that too.
None of the above worked for me in Xcode 12 beta 1 running BigSur but these steps did.
Create a Fonts folder for organization.
Add your fonts to the project. Be sure to check the macOS target!
Set Application fonts resource path to "." (no quotes).
No need to edit build phases or anything else.
THe value ATSApplicationFontsPath (i.e. Application fonts resource path) is relative to the Resources folder of your app bundle.
To see where your fonts are copied to:
In Xcode, expand the Products section under Project Navigator and click Show in Finder
In Finder, Ctrl-click on your app and click Show Resource Contents. Browse to the Resources folder and find your fonts there.
Xcode 12 to add custom fonts you have to exclude extension name from the string provided.
i.e.
.font(.custom("your font name", size:xx)) // works every time
.font(.custom("your font name.extension",size:xx)) // always fails
same is not true with Xcode 11.xx there fontname.extension is working.
I want to localize my app, and I add French and Spanish to the target properties other than English
But, those languages are not showing inside the file inspector to select. Only 'English' and Something called 'Base'.
Any Help?
If you go to the "Info" pane of your project, you'll see a panel that shows your Deployment Target, Configurations and also the current localizations that you support (including a checkmark for "Use Base Internationalization"). Base Internationalization, b.t.w., allows you to have a single storyboard file that has different string files populating the string fields in the storyboard. It works for iOS 6 and newer.
When you start, it might look like this:
Here I've added Hindi as a language possibility:
And when you're done, you have the checkbox to choose from:
You need to add in your Info Project the localizations (I can't add image sorry).
And next you need to create a new file in your project named "Localizable.strings" and Localize this file in your identity menu.
++
Just click on your project in "Info" panel , where you can see "Localizations" and add the languages you want.
My app is currently localized for English and Japanese, with seperate storyboards for each. I want to switch to base localization so that I only have to maintain a single storyboard. I've checked the "Use Base Internationalization" box in the project's info tab and chosen the English iPhone and iPad storyboards for the base.
I assume I should delete the Japanese iPhone and iPad storyboards I had previously used, but I don't see an option to delete them when right-clicking on their files in the file inspector. Should I delete these old storyboards, and, if so, how?
** Edit **
Changing the 'Main Interface' shown in the screenshot doesn't allow me to delete the Japanese storyboard. It's hard to tell which storyboard to select in the dropdown because its width is more narrow than the storyboard names, but that's a separate issue.
This tutorial drives you through the process step-by-step. This is how it worked for me:
Remove all localizations and leave only the base.
Ensure that the localized files were moved from the project directory (in Finder)
Add the localizations one-by-one
The localized strings are extracted from the storyboard only when the localization is created. The Tutorial above provides a script that can help you keeping the localized files up to date if the storyboard is changed.
In your case, you will have to merge the existing translations into the new files but I suppose it is not a huge deal compared to the gain with using a single file.
For reference, the process is described in this official tutorial too: http://developer.apple.com/library/ios/referencelibrary/GettingStarted/RoadMapiOS/chapters/InternationalizeYourApp/InternationalizeYourApp/InternationalizeYourApp.html
After cleaning and reloading, I was able to remove the Japanese storyboards by clicking on the - in the project settings:
I'm having trouble adding multiple icon files to my application's info.plist file. I've read the docs on Apple's site, and I've read many of the articles here on StackOverflow, but something isn't quite right.
When I open my info.plist file and click the "+" button next to the entry for "Icon File", I make an attempt to add an entry for "Icon files" (notice the added "s"). This entry does not come up in the dropdown list, however. And when I switch the view to "Show Raw Keys/Values", only the CFBundleIconFile shows up. The necessary CFBundleIconFiles (again, notice the "s") does not show up in my dropdown list.
Is there a setting in XCode I need to set to get these new values to show up? I'm running 3.2.6 with SDK 4.3.
Thanks!
If I follow correctly, you're having issues with enabling multiple icon files and their respective resolutions? Apart from setting the main one inside your .plist (as you're using XC3, whereas XC4's interface allows for retina and non-retina selections built in) the others simply need to be in the same place as your main Icon.png file.
This might further help you:
iPhone icon size