Skip to content

Commit 4410a5a

Browse files
committed
Package the scripts. Improve documentation.
1 parent fa2de4e commit 4410a5a

File tree

13 files changed

+110
-134
lines changed

13 files changed

+110
-134
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
*.pyc
2+
*.egg-info
3+
build
4+
venv

README.md

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,72 @@
22

33
# Tools for making OpenType-SVG fonts
44

5-
Dependencies:
5+
- `addsvg`
6+
adds an SVG table to a font, using SVG files provided. The font's format can be either OpenType or TrueType.
67

7-
- python 2.7 or higher
8-
- [fontTools 3.0](https://github.com/fonttools/fonttools)
8+
- `dumpsvg`
9+
saves the contents of a font's SVG table as individual SVG files. The font's format can be either OpenType, TrueType, WOFF, or WOFF2.
910

10-
## How to make OpenType-SVG fonts?
11+
- `fonts2svg`
12+
generates a set of SVG glyph files from one or more fonts and hex colors for each of them. The fonts' format can be either OpenType, TrueType, WOFF, or WOFF2.
13+
14+
15+
### Dependencies
16+
17+
- Python 3.6 or higher
18+
19+
- [FontTools](https://github.com/fonttools/fonttools) 3.1.0 or higher
20+
21+
22+
### Installation instructions
23+
24+
- Make sure you have Python 3.6 (or higher) installed.
25+
26+
- Clone this repository.
27+
28+
- `cd` into the repository folder.
29+
30+
- Setup a virtual environment:
31+
32+
$ python3 -m venv venv
33+
34+
- Activate the environment:
35+
36+
$ source venv/bin/activate
37+
38+
- Update `pip`:
39+
40+
$ pip install -U pip
41+
42+
- Install `opentypesvg`:
43+
44+
$ pip install .
45+
46+
47+
# How to make OpenType-SVG fonts?
1148

1249
### Step 1
1350
#### Generate a set of SVG files from a series of fonts and color values.
1451

1552
![step1](imgs/step1.png "step 1")
1653

17-
```sh
18-
$ python fonts2svg.py -c 99ccff,ff0066,cc0066 fonts/Zebrawood-Shadow.otf fonts/Zebrawood-Fill.otf fonts/Zebrawood-Dots.otf
19-
```
54+
fonts2svg -c 99ccff,ff0066,cc0066 fonts/Zebrawood-Shadow.otf fonts/Zebrawood-Fill.otf fonts/Zebrawood-Dots.otf
2055

2156
### Step 2
2257
#### Add a set of SVG files to an existing OpenType (or TrueType) font.
2358

2459
![step2](imgs/step2.png "step 2")
2560

26-
```sh
27-
$ python addSVGtable.py -s fonts/SVGs fonts/Zebrawood.otf
28-
```
61+
addsvg -s fonts/SVGs fonts/Zebrawood.otf
2962

30-
You can use **Step 2** without doing **Step 1**, but there are a few things you need to be aware of when using the `addSVGtable.py` script:
63+
You can use **Step 2** without doing **Step 1**, but there are a few things you need to be aware of when using the `addsvg` tool:
3164

3265
* After the SVG files are saved with the authoring application (e.g. Adobe Illustrator, CorelDRAW!, Inkscape) they should be put thru a process that optimizes and cleans up the SVG code; this will slim down the file size while keeping the resulting artwork the same. For this step you can use one of these tools:
3366
* [SVG Cleaner](https://github.com/RazrFalcon/svgcleaner-gui/releases) (GUI version)
3467
* [SVG Cleaner](https://github.com/RazrFalcon/svgcleaner) (command line version)
3568
* [SVG Optimizer](https://github.com/svg/svgo)
3669
* [Scour](https://github.com/scour-project/scour)
3770

38-
* The script requires the SVG files to be named after the glyphs which they are meant to be associated with. For example, if the glyph in the font is named **ampersand**, the SVG file needs to be named `ampersand.svg`.
71+
* The tool requires the SVG files to be named according to the glyphs which they are meant to be associated with. For example, if the glyph in the font is named **ampersand**, the SVG file needs to be named `ampersand.svg`.
3972

40-
* The script expects the color artwork to have been designed at the same size as the glyphs in the font, usually 1000 or 2048 UPM. This means 1 point (pt) in the authoring app equals 1 unit in font coordinates.
73+
* The tool expects the color artwork to have been designed at the same size as the glyphs in the font, usually 1000 or 2048 UPM. This means 1 point (pt) in the authoring app equals 1 unit in font coordinates.

addSVGtable.py renamed to lib/opentypesvg/addsvg.py

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,23 @@
99

1010
from __future__ import print_function
1111

12-
__version__ = '1.1.0'
12+
__version__ = '1.1.1'
1313

1414
import argparse
1515
import os
1616
import re
1717
import sys
1818
from shutil import copy2
1919

20-
from util.shared_utils import (read_file, split_comma_sequence,
21-
validate_font_paths, validate_folder_path)
22-
23-
import util.check_fonttools # pylint: disable=unused-import
24-
2520
from fontTools import ttLib
2621

22+
from opentypesvg.utils import (
23+
read_file,
24+
split_comma_sequence,
25+
validate_folder_path,
26+
validate_font_paths,
27+
)
28+
2729

2830
def getGlyphNameFromFileName(filePath):
2931
fontFileName = os.path.split(filePath)[1]
@@ -81,7 +83,7 @@ def cleanupSVGdoc(svgItemData):
8183
return svgItemData
8284

8385

84-
reCopyCounter = re.compile("#\d+$")
86+
reCopyCounter = re.compile(r"#\d+$")
8587

8688

8789
def makeFontCopyPath(fontPath):
@@ -281,15 +283,6 @@ def get_options(args):
281283
)
282284
options = parser.parse_args(args)
283285

284-
if options.generate_woffs:
285-
# Make sure that the brotli module is installed
286-
try:
287-
import brotli # pylint: disable=unused-variable
288-
except ImportError as err:
289-
print("ERROR: {} was found. The WOFF2 format requires it.".format(
290-
err), file=sys.stderr)
291-
sys.exit(1)
292-
293286
options.font_paths_list = validate_font_paths([options.input_path])
294287
return options
295288

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,23 +9,26 @@
99

1010
from __future__ import division, print_function
1111

12-
__version__ = '1.1.0'
12+
__version__ = '1.1.1'
1313

1414
import argparse
1515
import os
1616
import re
1717
import sys
1818

19-
from util.shared_utils import (write_file, final_message,
20-
get_output_folder_path,
21-
validate_font_paths, split_comma_sequence,
22-
create_folder, create_nested_folder,
23-
get_gnames_to_save_in_nested_folder)
24-
25-
import util.check_fonttools # pylint: disable=unused-import
26-
2719
from fontTools import ttLib
2820

21+
from opentypesvg.utils import (
22+
create_folder,
23+
create_nested_folder,
24+
final_message,
25+
get_gnames_to_save_in_nested_folder,
26+
get_output_folder_path,
27+
split_comma_sequence,
28+
validate_font_paths,
29+
write_file,
30+
)
31+
2932

3033
reViewBox = re.compile(r"viewBox=[\"|\']([\d, ])+?[\"|\']", re.DOTALL)
3134

fonts2svg.py renamed to lib/opentypesvg/fonts2svg.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,28 @@
1010

1111
from __future__ import division, print_function
1212

13-
__version__ = '1.1.0'
13+
__version__ = '1.1.1'
1414

1515
import argparse
1616
import os
1717
import re
1818
import sys
1919

20-
from util.shared_utils import (write_file, final_message,
21-
get_output_folder_path,
22-
validate_font_paths, split_comma_sequence,
23-
create_folder, create_nested_folder,
24-
get_gnames_to_save_in_nested_folder)
25-
26-
import util.check_fonttools # pylint: disable=unused-import
27-
2820
from fontTools import ttLib
2921
from fontTools.pens.basePen import BasePen
3022
from fontTools.pens.transformPen import TransformPen
3123

24+
from opentypesvg.utils import (
25+
create_folder,
26+
create_nested_folder,
27+
final_message,
28+
get_gnames_to_save_in_nested_folder,
29+
get_output_folder_path,
30+
split_comma_sequence,
31+
validate_font_paths,
32+
write_file,
33+
)
34+
3235

3336
class SVGPen(BasePen):
3437

setup.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from setuptools import setup
2+
3+
with open("README.md", "r") as fh:
4+
long_description = fh.read()
5+
6+
setup(
7+
name="opentypesvg",
8+
version="1.1.1",
9+
author="Miguel Sousa",
10+
author_email="msousa@adobe.com",
11+
description="Tools for making OpenType-SVG fonts",
12+
long_description=long_description,
13+
long_description_content_type="text/markdown",
14+
url="https://github.com/adobe-type-tools/opentype-svg",
15+
license="MIT",
16+
platforms=["Any"],
17+
package_dir={'': 'lib'},
18+
packages=['opentypesvg'],
19+
python_requires='>=3.6',
20+
install_requires=['fontTools[woff]>=3.1.0'],
21+
entry_points={
22+
'console_scripts': [
23+
"addsvg = opentypesvg.addsvg:main",
24+
"dumpsvg = opentypesvg.dumpsvg:main",
25+
"fonts2svg = opentypesvg.fonts2svg:main",
26+
]
27+
},
28+
)

tests/__init__.py

Whitespace-only changes.

tests/check_fonttools_test.py

Lines changed: 0 additions & 42 deletions
This file was deleted.

tests/run_tests.cmd

Lines changed: 0 additions & 6 deletions
This file was deleted.

0 commit comments

Comments
 (0)