Only supported for TrueType fonts在jupyter notebook
时间: 2023-09-20 19:03:34 浏览: 375
这错误通常发生在使用 Matplotlib 绘图时,因为 Matplotlib 默认使用的是 Type 3 字体格式,而某些字体不支持该格式。解决这个问题的方法是将 Matplotlib 的字体设置为 TrueType 格式。
你可以通过以下代码在 Jupyter Notebook 中设置 Matplotlib 的字体:
```python
import matplotlib.pyplot as plt
plt.rcParams['pdf.fonttype'] = 42
plt.rcParams['ps.fonttype'] = 42
```
这将把 Matplotlib 的字体格式设置为 TrueType,从而解决这个问题。
相关问题
Only supported for TrueType fonts
This error message usually occurs in the PIL library's ImageDraw module when attempting to use a font format that is not supported. The error message suggests that only TrueType fonts are supported.
To fix this error, you can try using a TrueType font instead of the font format you are currently using. You can specify a TrueType font in PIL using the `ImageFont.truetype()` method. Here is an example:
```python
from PIL import Image, ImageDraw, ImageFont
# Specify TrueType font
font = ImageFont.truetype('arial.ttf', size=20)
# Draw text on image
image = Image.new('RGB', (100, 100), color='white')
draw = ImageDraw.Draw(image)
draw.text((10, 10), 'Hello, World!', fill='black', font=font)
image.show()
```
In this example, we specify a TrueType font by calling `ImageFont.truetype()` and passing in the font file path and font size. You can replace `'arial.ttf'` with the path to the TrueType font file you want to use.
Only supported for TrueType fonts是啥意思
"Only supported for TrueType fonts" 意思是该功能仅适用于 TrueType 字体。可能是因为该功能需要使用 TrueType 字体的某些特性或属性,而其他类型的字体不支持这些特性或属性。如果您正在尝试使用非 TrueType 字体进行该功能,则可能会遇到错误或问题。