bdfparser


Namebdfparser JSON
Version 2.2.0 PyPI version JSON
download
home_pagehttps://github.com/tomchen/bdfparser
SummaryBDF (Glyph Bitmap Distribution Format) Bitmap Font File Parser in Python
upload_time2021-02-06 21:30:50
maintainer
docs_urlNone
authorTom Chen
requires_python>=3.5
license
keywords bdf bitmap font parser
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # BDF Parser Python library

[![PyPI package](https://img.shields.io/badge/pip%20install-bdfparser-brightgreen)](https://pypi.org/project/bdfparser/) [![version number](https://img.shields.io/pypi/v/bdfparser?color=green&label=version)](https://github.com/tomchen/bdfparser/releases) [![Actions Status](https://github.com/tomchen/bdfparser/workflows/Test/badge.svg)](https://github.com/tomchen/bdfparser/actions) [![codecov](https://codecov.io/gh/tomchen/bdfparser/branch/master/graph/badge.svg?token=IMVVQEC04H)](https://codecov.io/gh/tomchen/bdfparser) [![License](https://img.shields.io/github/license/tomchen/bdfparser)](https://github.com/tomchen/bdfparser/blob/master/LICENSE)

BDF (Glyph Bitmap Distribution; [Wikipedia](https://en.wikipedia.org/wiki/Glyph_Bitmap_Distribution_Format); [Spec](https://font.tomchen.org/bdf_spec/)) format bitmap font file parser library in Python. It has [`Font`](https://font.tomchen.org/bdfparser_js/font), [`Glyph`](https://font.tomchen.org/bdfparser_js/glyph) and [`Bitmap`](https://font.tomchen.org/bdfparser_js/bitmap) classes providing more than 30 chainable API methods of parsing BDF fonts, getting their meta information, rendering text in any writing direction, adding special effects and manipulating bitmap images. It works seamlessly with [PIL / Pillow](https://pillow.readthedocs.io/en/stable/) and [NumPy](https://numpy.org/), and has detailed documentation / tutorials / API reference.

**BDF Parser TypeScript (JavaScript) library** ([documentation](https://font.tomchen.org/bdfparser_js/); [GitHub page](https://github.com/tomchen/bdfparser-js); [npm page](https://www.npmjs.com/package/bdfparser); `npm i bdfparser`) is a port of **BDF Parser Python library** ([documentation](https://font.tomchen.org/bdfparser_py/); [GitHub page](https://github.com/tomchen/bdfparser); [PyPI page](https://pypi.org/project/bdfparser/); `pip install bdfparser`). Both are written by [Tom Chen](https://github.com/tomchen/) and under the MIT License.

The BDF Parser TypeScript (JavaScript) library has a [**Live Demo & Editor**](https://font.tomchen.org/bdfparser_js/editor) you can try.

Below I'll show you some quick examples, but it is still strongly recommended you go to [**BDF Parser Python Library's official website to read the detailed documentation / tutorials / API reference**](https://font.tomchen.org/bdfparser_py/).

Install bdfparser Python library with [pip](https://pip.pypa.io/en/stable/installing/#do-i-need-to-install-pip):

```bash
pip install bdfparser
```

Then:

```python
from bdfparser import Font
font = Font('tests/fonts/unifont-13.0.04.bdf')
print(f"This font's global size is "
      f"{font.headers['fbbx']} x {font.headers['fbby']} (pixel), "
      f"it contains {len(font)} glyphs.")

# =================================

ac = font.glyph("a").draw().crop(6, 8, 1, 2).concat(
    font.glyph("c").draw().crop(6, 8, 1, 2)
    ).shadow()
ac_8x8 = ac * 8

from PIL import Image
im_ac = Image.frombytes('RGBA',
                        (ac_8x8.width(), ac_8x8.height()),
                        ac_8x8.tobytes('RGBA'))
im_ac.save("ac.png", "PNG")

# =================================

hello = font.draw('Hello!', direction='rl').glow()
print(hello)

import numpy
import matplotlib.pyplot as plt
nparr = numpy.array(hello.todata(2))
plt.imshow(nparr, 'Blues')
plt.show()

# =================================

font_preview = font.drawall()
im_ac = Image.frombytes('1',
                        (font_preview.width(), font_preview.height()),
                        font_preview.tobytes('1'))
im_ac.save("font_preview.png", "PNG")
```

You probably understand what I did in these examples. Whether you do or not, go to [**bdfparser's documentation website**](https://font.tomchen.org/bdfparser_py/).

<p align="center">
<a href="https://font.tomchen.org/bdfparser_py/">
<img src="https://font.tomchen.org/img/bdfparser_py/ac.png" /><br>
<img src="https://font.tomchen.org/img/bdfparser_py/plot.png" /><br>
<img src="https://font.tomchen.org/img/bdfparser_py/font_preview_part.png" />
</a>
<a href="https://font.tomchen.org/bdfparser_js/editor" title="BDF Parser Live Demo & Code Editor"><img src="https://font.tomchen.org/img/bdfparser_js/bdfparser_live_editor_demo.gif" width="700" alt="BDF Parser Live Demo & Code Editor"></a>
</p>



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/tomchen/bdfparser",
    "name": "bdfparser",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.5",
    "maintainer_email": "",
    "keywords": "bdf,bitmap,font,parser",
    "author": "Tom Chen",
    "author_email": "tomchen.org@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/e3/b7/8e2a9b806450254f1ae0d4e18e4d8612cf7561fb87a5a8395e369b3bf4b9/bdfparser-2.2.0.tar.gz",
    "platform": "",
    "description": "# BDF Parser Python library\n\n[![PyPI package](https://img.shields.io/badge/pip%20install-bdfparser-brightgreen)](https://pypi.org/project/bdfparser/) [![version number](https://img.shields.io/pypi/v/bdfparser?color=green&label=version)](https://github.com/tomchen/bdfparser/releases) [![Actions Status](https://github.com/tomchen/bdfparser/workflows/Test/badge.svg)](https://github.com/tomchen/bdfparser/actions) [![codecov](https://codecov.io/gh/tomchen/bdfparser/branch/master/graph/badge.svg?token=IMVVQEC04H)](https://codecov.io/gh/tomchen/bdfparser) [![License](https://img.shields.io/github/license/tomchen/bdfparser)](https://github.com/tomchen/bdfparser/blob/master/LICENSE)\n\nBDF (Glyph Bitmap Distribution; [Wikipedia](https://en.wikipedia.org/wiki/Glyph_Bitmap_Distribution_Format); [Spec](https://font.tomchen.org/bdf_spec/)) format bitmap font file parser library in Python. It has [`Font`](https://font.tomchen.org/bdfparser_js/font), [`Glyph`](https://font.tomchen.org/bdfparser_js/glyph) and [`Bitmap`](https://font.tomchen.org/bdfparser_js/bitmap) classes providing more than 30 chainable API methods of parsing BDF fonts, getting their meta information, rendering text in any writing direction, adding special effects and manipulating bitmap images. It works seamlessly with [PIL / Pillow](https://pillow.readthedocs.io/en/stable/) and [NumPy](https://numpy.org/), and has detailed documentation / tutorials / API reference.\n\n**BDF Parser TypeScript (JavaScript) library** ([documentation](https://font.tomchen.org/bdfparser_js/); [GitHub page](https://github.com/tomchen/bdfparser-js); [npm page](https://www.npmjs.com/package/bdfparser); `npm i bdfparser`) is a port of **BDF Parser Python library** ([documentation](https://font.tomchen.org/bdfparser_py/); [GitHub page](https://github.com/tomchen/bdfparser); [PyPI page](https://pypi.org/project/bdfparser/); `pip install bdfparser`). Both are written by [Tom Chen](https://github.com/tomchen/) and under the MIT License.\n\nThe BDF Parser TypeScript (JavaScript) library has a [**Live Demo & Editor**](https://font.tomchen.org/bdfparser_js/editor) you can try.\n\nBelow I'll show you some quick examples, but it is still strongly recommended you go to [**BDF Parser Python Library's official website to read the detailed documentation / tutorials / API reference**](https://font.tomchen.org/bdfparser_py/).\n\nInstall bdfparser Python library with [pip](https://pip.pypa.io/en/stable/installing/#do-i-need-to-install-pip):\n\n```bash\npip install bdfparser\n```\n\nThen:\n\n```python\nfrom bdfparser import Font\nfont = Font('tests/fonts/unifont-13.0.04.bdf')\nprint(f\"This font's global size is \"\n      f\"{font.headers['fbbx']} x {font.headers['fbby']} (pixel), \"\n      f\"it contains {len(font)} glyphs.\")\n\n# =================================\n\nac = font.glyph(\"a\").draw().crop(6, 8, 1, 2).concat(\n    font.glyph(\"c\").draw().crop(6, 8, 1, 2)\n    ).shadow()\nac_8x8 = ac * 8\n\nfrom PIL import Image\nim_ac = Image.frombytes('RGBA',\n                        (ac_8x8.width(), ac_8x8.height()),\n                        ac_8x8.tobytes('RGBA'))\nim_ac.save(\"ac.png\", \"PNG\")\n\n# =================================\n\nhello = font.draw('Hello!', direction='rl').glow()\nprint(hello)\n\nimport numpy\nimport matplotlib.pyplot as plt\nnparr = numpy.array(hello.todata(2))\nplt.imshow(nparr, 'Blues')\nplt.show()\n\n# =================================\n\nfont_preview = font.drawall()\nim_ac = Image.frombytes('1',\n                        (font_preview.width(), font_preview.height()),\n                        font_preview.tobytes('1'))\nim_ac.save(\"font_preview.png\", \"PNG\")\n```\n\nYou probably understand what I did in these examples. Whether you do or not, go to [**bdfparser's documentation website**](https://font.tomchen.org/bdfparser_py/).\n\n<p align=\"center\">\n<a href=\"https://font.tomchen.org/bdfparser_py/\">\n<img src=\"https://font.tomchen.org/img/bdfparser_py/ac.png\" /><br>\n<img src=\"https://font.tomchen.org/img/bdfparser_py/plot.png\" /><br>\n<img src=\"https://font.tomchen.org/img/bdfparser_py/font_preview_part.png\" />\n</a>\n<a href=\"https://font.tomchen.org/bdfparser_js/editor\" title=\"BDF Parser Live Demo & Code Editor\"><img src=\"https://font.tomchen.org/img/bdfparser_js/bdfparser_live_editor_demo.gif\" width=\"700\" alt=\"BDF Parser Live Demo & Code Editor\"></a>\n</p>\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "BDF (Glyph Bitmap Distribution Format) Bitmap Font File Parser in Python",
    "version": "2.2.0",
    "project_urls": {
        "Bug Reports": "https://github.com/tomchen/bdfparser/issues",
        "Documentation": "https://github.com/tomchen/bdfparser",
        "Homepage": "https://github.com/tomchen/bdfparser",
        "Source Code": "https://github.com/tomchen/bdfparser"
    },
    "split_keywords": [
        "bdf",
        "bitmap",
        "font",
        "parser"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2f00846b41165fd31b5668fe89bdbda9f44099d9df8760c3865404336af094a3",
                "md5": "45c5fca5dd88ebe05219ed61503e8384",
                "sha256": "62ceed3b90b1fca050fcb414e70cc5b1f4551d57b088f9e7417678563eebf135"
            },
            "downloads": -1,
            "filename": "bdfparser-2.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "45c5fca5dd88ebe05219ed61503e8384",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.5",
            "size": 12611,
            "upload_time": "2021-02-06T21:30:49",
            "upload_time_iso_8601": "2021-02-06T21:30:49.736409Z",
            "url": "https://files.pythonhosted.org/packages/2f/00/846b41165fd31b5668fe89bdbda9f44099d9df8760c3865404336af094a3/bdfparser-2.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e3b78e2a9b806450254f1ae0d4e18e4d8612cf7561fb87a5a8395e369b3bf4b9",
                "md5": "614854b2fae1abb929f0701f2506d893",
                "sha256": "75cebd7c2f1ed5e5d0985763b255726a9538c602c7c5ca8639707aec54a58683"
            },
            "downloads": -1,
            "filename": "bdfparser-2.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "614854b2fae1abb929f0701f2506d893",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.5",
            "size": 14631,
            "upload_time": "2021-02-06T21:30:50",
            "upload_time_iso_8601": "2021-02-06T21:30:50.860205Z",
            "url": "https://files.pythonhosted.org/packages/e3/b7/8e2a9b806450254f1ae0d4e18e4d8612cf7561fb87a5a8395e369b3bf4b9/bdfparser-2.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2021-02-06 21:30:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tomchen",
    "github_project": "bdfparser",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "bdfparser"
}
        
Elapsed time: 0.28280s