# RuntimeError: 由于缺少字体度量，无法使用tex处理字符串。

- **ID:** `python/matplotlib-pdf-font-embedding-error`
- **领域:** python
- **类别:** system_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

使用LaTeX文本渲染(usetex=True)时，LaTeX安装不完整或缺少所需字体。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |

## 解决方案

1. **Install a full LaTeX distribution (e.g., TeX Live or MiKTeX)** (90% 成功率)
   ```
   sudo apt-get install texlive-latex-base texlive-fonts-recommended
   ```
2. **Disable usetex and use Matplotlib's built-in math rendering** (95% 成功率)
   ```
   plt.rcParams['text.usetex'] = False
   ```

## 无效尝试

- **Installing only matplotlib with pip** — LaTeX is a separate system; pip cannot install it. (95% 失败率)
- **Setting usetex=False but still getting error** — If usetex is False, this error should not occur; the setting might not have been reset. (80% 失败率)
