python3.6使用wordcloud 1.9报错ValueError: Only supported for TrueType fonts

该版本的wordcloud的源码中显示不兼容python3.6 

解决办法:修改wordcloud源码

修改前

 508: box_size = draw.textbox((0, 0), word, font=transposed_font, anchor="lt")
           
 510:  result = occupancy.sample_position(box_size[3] + self.margin,
                                                   box_size[2] + self.margin,
                                                   random_state)

修改后

508:  box_size = draw.textsize(word, font=transposed_font)
510: result = occupancy.sample_position(box_size[1] + self.margin,
                                                   box_size[0] + self.margin,
posted @ 2023-08-29 19:53  突破铁皮  阅读(1246)  评论(1编辑  收藏  举报