This python script will help you to include any Fontastic or Icomoon fonts on your Android or IOS Cobalt App. See the How to use below.
- This script create a standard Android|IOS module architecture.
- Parse the .css given by Fontastic|Icomoon, extract icons name and associated glyphs and put them in the created package.
- Android: Create a basic AndroidManifest.xml, build.gradle with Cobalt dependency, and the corresponding java code according to the Cobalt framework in the package.
- IOS: Create a basic projet with a header and some generated .m code and fill them.
- Copy the font.ttf in the package's assets directory.
- The resulting module is generated in the ./Fonts-FontName-Android|IOS directory.
pip install tinycss
git clone https://github.com/Cobaltians-Fonts/FontToCobalt.git
python fontToCobalt.py --name fontname --arch android|ios styles.css yourfont.ttf
python fontToCobalt.py styles.css yourfont.ttf
python fontToCobalt.py --name myFontName styles.css yourfont.ttf
python fontToCobalt.py --name myFontName --arch ios styles.css yourfont.ttf
Note: the --name
param must match the font name as shown in your font book (Mac) or equivalent as in the screenshot below
In cobalt.conf:
Add this example code at the end of cobalt.conf
"fonts" : {
"fa": {
"ios": "FontsAwesome",
"android": "org.cobaltians.fonts.fontAwesome.FontAwesomeDrawable"
}
}
In Android Studio:
- Open your project
- Select File/New/ImportModule/
- Then select the generated font module 'Fonts-FontName-Android'
- Clic Finish
In Xcode:
- Open your project or workspace
- Drag and drop the generated 'Fonts-FontName-iOS' folder into your project navigator and check the "Copy items if needed" in the pop-up which appears
- Add a
Fonts provided by application
array in the .plist file of your application project with an item whose value is the filename of your font file.
Voila! You can now use native bars icon using the name of the icon:
"icon": "fa house-icon"