New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
one errors on windows for font #411
Comments
Can you share an example of the code that produced the |
ValueError: NULL pointer access. the errors is location in wand/drawing.py. |
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 |
such as the font's name is '方正兰亭黑.TTF', it would be error.when I change it to 'a.TTF',it will work well. |
I set a font have chinese with draw.font, then when i use draw.get_font_metrics(), it would be errors with valueError? what can I do for this?
The text was updated successfully, but these errors were encountered: