Skip to content

Commit

Permalink
fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
Zverik committed Dec 22, 2014
1 parent 56c5a11 commit d557d4b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Nik4 Change History

## *master*

* `--version` option.
* Added `--fonts` option for registering additional fonts. [#16](https://github.com/Zverik/Nik4/issues/16)

## 1.5, 7.12.2014

* Removed debug output for `--url`.
Expand Down
12 changes: 12 additions & 0 deletions nik4.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ def xml_vars(style, variables):
rstyle = rstyle + style[last:]
return rstyle

def add_fonts(path):
if os.path.exists(path):
mapnik.register_fonts(path)
else:
raise Exception('The directory "{p}" does not exists'.format(p=path))

if __name__ == "__main__":
parser = argparse.ArgumentParser(description='Nik4 {}: Tile-aware mapnik image renderer'.format(VERSION))
parser.add_argument('--version', action='version', version='Nik4 {}'.format(VERSION))
Expand Down Expand Up @@ -202,6 +208,7 @@ def xml_vars(style, variables):
parser.add_argument('-f', '--format', dest='fmt', help='Target file format (by default looks at extension)')
parser.add_argument('--base', help='Base path for style file, in case it\'s piped to stdin')
parser.add_argument('--vars', nargs='*', help='List of variables (name=value) to substitute in style file (use ${name:default})')
parser.add_argument('--fonts', nargs='*', help='List of full path to directories containing fonts')
parser.add_argument('style', help='Style file for mapnik')
parser.add_argument('output', help='Resulting image file')
options = parser.parse_args()
Expand Down Expand Up @@ -316,6 +323,11 @@ def xml_vars(style, variables):
mapnik.load_map_from_string(m, style_xml, False, style_path)
m.srs = p3857.params()

# register non-standard fonts
if options.fonts:
for f in options.fonts:
add_fonts(f)

# get bbox from layer extents
if options.fit:
bbox = layer_bbox(m, options.fit.split(','), bbox)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

setup(
name='Nik4',
version='1.5.0',
version='1.5.1',
license='WTFPL',
description='Command-line interface to a Mapnik rendering toolkit',
long_description="""
Expand Down

0 comments on commit d557d4b

Please sign in to comment.