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:
parent
f82e320395
commit
bf6b2d9f7e
@ -46,11 +46,16 @@ def fonts_to_quadratic(*fonts, **kwargs):
|
|||||||
font at a time may yield slightly more optimized results.
|
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', {})
|
report = kwargs.get('report', {})
|
||||||
dump_report = kwargs.get('dump_report', False)
|
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):
|
for glyph in FontCollection(fonts):
|
||||||
glyph_to_quadratic(glyph, max_errors, max_n, report)
|
glyph_to_quadratic(glyph, max_errors, max_n, report)
|
||||||
|
@ -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:
|
This can also be provided by the caller:
|
||||||
|
|
||||||
```python
|
```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
|
```python
|
||||||
for font in [thin_font, bold_font]:
|
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
|
`fonts_to_quadratic` can print a string reporting the number of curves of each
|
||||||
|
Loading…
x
Reference in New Issue
Block a user