Specify tolerance in em through max_err_em

This way, the `max_err` parameter is consistent with the other
functions (being in font units).
This commit is contained in:
jamesgk 2015-11-24 12:52:03 -08:00
parent f82e320395
commit bf6b2d9f7e
2 changed files with 10 additions and 5 deletions

View File

@ -46,11 +46,16 @@ def fonts_to_quadratic(*fonts, **kwargs):
font at a time may yield slightly more optimized results.
"""
max_n = kwargs.get('max_n', 10)
max_err = kwargs.get('max_err', 0.0025)
max_errors = [f.info.unitsPerEm * max_err for f in fonts]
report = kwargs.get('report', {})
dump_report = kwargs.get('dump_report', False)
max_n = kwargs.get('max_n', 10)
max_err_em = kwargs.get('max_err_em', 0.0025)
max_err = kwargs.get('max_err', None)
if max_err:
max_errors = [max_err] * len(fonts)
else:
max_errors = [f.info.unitsPerEm * max_err_em for f in fonts]
for glyph in FontCollection(fonts):
glyph_to_quadratic(glyph, max_errors, max_n, report)

View File

@ -24,12 +24,12 @@ Some fonts may need a different error threshold than the default (0.0025 em).
This can also be provided by the caller:
```python
fonts_to_quadratic(thin_font, bold_font, max_err=0.005)
fonts_to_quadratic(thin_font, bold_font, max_err_em=0.005)
```
```python
for font in [thin_font, bold_font]:
fonts_to_quadratic(font, max_err=0.001)
fonts_to_quadratic(font, max_err_em=0.001)
```
`fonts_to_quadratic` can print a string reporting the number of curves of each