ufoProcessor


NameufoProcessor JSON
Version 1.9.0 PyPI version JSON
download
home_pagehttps://github.com/LettError/ufoProcessor
SummaryRead, write and generate UFOs with designspace data.
upload_time2020-03-24 16:33:44
maintainer
docs_urlNone
authorErik van Blokland
requires_python>=2.7
licenseMIT
keywords font development tools
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            [![Travis](https://travis-ci.org/LettError/ufoProcessor.svg?branch=master)](https://travis-ci.org/LettError/ufoProcessor)
[![PyPI](https://img.shields.io/pypi/v/ufoprocessor.svg)](https://pypi.org/project/ufoprocessor)

# ufoProcessor
Python package based on the **designSpaceDocument** from [fontTools.designspaceLib](https://github.com/fonttools/fonttools/tree/master/Lib/fontTools/designspaceLib)) specifically to _process_ and _generate_ instances for UFO files, glyphs and other data.

* Collect source materials
* Provide mutators for specific glyphs, font info, kerning so that other tools can generate partial instances. Either from `MutatorMath` or `fonttools varlib.model`.
* Support designspace format 4 with layers.
* Apply avar-like designspace bending
* Apply rules
* Generate actual UFO instances in formats 2 and 3.
* Round geometry as requested
* Try to stay up to date with fontTools
* Baseclass for tools that need access to designspace data.

## Usage
The easiest way to use ufoProcessor is to call `build(designspacePath)`

* **documentPath**: path to the designspace file.
* **outputUFOFormatVersion**: integer, 2, 3. Format for generated UFOs. Note: can be different from source UFO format.
* **roundGeometry**: bool, if the geometry needs to be rounded to whole integers. This affects glyphs, metrics, kerning, select font info.
* **processRules**: bool, when generating UFOs, execute designspace rules as swaps.
* **logger**: optional logger object.

* **documentPath**:               filepath to the .designspace document
* **outputUFOFormatVersion**:     ufo format for output, default is the current, so 3.
* **useVarlib**:                  True if you want the geometry to be generated with `varLib.model` instead of `mutatorMath`.

## Examples

Generate all the instances (using the varlib model, no rounding):

```python
import ufoProcessor
myPath = "myDesignspace.designspace"
ufoProcessor.build(myPath)
```

Generate all the instances (using the varlib model, but round all the geometry to integers):

```python
import ufoProcessor
myPath = "myDesignspace.designspace"
ufoProcessor.build(myPath, roundGeometry=True)
```

Generate all the instances (using the mutatormath model, no rounding):

```python
import ufoProcessor
myPath = "myDesignspace.designspace"
ufoProcessor.build(myPath, useVarlib=False)
```

Generate an instance for one glyph, `"A"` at `width=100, weight=200`. (assuming the designspace has those axes and the masters have that glyph)

```python
import ufoProcessor
myPath = "myDesignspace.designspace"
doc = ufoProcessor.DesignSpaceProcessor()
doc.read(myPath)
doc.loadFonts()
glyphMutator = doc.getGlyphMutator("A")
instance = glyphMutator.makeInstance(Location(width=100, weight=200)
```

Depending on the setting for `usevarlib`, the `glyphMutator` object returned by `getGlyphMutator` in the example above can either be a `MutatorMath.Mutator`, or a `VariationModelMutator` object. That uses the `fontTools.varLib.models.VariationModel` but it is wrapped and can be called as a Mutator object to generate instances. This way `DesignSpaceProcessor` does not need to know much about which math model it is using.


## Convert Superpolator to designspace

The ufoProcessor.sp3 module has some tools for interpreting Superpolator .sp3 documents. Not all data is migrated. But the important geometry is there. Given that Superpolator can read designspace files, there is hopefully no real need for a writer. Note that this conversion is lossy. 

* Axis
	* dimensions
	* name
	* tag
* Source
	* ufo path
	* familyname, stylename
	* mute state (stored in lib)
	* location
* Instance
	* ufo path
	* familyname, stylename
	* stylemap names
	* location
* Rules
	* *Simple Rules* are wrapped in a conditionset.
	* most of the really old Superpolator rules can't be converted. Only rules with `<` or `>` operators are used.
* Some Superpolator user prefs
	* Preview text
	* Which axes used vertically and horizontally


## Usage 
```python
# convert sp3 file to designspace
# first make a new designspace doc object
doc = DesignSpaceDocument()
# feed it to the reader
reader = SuperpolatorReader(sp3path, doc)
reader.read()
# now you can work with it, even save it
doc.write(designspacePath)
```
Indeed that last example comes from this convenience function:  
```sp3_to_designspace(sp3path, designspacePath=None)```
If designspacePath = None, sp3_to_designspace will use the same path for the output, but replace the `.sp3` with `.designspace` extension. If the file exists it will overwrite.

## Notes
* Glyph-specific masters in instances are ignored.   
* Instance notes are ignored. 
* Designspace geometry requires the default master to be on the default value of each axis. Superpolator handled that differently, it would find the default dynamically. So it is possible that converted designspaces need some work in terms of the basic structure. That can't be handled automatically.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/LettError/ufoProcessor",
    "name": "ufoProcessor",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=2.7",
    "maintainer_email": "",
    "keywords": "font development tools",
    "author": "Erik van Blokland",
    "author_email": "erik@letterror.com",
    "download_url": "https://files.pythonhosted.org/packages/b0/d6/a2b248adc2f26a97752bec3719bd5d33a788890b5546bff0839baeba1b4e/ufoProcessor-1.9.0.zip",
    "platform": "",
    "description": "[![Travis](https://travis-ci.org/LettError/ufoProcessor.svg?branch=master)](https://travis-ci.org/LettError/ufoProcessor)\n[![PyPI](https://img.shields.io/pypi/v/ufoprocessor.svg)](https://pypi.org/project/ufoprocessor)\n\n# ufoProcessor\nPython package based on the **designSpaceDocument** from [fontTools.designspaceLib](https://github.com/fonttools/fonttools/tree/master/Lib/fontTools/designspaceLib)) specifically to _process_ and _generate_ instances for UFO files, glyphs and other data.\n\n* Collect source materials\n* Provide mutators for specific glyphs, font info, kerning so that other tools can generate partial instances. Either from `MutatorMath` or `fonttools varlib.model`.\n* Support designspace format 4 with layers.\n* Apply avar-like designspace bending\n* Apply rules\n* Generate actual UFO instances in formats 2 and 3.\n* Round geometry as requested\n* Try to stay up to date with fontTools\n* Baseclass for tools that need access to designspace data.\n\n## Usage\nThe easiest way to use ufoProcessor is to call `build(designspacePath)`\n\n* **documentPath**: path to the designspace file.\n* **outputUFOFormatVersion**: integer, 2, 3. Format for generated UFOs. Note: can be different from source UFO format.\n* **roundGeometry**: bool, if the geometry needs to be rounded to whole integers. This affects glyphs, metrics, kerning, select font info.\n* **processRules**: bool, when generating UFOs, execute designspace rules as swaps.\n* **logger**: optional logger object.\n\n* **documentPath**:               filepath to the .designspace document\n* **outputUFOFormatVersion**:     ufo format for output, default is the current, so 3.\n* **useVarlib**:                  True if you want the geometry to be generated with `varLib.model` instead of `mutatorMath`.\n\n## Examples\n\nGenerate all the instances (using the varlib model, no rounding):\n\n```python\nimport ufoProcessor\nmyPath = \"myDesignspace.designspace\"\nufoProcessor.build(myPath)\n```\n\nGenerate all the instances (using the varlib model, but round all the geometry to integers):\n\n```python\nimport ufoProcessor\nmyPath = \"myDesignspace.designspace\"\nufoProcessor.build(myPath, roundGeometry=True)\n```\n\nGenerate all the instances (using the mutatormath model, no rounding):\n\n```python\nimport ufoProcessor\nmyPath = \"myDesignspace.designspace\"\nufoProcessor.build(myPath, useVarlib=False)\n```\n\nGenerate an instance for one glyph, `\"A\"` at `width=100, weight=200`. (assuming the designspace has those axes and the masters have that glyph)\n\n```python\nimport ufoProcessor\nmyPath = \"myDesignspace.designspace\"\ndoc = ufoProcessor.DesignSpaceProcessor()\ndoc.read(myPath)\ndoc.loadFonts()\nglyphMutator = doc.getGlyphMutator(\"A\")\ninstance = glyphMutator.makeInstance(Location(width=100, weight=200)\n```\n\nDepending on the setting for `usevarlib`, the `glyphMutator` object returned by `getGlyphMutator` in the example above can either be a `MutatorMath.Mutator`, or a `VariationModelMutator` object. That uses the `fontTools.varLib.models.VariationModel` but it is wrapped and can be called as a Mutator object to generate instances. This way `DesignSpaceProcessor` does not need to know much about which math model it is using.\n\n\n## Convert Superpolator to designspace\n\nThe ufoProcessor.sp3 module has some tools for interpreting Superpolator .sp3 documents. Not all data is migrated. But the important geometry is there. Given that Superpolator can read designspace files, there is hopefully no real need for a writer. Note that this conversion is lossy. \n\n* Axis\n\t* dimensions\n\t* name\n\t* tag\n* Source\n\t* ufo path\n\t* familyname, stylename\n\t* mute state (stored in lib)\n\t* location\n* Instance\n\t* ufo path\n\t* familyname, stylename\n\t* stylemap names\n\t* location\n* Rules\n\t* *Simple Rules* are wrapped in a conditionset.\n\t* most of the really old Superpolator rules can't be converted. Only rules with `<` or `>` operators are used.\n* Some Superpolator user prefs\n\t* Preview text\n\t* Which axes used vertically and horizontally\n\n\n## Usage \n```python\n# convert sp3 file to designspace\n# first make a new designspace doc object\ndoc = DesignSpaceDocument()\n# feed it to the reader\nreader = SuperpolatorReader(sp3path, doc)\nreader.read()\n# now you can work with it, even save it\ndoc.write(designspacePath)\n```\nIndeed that last example comes from this convenience function:  \n```sp3_to_designspace(sp3path, designspacePath=None)```\nIf designspacePath = None, sp3_to_designspace will use the same path for the output, but replace the `.sp3` with `.designspace` extension. If the file exists it will overwrite.\n\n## Notes\n* Glyph-specific masters in instances are ignored.   \n* Instance notes are ignored. \n* Designspace geometry requires the default master to be on the default value of each axis. Superpolator handled that differently, it would find the default dynamically. So it is possible that converted designspaces need some work in terms of the basic structure. That can't be handled automatically.\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Read, write and generate UFOs with designspace data.",
    "version": "1.9.0",
    "split_keywords": [
        "font",
        "development",
        "tools"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "47668ce437915371d6813339d236d8beb6cbef601d125e94d7c09bfa0f6dd5c6",
                "md5": "a34c97f1b371e69ab918f7cacb38bfdd",
                "sha256": "0b77d4055306872d5df662feec6d066bdd34fc304c5a6c5999d2bcfd1720e637"
            },
            "downloads": -1,
            "filename": "ufoProcessor-1.9.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a34c97f1b371e69ab918f7cacb38bfdd",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=2.7",
            "size": 22746,
            "upload_time": "2020-03-24T16:33:43",
            "upload_time_iso_8601": "2020-03-24T16:33:43.058321Z",
            "url": "https://files.pythonhosted.org/packages/47/66/8ce437915371d6813339d236d8beb6cbef601d125e94d7c09bfa0f6dd5c6/ufoProcessor-1.9.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b0d6a2b248adc2f26a97752bec3719bd5d33a788890b5546bff0839baeba1b4e",
                "md5": "77f3e1d71d4780241707338441b0722a",
                "sha256": "baa8bd9bbbb11ce004647eb1906105f4d5bfdbc1b3388ca4d36fab57950a415b"
            },
            "downloads": -1,
            "filename": "ufoProcessor-1.9.0.zip",
            "has_sig": false,
            "md5_digest": "77f3e1d71d4780241707338441b0722a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=2.7",
            "size": 70066,
            "upload_time": "2020-03-24T16:33:44",
            "upload_time_iso_8601": "2020-03-24T16:33:44.174452Z",
            "url": "https://files.pythonhosted.org/packages/b0/d6/a2b248adc2f26a97752bec3719bd5d33a788890b5546bff0839baeba1b4e/ufoProcessor-1.9.0.zip",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2020-03-24 16:33:44",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "LettError",
    "github_project": "ufoProcessor",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "ufoprocessor"
}
        
Elapsed time: 0.03221s