mplfonts


Namemplfonts JSON
Version 0.0.10 PyPI version JSON
download
home_pagehttps://github.com/Clarmy/mplfonts
SummaryFonts manager for matplotlib
upload_time2024-12-02 12:14:45
maintainerNone
docs_urlNone
authorWentao Li
requires_python>=3.9
licenseMIT
keywords matplotlib fonts manager
VCS
bugtrack_url
requirements fire fontmeta matplotlib
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [中文文档](./docs/README_zh.md)

[![Python package](https://github.com/Clarmy/mplfonts/actions/workflows/python-package.yml/badge.svg)](https://github.com/Clarmy/mplfonts/actions/workflows/python-package.yml)
[![PyPI version](https://badge.fury.io/py/mplfonts.svg)](https://badge.fury.io/py/mplfonts)
[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/Clarmy/mplfonts/issues)


# mplfonts
The mplfonts is a Python package and command-line tool that allows you to manage your Matplotlib fonts. It provides an easy solution to the "tofu" problem that arises when plotting with CJK (Chinese, Japanese, Korean) languages.

## Installation
You can use `pip` to install mplfonts.
```bash
$ pip install mplfonts
```

## Quickstart
You can easily solve the "tofu" problem with a single command:
```bash
$ mplfonts init
```
After that, try using Matplotlib to plot an image with CJK text; it should display normally. 

Now you can enjoy it.

## Usage
This package not only solves the "tofu" problem, but also provides a convenient way to manage Matplotlib fonts. When you install mplfonts, it comes with several open-source CJK fonts, including:
* Noto Sans Mono CJK SC
* Noto Serif CJK SC
* Noto Sans CJK SC
* Source Han Serif SC
* Source Han Mono SC

Once you have finished the initialization step, you can use the following code in your script to switch fonts:

```python
from mplfonts import use_font

use_font('Noto Serif CJK SC')

# write your plotting code below
```

If you want to set up custom fonts, you can install them with the following command:
```bash
$ mplfonts install --update <your font file path>
```
Furthermore, you can install all the fonts in a directory by running the following command:
```bash
$ mplfonts install --update <your directory path>
```

Unsure of which fonts are available? No problem, simply use the command `mplfonts list` to see a list of all available fonts.
```bash
$ mplfonts list
DejaVu Sans Display:
/Users/clarmylee/Miniconda3/envs/mplfonts/lib/python3.6/site-packages/matplotlib-3.3.4-py3.6-macosx-10.9-x86_64.egg/matplotlib/mpl-data/fonts/ttf/DejaVuSansDisplay.ttf
---------------
DejaVu Sans:
/Users/clarmylee/Miniconda3/envs/mplfonts/lib/python3.6/site-packages/matplotlib-3.3.4-py3.6-macosx-10.9-x86_64.egg/matplotlib/mpl-data/fonts/ttf/DejaVuSans-BoldOblique.ttf
---------------
Source Han Mono SC:
/Users/clarmylee/Miniconda3/envs/mplfonts/lib/python3.6/site-packages/matplotlib-3.3.4-py3.6-macosx-10.9-x86_64.egg/matplotlib/mpl-data/fonts/ttf/SourceHanMonoSC-Regular.otf

...
```
This command will show the names and source files of the fonts, which can then be passed as arguments to the `use_font` function.

By default, running `mplfonts init` will generate a new `matplotlibrc` file to replace your current one. This new file will contain cache configuration settings that support CJK rendering. Here is the content of the new `matplotlibrc` file:
```
font.family:  sans-serif
font.sans-serif: Noto Sans CJK SC Regular, 思源等宽, Noto Serif CJK SC, 思源宋体, Noto Sans Mono CJK SC Regularsans-serif
axes.unicode_minus: False
```
By default, `Noto Sans CJK SC Regular` is the preferred font. If you install custom fonts from another source and want them to have first priority, add them to the leftmost end of the `font.sans-serif` list. Then, run `$ mplfonts updaterc <your matplotlibrc path>` to set it as your global cache configuration.

## Fonts Source
You can access some open-source fonts from Google and Adobe. Here are some resources:
* https://github.com/adobe-fonts
* https://fonts.google.com
* https://github.com/googlefonts


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Clarmy/mplfonts",
    "name": "mplfonts",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "matplotlib, fonts, manager",
    "author": "Wentao Li",
    "author_email": "clarmyleewt@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/ef/db/1199ed8529793e5e6a0d8aa3500683513ae518f88b1e72a0e41151358410/mplfonts-0.0.10.tar.gz",
    "platform": null,
    "description": "[\u4e2d\u6587\u6587\u6863](./docs/README_zh.md)\n\n[![Python package](https://github.com/Clarmy/mplfonts/actions/workflows/python-package.yml/badge.svg)](https://github.com/Clarmy/mplfonts/actions/workflows/python-package.yml)\n[![PyPI version](https://badge.fury.io/py/mplfonts.svg)](https://badge.fury.io/py/mplfonts)\n[![contributions welcome](https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat)](https://github.com/Clarmy/mplfonts/issues)\n\n\n# mplfonts\nThe mplfonts is a Python package and command-line tool that allows you to manage your Matplotlib fonts. It provides an easy solution to the \"tofu\" problem that arises when plotting with CJK (Chinese, Japanese, Korean) languages.\n\n## Installation\nYou can use `pip` to install mplfonts.\n```bash\n$ pip install mplfonts\n```\n\n## Quickstart\nYou can easily solve the \"tofu\" problem with a single command:\n```bash\n$ mplfonts init\n```\nAfter that, try using Matplotlib to plot an image with CJK text; it should display normally. \n\nNow you can enjoy it.\n\n## Usage\nThis package not only solves the \"tofu\" problem, but also provides a convenient way to manage Matplotlib fonts. When you install mplfonts, it comes with several open-source CJK fonts, including:\n* Noto Sans Mono CJK SC\n* Noto Serif CJK SC\n* Noto Sans CJK SC\n* Source Han Serif SC\n* Source Han Mono SC\n\nOnce you have finished the initialization step, you can use the following code in your script to switch fonts:\n\n```python\nfrom mplfonts import use_font\n\nuse_font('Noto Serif CJK SC')\n\n# write your plotting code below\n```\n\nIf you want to set up custom fonts, you can install them with the following command:\n```bash\n$ mplfonts install --update <your font file path>\n```\nFurthermore, you can install all the fonts in a directory by running the following command:\n```bash\n$ mplfonts install --update <your directory path>\n```\n\nUnsure of which fonts are available? No problem, simply use the command `mplfonts list` to see a list of all available fonts.\n```bash\n$ mplfonts list\nDejaVu Sans Display:\n/Users/clarmylee/Miniconda3/envs/mplfonts/lib/python3.6/site-packages/matplotlib-3.3.4-py3.6-macosx-10.9-x86_64.egg/matplotlib/mpl-data/fonts/ttf/DejaVuSansDisplay.ttf\n---------------\nDejaVu Sans:\n/Users/clarmylee/Miniconda3/envs/mplfonts/lib/python3.6/site-packages/matplotlib-3.3.4-py3.6-macosx-10.9-x86_64.egg/matplotlib/mpl-data/fonts/ttf/DejaVuSans-BoldOblique.ttf\n---------------\nSource Han Mono SC:\n/Users/clarmylee/Miniconda3/envs/mplfonts/lib/python3.6/site-packages/matplotlib-3.3.4-py3.6-macosx-10.9-x86_64.egg/matplotlib/mpl-data/fonts/ttf/SourceHanMonoSC-Regular.otf\n\n...\n```\nThis command will show the names and source files of the fonts, which can then be passed as arguments to the `use_font` function.\n\nBy default, running `mplfonts init` will generate a new `matplotlibrc` file to replace your current one. This new file will contain cache configuration settings that support CJK rendering. Here is the content of the new `matplotlibrc` file:\n```\nfont.family:  sans-serif\nfont.sans-serif: Noto Sans CJK SC Regular, \u601d\u6e90\u7b49\u5bbd, Noto Serif CJK SC, \u601d\u6e90\u5b8b\u4f53, Noto Sans Mono CJK SC Regularsans-serif\naxes.unicode_minus: False\n```\nBy default, `Noto Sans CJK SC Regular` is the preferred font. If you install custom fonts from another source and want them to have first priority, add them to the leftmost end of the `font.sans-serif` list. Then, run `$ mplfonts updaterc <your matplotlibrc path>` to set it as your global cache configuration.\n\n## Fonts Source\nYou can access some open-source fonts from Google and Adobe. Here are some resources:\n* https://github.com/adobe-fonts\n* https://fonts.google.com\n* https://github.com/googlefonts\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Fonts manager for matplotlib",
    "version": "0.0.10",
    "project_urls": {
        "Homepage": "https://github.com/Clarmy/mplfonts",
        "Repository": "https://github.com/Clarmy/mplfonts"
    },
    "split_keywords": [
        "matplotlib",
        " fonts",
        " manager"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3ea026d69a8a973f1a381cff9d5375ee7d660f49445e57433d52f76fd22cb7c7",
                "md5": "a0b600a4d47be21a695013d02164f36c",
                "sha256": "835e35ada4a6ef85ce29ea81dd589a98b92af5b5c8e8b9f4e2d79dfea9c2ba40"
            },
            "downloads": -1,
            "filename": "mplfonts-0.0.10-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a0b600a4d47be21a695013d02164f36c",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 85007207,
            "upload_time": "2024-12-02T12:14:40",
            "upload_time_iso_8601": "2024-12-02T12:14:40.417700Z",
            "url": "https://files.pythonhosted.org/packages/3e/a0/26d69a8a973f1a381cff9d5375ee7d660f49445e57433d52f76fd22cb7c7/mplfonts-0.0.10-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "efdb1199ed8529793e5e6a0d8aa3500683513ae518f88b1e72a0e41151358410",
                "md5": "2c7289c7ddbad391e912f88326164df7",
                "sha256": "5da8d1afd53b8d38a1053d61a7ebd936de08b8480fba17f9b655beb270af8089"
            },
            "downloads": -1,
            "filename": "mplfonts-0.0.10.tar.gz",
            "has_sig": false,
            "md5_digest": "2c7289c7ddbad391e912f88326164df7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 84964997,
            "upload_time": "2024-12-02T12:14:45",
            "upload_time_iso_8601": "2024-12-02T12:14:45.372314Z",
            "url": "https://files.pythonhosted.org/packages/ef/db/1199ed8529793e5e6a0d8aa3500683513ae518f88b1e72a0e41151358410/mplfonts-0.0.10.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-12-02 12:14:45",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Clarmy",
    "github_project": "mplfonts",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [
        {
            "name": "fire",
            "specs": [
                [
                    ">=",
                    "0.4.0"
                ]
            ]
        },
        {
            "name": "fontmeta",
            "specs": [
                [
                    ">=",
                    "1.6.1"
                ]
            ]
        },
        {
            "name": "matplotlib",
            "specs": [
                [
                    ">=",
                    "3.4"
                ]
            ]
        }
    ],
    "lcname": "mplfonts"
}
        
Elapsed time: 6.76179s