Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
one errors on windows for font #411
I'm not able to reproduce (yet), but I would suspect that font library can not load the typeface. Usually the font-resolver will fallback to system fault if there's an issue, so we need to know what the actual error is. The following patch should at least emit ImageMagick's internal exception.
index 43f35eb..7f39dd3 100644 --- a/wand/drawing.py +++ b/wand/drawing.py @@ -1151,6 +1151,13 @@ class Drawing(Resource): else: text = binary(text) result = font_metrics_f(image.wand, self.resource, text) + if not result: + # Possible error on drawing context + self.raise_exception() + # Or error on image canvas + image.raise_exception() + # Generate a generic error if ImageMagick couldn't emit one. + raise ValueError('Unable to render text with current font.') args = [result[i] for i in xrange(13)] library.MagickRelinquishMemory(result) return FontMetrics(*args)
Don't know if you're able to patch & test, but I would like a minimum test case. Both Simplified & Traditional Chinese fonts work for me.
with Image(filename='wizard:') as img: with Drawing() as traditional_chinese: traditional_chinese.font = '/path/to/Apple LiSung Light.ttf' traditional_chinese.font_size = 64 metrics = traditional_chinese.get_font_metrics(img, u'你好，世界') print('Traditional Chinese', metrics) with Drawing() as simplified_chinese: simplified_chinese.font = '/path/to/FandolHei-Bold.otf' simplified_chinese.font_size = 64 metrics = simplified_chinese.get_font_metrics(img, u'你好，世界') print('Simplified Chinese', metrics)
Okay, this method will now raise the correct error. Should be a
As far as why it would fail, that's usually just a typo. Also ensure that