Skip to main content

Python script (and library) for exporting icons from icon fonts (e.g. Font Awesome, Octicons) as PNG images.

Project description

Build Status PyPI Version PyPI Downloads Python Versions License

Python script (and library) for easy and simple export of icons from web icon fonts (e.g. Font Awesome, Octicons) as PNG images. The best part is the provided shell script, but you can also use it’s functionality directly in your (probably awesome) Python project.

There’s also font-awesome-to-png script for backwards compatibility with the first iteration of the concept.

Package is considered to be in beta status and no backwards compatibility (if you use it inside your project) between versions is guaranteed.

Packages required for running and testing are listed in requirements directory.

Installation

Make sure you have required packages for Pillow installation.

With pip (recommended):

$ pip install icon_font_to_png

Without pip:

$ git clone https://github.com/Pythonity/icon-font-to-png
$ pip install -r icon-font-to-png/requirements.txt
$ cd icon-font-to-png/bin

OS X

As reported here, to install it on OS X:

$ pip install icon_font_to_png --ignore-installed six

Usage

usage: icon-font-to-png [-h] [--list] [--download {font-awesome,octicons}]
                        [--ttf TTF-FILE] [--css CSS-FILE] [--size SIZE]
                        [--scale SCALE] [--color COLOR] [--filename FILENAME]
                        [--keep_prefix]
                        [icons [icons ...]]

Exports font icons as PNG images.

optional arguments:
  -h, --help            show this help message and exit
  --list                list all available icon names and exit
  --download {font-awesome,octicons}
                        download latest icon font and exit

required arguments:
  --ttf TTF-FILE        path to TTF file
  --css CSS-FILE        path to CSS file

exporting icons:
  icons                 names of the icons to export (or 'ALL' for all icons)
  --size SIZE           icon size in pixels (default: 16)
  --scale SCALE         scaling factor between 0 and 1, or 'auto' for
                        automatic scaling (default: auto); be careful, as
                        setting it may lead to icons being cropped
  --color COLOR         color name or hex value (default: black)
  --filename FILENAME   name of the output file (without '.png' extension);
                        it's used as a prefix if multiple icons are exported
  --keep_prefix         do not remove common icon prefix (i.e. 'fa-arrow-
                        right' instead of 'arrow-right')

Examples

Download latest Font Awesome:
$ icon-font-to-png --download font-awesome
List all available icons:
$ icon-font-to-png --css font-awesome.css --ttf fontawesome-webfont.ttf --list
Export ‘play’ and ‘stop’ icons, size 64x64:
$ icon-font-to-png --css font-awesome.css --ttf fontawesome-webfont.ttf --size 64 play stop
Export all icons in blue:
$ icon-font-to-png --css font-awesome.css --ttf fontawesome-webfont.ttf --color blue ALL

Export all icons in blue, but using it’s hex value: $ icon-font-to-png --css font-awesome.css --ttf fontawesome-webfont.ttf --color blue '#0000ff' ALL

Or you can use font-awesome-to-png, without css and ttf arguments:
$ font-awesome-to-png ALL

API

You can use IconFont (and IconFontDownloader for that matter) directly inside your Python project. There’s no documentation as of now, but the code is commented and should be pretty straightforward to use.

But feel free to ask me if anything is unclear.

Tests

Package was tested with tox on Python 2.7 and Python 3.4 (see tox.ini).

To run tests yourself, just run tox inside repository.

Contributions

Package source code is available at GitHub.

Feel free to use, ask, fork, star, report bugs, fix them, suggest enhancements and point out any mistakes.

Authors

Developed and maintained by Pythonity.

Original version by Michał Wojciechowski, refactored by Paweł Adamczak.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

icon_font_to_png-0.3.4.tar.gz (121.3 kB view details)

Uploaded Source

Built Distribution

icon_font_to_png-0.3.4-py2.py3-none-any.whl (13.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file icon_font_to_png-0.3.4.tar.gz.

File metadata

File hashes

Hashes for icon_font_to_png-0.3.4.tar.gz
Algorithm Hash digest
SHA256 ca301295689d956b85d9cb64f4e6cc6800b3921277134a2c421d96c2c63912f9
MD5 6bb5e1b5a5f97638a11833a5ba6c5b9e
BLAKE2b-256 7d539a63021968ce6a6fb9fb35d68aae6b25aaf7b69aef445df212e1dc99780f

See more details on using hashes here.

File details

Details for the file icon_font_to_png-0.3.4-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for icon_font_to_png-0.3.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 4169997648ba87001f1bc1689b5ae6981a3f243d103117bbd269c47333804470
MD5 69145f243187aed6f31483a1ae5ba71d
BLAKE2b-256 fce0d5594f2a2449851061f95ab1e53a391c8c5ec71d2933c5a016babb598c67

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page