## DrawString(string, Font, Brush, float, float) {#drawstring_4}

在指定位置用指定的字符绘制指定的文本字符串[`Brush`](../../brush/)和[`Font`](../../font/)对象.

```csharp
public void DrawString(string s, Font font, Brush brush, float x, float y)
```

| 范围 | 类型 | 描述 |
| --- | --- | --- |
| s | String | 要绘制的字符串。 |
| font | Font | [`Font`](../../font/)定义字符串的文本格式。 |
| brush | Brush | [`Brush`](../../brush/)确定绘制文本的颜色和纹理。 |
| x | Single | 绘制文本左上角的 x 坐标。 |
| y | Single | 绘制文本左上角的 y 坐标。 |

### 例外

| 例外 | （健康）状况 |
| --- | --- |
| ArgumentNullException | *brush*为空。 -或- *s*一片空白。 |

### 也可以看看

* class [Font](../../font/)
* class [Brush](../../brush/)
* class [Graphics](../)
* 命名空间 [Aspose.PSD](../../graphics/)
* 部件 [Aspose.PSD](../../../)

---

## DrawString(string, Font, Brush, PointF) {#drawstring}

在指定位置用指定的字符绘制指定的文本字符串[`Brush`](../../brush/)和[`Font`](../../font/)对象.

```csharp
public void DrawString(string s, Font font, Brush brush, PointF point)
```

| 范围 | 类型 | 描述 |
| --- | --- | --- |
| s | String | 要绘制的字符串。 |
| font | Font | [`Font`](../../font/)定义字符串的文本格式。 |
| brush | Brush | [`Brush`](../../brush/)确定绘制文本的颜色和纹理。 |
| point | PointF | [`PointF`](../../pointf/)指定绘制文本左上角的结构。 |

### 例外

| 例外 | （健康）状况 |
| --- | --- |
| ArgumentNullException | *brush*为空。 -或- *s*一片空白。 |

### 例子

此示例演示了使用 Font 和 SolidBrush 类在 Image 表面上绘制字符串。该示例创建一个新图像并使用 Figures 和 GraphicsPath 绘制形状

```csharp
[C#]

//创建图像实例
using (Aspose.PSD.Image image = new Aspose.PSD.FileFormats.Psd.PsdImage(500, 500))
{
    //创建并初始化Graphics类的实例
    Aspose.PSD.Graphics graphics = new Aspose.PSD.Graphics(image);

    //清除图形表面
    graphics.Clear(Color.Wheat);

    //创建字体实例
    Aspose.PSD.Font font = new Aspose.PSD.Font("Times New Roman", 16);

    //创建一个具有红色的 SolidBrush 实例
    Aspose.PSD.Brushes.SolidBrush brush = new Aspose.PSD.Brushes.SolidBrush(Color.Red);

    //画一个字符串
    graphics.DrawString("Created by Aspose.PSD for .Net", font, brush, new PointF(100, 100));

    // 创建导出选项。
    Aspose.PSD.ImageOptions.GifOptions options = new Aspose.PSD.ImageOptions.GifOptions();

    // 保存所有更改
    image.Save("C:\\temp\\output.gif", options);
}
```

### 也可以看看

* class [Font](../../font/)
* class [Brush](../../brush/)
* struct [PointF](../../pointf/)
* class [Graphics](../)
* 命名空间 [Aspose.PSD](../../graphics/)
* 部件 [Aspose.PSD](../../../)

---

## DrawString(string, Font, Brush, float, float, StringFormat) {#drawstring_5}

在指定位置用指定的字符绘制指定的文本字符串[`Brush`](../../brush/)和[`Font`](../../font/)使用指定格式属性的对象[`StringFormat`](../../stringformat/) .

```csharp
public void DrawString(string s, Font font, Brush brush, float x, float y, StringFormat format)
```

| 范围 | 类型 | 描述 |
| --- | --- | --- |
| s | String | 要绘制的字符串。 |
| font | Font | [`Font`](../../font/)定义字符串的文本格式。 |
| brush | Brush | [`Brush`](../../brush/)确定绘制文本的颜色和纹理。 |
| x | Single | 绘制文本左上角的 x 坐标。 |
| y | Single | 绘制文本左上角的 y 坐标。 |
| format | StringFormat | [`StringFormat`](../../stringformat/)指定应用于绘制文本的格式属性，例如行间距和对齐方式。 |

