===========
glyphtools
===========
.. image:: https://img.shields.io/pypi/v/glyphtools.svg
:target: https://pypi.python.org/pypi/glyphtools
.. image:: https://img.shields.io/travis/simoncozens/glyphtools.svg
:target: https://travis-ci.com/simoncozens/glyphtools
.. image:: https://readthedocs.org/projects/glyphtools/badge/?version=latest
:target: https://glyphtools.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Status
Routines for extracting information from font glyphs
**glyphtools.bin_glyphs_by_metric(font, glyphs, category,
bincount=5)**
Organise glyphs according to a given metric.
Organises similar glyphs into a number of bins. The bins are not
guaranteed to contain the same number of glyphs; the
one-dimensional ckmeans clustering algorithm is used to cluster
glyphs based on metric similarity. For example, if there are five
glyphs of width 100, 102, 105, 210, and 220 units respectively, and
you ask for two bins, the first bin will contain three glyphs and
the second will contain two. This is usually what you want.
:Parameters:
* **font** – a ``fontTools`` TTFont object OR a ``glyphsLib`` GSFontMaster object OR a ``babelfont`` Font object.
* **glyphs** – a collection of glyph names
* **category** – the metric (see metric keys in
get_glyph_metrics().)
* **bincount** – number of bins to return
:Returns:
A list of ``bincount`` two-element tuples. The first element is
a list of glyphnames in this bin; the second is the average
metric value of the glyphs in this bin.
**glyphtools.categorize_glyph(font, glyphname)**
Returns the category of the given glyph.
:Parameters:
* **font** – a ``fontTools`` TTFont object OR a ``glyphsLib`` GSFontMaster object OR a ``babelfont`` Font object.
* **glyphname** – name of the glyph.
:Returns:
A two-element tuple. The first element is one of the following
strings: ``unknown``, ``base``, ``mark``, ``ligature``,
``component``. If the glyph is a mark, the second element is the
mark attachment class number.
**glyphtools.determine_kern(font, glyph1, glyph2, targetdistance,
offset1=0, 0, offset2=0, 0, maxtuck=0.4)**
Determine a kerning value required to set two glyphs at given
ink-to-ink distance.
The value is bounded by the ``maxtuck`` parameter. For example, if
``maxtuck`` is 0.20, the right glyph will not be placed any further
left than 80% of the width of left glyph, even if this places the
ink further than ``targetdistance`` units away.
:Parameters:
* **font** – a ``fontTools`` TTFont object OR a ``glyphsLib`` GSFontMaster object OR a ``babelfont`` Font object.
* **glyph1** – name of the left glyph.
* **glyph2** – name of the right glyph.
* **targetdistance** – distance to set the glyphs apart.
* **offset1** – offset (X-coordinate, Y-coordinate) to place
left glyph.
* **offset2** – offset (X-coordinate, Y-coordinate) to place
right glyph.
* **maxtuck** – maximum proportion of the left glyph’s width to
kern.
Returns: A kerning value, in units.
**glyphtools.duplicate_glyph(font, existing, new)**
Add a new glyph to the font duplicating an existing one.
:Parameters:
* **font** – a ``babelfont`` Font object.
* **existing** – name of the glyph to duplicate.
* **new** – name of the glyph to add.
**glyphtools.get_glyph_metrics(font, glyphname)**
Returns glyph metrics as a dictionary.
:Parameters:
* **font** – a ``fontTools`` TTFont object OR a ``glyphsLib`` GSFontMaster object OR a ``babelfont`` Font object.
* **glyphname** – name of the glyph.
:Returns:
width: Advance width of the glyph. lsb: Left side-bearing rsb:
Right side-bearing xMin: minimum X coordinate xMax: maximum X
coordinate yMin: minimum Y coordinate yMax: maximum Y coordinate
rise: difference in Y coordinate between cursive entry and exit
:Return type:
A dictionary with the following keys
**glyphtools.set_glyph_category(font, glyphname, category,
maClass=None)**
Sets the category of the glyph in the font.
:Parameters:
* **font** – a ``fontTools`` TTFont object OR a ``glyphsLib`` GSFontMaster object OR a ``babelfont`` Font object.
* **glyphname** – name of the glyph.
* **category** – one of ``base``, ``mark``, ``ligature``,
``component``.
* **maClass** – If the category is ``base``, the mark
attachment class number.
* Free software: Apache Software License 2.0
* Documentation: https://glyphtools.readthedocs.io.
=======
History
=======
0.1.0 (2020-08-10)
------------------
* First release on PyPI.
Raw data
{
"_id": null,
"home_page": "https://github.com/simoncozens/glyphtools",
"name": "glyphtools",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.5",
"maintainer_email": "",
"keywords": "glyphtools",
"author": "Simon Cozens",
"author_email": "simon@simon-cozens.org",
"download_url": "https://files.pythonhosted.org/packages/0b/4a/4732f8b30a83591b79c226d7743b4f011a7052089938cc7f011c40e886f8/glyphtools-0.8.0.tar.gz",
"platform": "",
"description": "===========\nglyphtools\n===========\n\n\n.. image:: https://img.shields.io/pypi/v/glyphtools.svg\n :target: https://pypi.python.org/pypi/glyphtools\n\n.. image:: https://img.shields.io/travis/simoncozens/glyphtools.svg\n :target: https://travis-ci.com/simoncozens/glyphtools\n\n.. image:: https://readthedocs.org/projects/glyphtools/badge/?version=latest\n :target: https://glyphtools.readthedocs.io/en/latest/?badge=latest\n :alt: Documentation Status\n\n\nRoutines for extracting information from font glyphs\n\n\n**glyphtools.bin_glyphs_by_metric(font, glyphs, category,\nbincount=5)**\n\n Organise glyphs according to a given metric.\n\n Organises similar glyphs into a number of bins. The bins are not\n guaranteed to contain the same number of glyphs; the\n one-dimensional ckmeans clustering algorithm is used to cluster\n glyphs based on metric similarity. For example, if there are five\n glyphs of width 100, 102, 105, 210, and 220 units respectively, and\n you ask for two bins, the first bin will contain three glyphs and\n the second will contain two. This is usually what you want.\n\n :Parameters:\n * **font** \u2013 a ``fontTools`` TTFont object OR a ``glyphsLib`` GSFontMaster object OR a ``babelfont`` Font object.\n\n * **glyphs** \u2013 a collection of glyph names\n\n * **category** \u2013 the metric (see metric keys in\n get_glyph_metrics().)\n\n * **bincount** \u2013 number of bins to return\n\n :Returns:\n A list of ``bincount`` two-element tuples. The first element is\n a list of glyphnames in this bin; the second is the average\n metric value of the glyphs in this bin.\n\n**glyphtools.categorize_glyph(font, glyphname)**\n\n Returns the category of the given glyph.\n\n :Parameters:\n * **font** \u2013 a ``fontTools`` TTFont object OR a ``glyphsLib`` GSFontMaster object OR a ``babelfont`` Font object.\n\n * **glyphname** \u2013 name of the glyph.\n\n :Returns:\n A two-element tuple. The first element is one of the following\n strings: ``unknown``, ``base``, ``mark``, ``ligature``,\n ``component``. If the glyph is a mark, the second element is the\n mark attachment class number.\n\n**glyphtools.determine_kern(font, glyph1, glyph2, targetdistance,\noffset1=0, 0, offset2=0, 0, maxtuck=0.4)**\n\n Determine a kerning value required to set two glyphs at given\n ink-to-ink distance.\n\n The value is bounded by the ``maxtuck`` parameter. For example, if\n ``maxtuck`` is 0.20, the right glyph will not be placed any further\n left than 80% of the width of left glyph, even if this places the\n ink further than ``targetdistance`` units away.\n\n :Parameters:\n * **font** \u2013 a ``fontTools`` TTFont object OR a ``glyphsLib`` GSFontMaster object OR a ``babelfont`` Font object.\n\n * **glyph1** \u2013 name of the left glyph.\n\n * **glyph2** \u2013 name of the right glyph.\n\n * **targetdistance** \u2013 distance to set the glyphs apart.\n\n * **offset1** \u2013 offset (X-coordinate, Y-coordinate) to place\n left glyph.\n\n * **offset2** \u2013 offset (X-coordinate, Y-coordinate) to place\n right glyph.\n\n * **maxtuck** \u2013 maximum proportion of the left glyph\u2019s width to\n kern.\n\n Returns: A kerning value, in units.\n\n**glyphtools.duplicate_glyph(font, existing, new)**\n\n Add a new glyph to the font duplicating an existing one.\n\n :Parameters:\n * **font** \u2013 a ``babelfont`` Font object.\n\n * **existing** \u2013 name of the glyph to duplicate.\n\n * **new** \u2013 name of the glyph to add.\n\n**glyphtools.get_glyph_metrics(font, glyphname)**\n\n Returns glyph metrics as a dictionary.\n\n :Parameters:\n * **font** \u2013 a ``fontTools`` TTFont object OR a ``glyphsLib`` GSFontMaster object OR a ``babelfont`` Font object.\n\n * **glyphname** \u2013 name of the glyph.\n\n :Returns:\n width: Advance width of the glyph. lsb: Left side-bearing rsb:\n Right side-bearing xMin: minimum X coordinate xMax: maximum X\n coordinate yMin: minimum Y coordinate yMax: maximum Y coordinate\n rise: difference in Y coordinate between cursive entry and exit\n\n :Return type:\n A dictionary with the following keys\n\n**glyphtools.set_glyph_category(font, glyphname, category,\nmaClass=None)**\n\n Sets the category of the glyph in the font.\n\n :Parameters:\n * **font** \u2013 a ``fontTools`` TTFont object OR a ``glyphsLib`` GSFontMaster object OR a ``babelfont`` Font object.\n\n * **glyphname** \u2013 name of the glyph.\n\n * **category** \u2013 one of ``base``, ``mark``, ``ligature``,\n ``component``.\n\n * **maClass** \u2013 If the category is ``base``, the mark\n attachment class number.\n\n\n\n* Free software: Apache Software License 2.0\n* Documentation: https://glyphtools.readthedocs.io.\n\n\n=======\nHistory\n=======\n\n0.1.0 (2020-08-10)\n------------------\n\n* First release on PyPI.\n\n\n",
"bugtrack_url": null,
"license": "Apache Software License 2.0",
"summary": "Routines for extracting information from fontTools glyphs",
"version": "0.8.0",
"split_keywords": [
"glyphtools"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "5529c6435cc7f97690ac3cc9e6aa6a67",
"sha256": "c5de7881eb29f1d37f8879c7838ae4aa42cc07b185dcffbc7eac6dfb84a95f96"
},
"downloads": -1,
"filename": "glyphtools-0.8.0-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "5529c6435cc7f97690ac3cc9e6aa6a67",
"packagetype": "bdist_wheel",
"python_version": "py2.py3",
"requires_python": ">=3.5",
"size": 10009,
"upload_time": "2022-01-21T13:49:28",
"upload_time_iso_8601": "2022-01-21T13:49:28.394854Z",
"url": "https://files.pythonhosted.org/packages/d4/37/291cf7738fa42ff98539d0454b2356811e656f19ffb72566443a363339c4/glyphtools-0.8.0-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "cef2311fc771cd60d2d7456784664d43",
"sha256": "3d7c171d63096ec8ba66d37e75a697027970de05790c5021c91c5d05aed43fe3"
},
"downloads": -1,
"filename": "glyphtools-0.8.0.tar.gz",
"has_sig": false,
"md5_digest": "cef2311fc771cd60d2d7456784664d43",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.5",
"size": 20010,
"upload_time": "2022-01-21T13:49:30",
"upload_time_iso_8601": "2022-01-21T13:49:30.138445Z",
"url": "https://files.pythonhosted.org/packages/0b/4a/4732f8b30a83591b79c226d7743b4f011a7052089938cc7f011c40e886f8/glyphtools-0.8.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-01-21 13:49:30",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "simoncozens",
"github_project": "glyphtools",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"requirements": [
{
"name": "numpy",
"specs": []
},
{
"name": "beziers",
"specs": []
},
{
"name": "babelfont",
"specs": [
[
">",
"0.2.0"
]
]
},
{
"name": "glyphsLib",
"specs": []
}
],
"tox": true,
"lcname": "glyphtools"
}