Class FontRepository
内容
[
隐藏
]FontRepository class
执行字体搜索。在系统安装的字体和标准 Pdf 字体中进行搜索。还提供打开自定义字体的功能。
public sealed class FontRepository
Constructors
| Name | Description |
|---|---|
| FontRepository() | 默认构造函数。 |
Properties
| Name | Description |
|---|---|
| static Sources { get; } | 获取字体源集合。 |
| static Substitutions { get; } | 获取字体替代策略集合。 |
Methods
| Name | Description |
|---|---|
| static FindFont(string) | 搜索并返回指定字体名称的字体。 |
| static FindFont(string, bool) | 搜索并返回指定字体名称的字体,忽略或尊重大小写敏感性。 |
| static FindFont(string, FontStyles) | 搜索并返回指定字体名称和字体样式的字体。 |
| static FindFont(string, FontStyles, bool) | 搜索并返回指定字体名称和字体样式的字体,忽略或尊重大小写敏感性。 |
| static LoadFonts() | 加载系统安装的字体和标准 Pdf 字体。此方法旨在加快字体加载过程。默认情况下,字体在首次请求任何字体时加载。使用此方法会在打开任何 Pdf 文档之前立即加载系统和标准 Pdf 字体。 |
| static OpenFont(string) | 打开指定字体文件路径的字体。 |
| static OpenFont(Stream, FontTypes) | 打开指定字体流的字体。 |
| static OpenFont(string, string) | 打开指定字体文件路径和度量文件路径的字体。 |
| static ReloadFonts() | 重新加载由属性 Sources 指定的所有字体。 |
Examples
该示例演示如何查找字体并替换第一页文本的字体。
// Find font
Font font = FontRepository.FindFont("Arial");
// Open document
Document doc = new Document(@"D:\Tests\input.pdf");
// Create TextFragmentAbsorber object to find all "hello world" text occurrences
TextFragmentAbsorber absorber = new TextFragmentAbsorber("hello world");
// Accept the absorber for first page
doc.Pages[1].Accept(absorber);
// Change font of the first text occurrence
absorber.TextFragments[1].TextState.Font = font;
// Save document
doc.Save(@"D:\Tests\output.pdf");
See Also
- class TextFragmentAbsorber
- class Document
- namespace Aspose.Pdf.Text
- assembly Aspose.PDF