### 例外

| 例外 | （健康）状况 |
| --- | --- |
| ArgumentNullException | *brush*为空。 -或- *s*一片空白。 |

### 也可以看看

* class [Font](../../font/)
* class [Brush](../../brush/)
* class [StringFormat](../../stringformat/)
* class [Graphics](../)
* 命名空间 [Aspose.PSD](../../graphics/)
* 部件 [Aspose.PSD](../../../)

---

## DrawString(string, Font, Brush, PointF, StringFormat) {#drawstring_1}

在指定位置用指定的字符绘制指定的文本字符串[`Brush`](../../brush/)和[`Font`](../../font/)使用指定格式属性的对象[`StringFormat`](../../stringformat/) .

```csharp
public void DrawString(string s, Font font, Brush brush, PointF point, StringFormat format)
```

| 范围 | 类型 | 描述 |
| --- | --- | --- |
| s | String | 要绘制的字符串。 |
| font | Font | [`Font`](../../font/)定义字符串的文本格式。 |
| brush | Brush | [`Brush`](../../brush/)确定绘制文本的颜色和纹理。 |
| point | PointF | [`PointF`](../../pointf/)指定绘制文本左上角的结构。 |
| format | StringFormat | [`StringFormat`](../../stringformat/)指定应用于绘制文本的格式属性，例如行间距和对齐方式。 |

### 例外

| 例外 | （健康）状况 |
| --- | --- |
| ArgumentNullException | *brush*为空。 -或- *s*一片空白。 |

### 也可以看看

* class [Font](../../font/)
* class [Brush](../../brush/)
* struct [PointF](../../pointf/)
* class [StringFormat](../../stringformat/)
* class [Graphics](../)
* 命名空间 [Aspose.PSD](../../graphics/)
* 部件 [Aspose.PSD](../../../)

---

## DrawString(string, Font, Brush, RectangleF) {#drawstring_2}

在指定矩形内绘制指定文本字符串[`Brush`](../../brush/)和[`Font`](../../font/)对象.

```csharp
public void DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle)
```

| 范围 | 类型 | 描述 |
| --- | --- | --- |
| s | String | 要绘制的字符串。 |
| font | Font | [`Font`](../../font/)定义字符串的文本格式。 |
| brush | Brush | [`Brush`](../../brush/)确定绘制文本的颜色和纹理。 |
| layoutRectangle | RectangleF | [`RectangleF`](../../rectanglef/)指定绘制文本位置的结构。 |

### 例外

| 例外 | （健康）状况 |
| --- | --- |
| ArgumentNullException | *brush*为空。 -或- *s*一片空白。 |

### 也可以看看

* class [Font](../../font/)
* class [Brush](../../brush/)
* struct [RectangleF](../../rectanglef/)
* class [Graphics](../)
* 命名空间 [Aspose.PSD](../../graphics/)
* 部件 [Aspose.PSD](../../../)

---

## DrawString(string, Font, Brush, RectangleF, StringFormat) {#drawstring_3}

在指定矩形内绘制指定文本字符串[`Brush`](../../brush/)和[`Font`](../../font/)使用指定格式属性的对象[`StringFormat`](../../stringformat/) .

```csharp
public void DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle, 
    StringFormat format)
```

| 范围 | 类型 | 描述 |
| --- | --- | --- |
| s | String | 要绘制的字符串。 |
| font | Font | [`Font`](../../font/)定义字符串的文本格式。 |
| brush | Brush | [`Brush`](../../brush/)确定绘制文本的颜色和纹理。 |
| layoutRectangle | RectangleF | [`RectangleF`](../../rectanglef/)指定绘制文本位置的结构。 |
| format | StringFormat | [`StringFormat`](../../stringformat/)指定应用于绘制文本的格式属性，例如行间距和对齐方式。 |

### 例外

| 例外 | （健康）状况 |
| --- | --- |
| ArgumentNullException | *brush*为空。 -或- *s*为空。 -或- *brush*一片空白。 |

### 也可以看看

* class [Font](../../font/)
* class [Brush](../../brush/)
* struct [RectangleF](../../rectanglef/)
* class [StringFormat](../../stringformat/)
* class [Graphics](../)
* 命名空间 [Aspose.PSD](../../graphics/)
* 部件 [Aspose.PSD](../../../)


