> For the complete documentation index, see [llms.txt](https://imgo.gitbook.io/cn/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://imgo.gitbook.io/cn/api/text.md).

# Text

在图像中插入文字。

## 参数

<table><thead><tr><th width="198.4826833846656">参数名</th><th width="208.18338610093963">类型</th><th>说明</th></tr></thead><tbody><tr><td>label</td><td><code>string</code></td><td>文字内容</td></tr><tr><td>x</td><td><code>int</code></td><td>插入文字的左上角坐标的 x 轴</td></tr><tr><td>y</td><td><code>int</code></td><td>插入文字的左上角坐标的 y 轴</td></tr><tr><td>fontPath</td><td><code>string</code></td><td>字体文件路径</td></tr><tr><td>fontColor</td><td><code>color.Color</code></td><td>文字颜色</td></tr><tr><td>fontSize</td><td><code>float64</code></td><td>文字大小</td></tr><tr><td>dpi</td><td><code>float64</code></td><td>文字 DPI</td></tr></tbody></table>

## 返回值

`*imgo.Image` 类型的实例。

## 例子

```go
package main

import (
    "github.com/fishtailstudio/imgo"
    "golang.org/x/image/colornames"
    "image/color"
)

func main() {
    fontPath := "/System/Library/Fonts/Supplemental/Arial.ttf"
    imgo.Canvas(500, 500, color.White).
        Text("Hello World", 50, 50, fontPath, colornames.Chocolate, 50, 100).
        Save("out.png")
}
```
