fa2svg
A small Python package that converts Font Awesome <i>/<span> tags into email‑friendly inline images. You can embed either raw SVG (to_inline_svg) or high‑density PNG (to_inline_png_img), preserving font‑size, color, aspect ratio, and baseline alignment. Includes a simple test script at tests/run_test.py to verify basic functionality.
Installation
pip install fa2svg
Or for local development:
git clone https://github.com/meena-erian/fa2svg.git
cd fa2svg
pip install -e .
Upload to PyPI
Ensure your .pypirc is configured, then:
# from project root
env/bin/python -m build
twine upload --config-file "./.pypirc" dist/*
Usage
from fa2svg.converter import to_inline_svg, to_inline_png_img
html = '''
<p>
Coffee time:
<i class="fas fa-mug-saucer" style="font-size:64px;color:#c60"></i>
and stars:
<span class="far fa-star" style="font-size:48px;color:gold"></span>
</p>
'''
# Embed as SVG data URI:
converted_svg = to_inline_svg(html)
# Embed as higher-resolution PNG data URI:
converted_png = to_inline_png_img(html)
print(converted_svg)
print(converted_png)
API
-
to_inline_svg(html: str) -> strFetches the correct FA SVG, inlines your
font-sizeandcolor, and outputs an<img>tag with a base64‑encoded SVG data URI, pluswidth,height, andvertical-alignCSS. -
to_inline_png_img(html: str) -> strSame as above but renders a PNG at higher pixel density (default 2×) for crisper images in clients with varying DPI.
Testing
A basic test harness is provided at tests/run_test.py:
python -m tests.run_test
Contributing
- Fork the repo
- Create a feature branch
- Commit & push your changes
- Open a Pull Request
Issues and PRs are very welcome!
Metadata
Release files for fa2svg 0.1.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fa2svg-0.1.10.tar.gz | 19.5 kB | Without provenance | Details for fa2svg-0.1.10.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fa2svg-0.1.10-py3-none-any.whl | Python 3 | none | any | Details for fa2svg-0.1.10-py3-none-any.whl |
Total release size: 36.5 kB
Release files / fa2svg-0.1.10.tar.gz
| Download URL | fa2svg-0.1.10.tar.gz |
|---|---|
| Size | 19.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e78bdbd27c6ce735d124f6e8d63b14d3bf6242a2aec55c4e0e71db3661ddaa1c
|
|
BLAKE2b-256 checksum How to use checksums |
395d03f5cf7e098e319652193fb62d819c02a55d98ef5af8a9468fb3f9104c93
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.10
|
Release files / fa2svg-0.1.10-py3-none-any.whl
| Download URL | fa2svg-0.1.10-py3-none-any.whl |
|---|---|
| Size | 17.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fb4e919f449a0036f637cc4b67a759092723adf25d569bc28816e64a9bbcac7e
|
|
BLAKE2b-256 checksum How to use checksums |
e706e785344fbdbd3c597527b733840336c910c92f2215a7c350d9f92ba1c896
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.8.10
|
Security for fa2svg 0.1.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.