FileFontSource
İçindekiler
[
Saklamak
]FileFontSource(string)
Ctor.
public FileFontSource(string filePath)
Parametre | Tip | Tanım |
---|---|---|
filePath | String | Yazı tipi dosyasının yolu. |
Örnekler
Yerel dosya sistemindeki bir yazı tipi dosyasının yazı tipi kaynağı olarak nasıl kullanılacağını gösterir.
FileFontSource fileFontSource = new FileFontSource(MyDir + "Alte DIN 1451 Mittelschrift.ttf", 0);
Document doc = new Document();
doc.FontSettings = new FontSettings();
doc.FontSettings.SetFontsSources(new FontSourceBase[] {fileFontSource});
Assert.AreEqual(MyDir + "Alte DIN 1451 Mittelschrift.ttf", fileFontSource.FilePath);
Assert.AreEqual(FontSourceType.FontFile, fileFontSource.Type);
Assert.AreEqual(0, fileFontSource.Priority);
Ayrıca bakınız
- class FileFontSource
- ad alanı Aspose.Words.Fonts
- toplantı Aspose.Words
FileFontSource(string, int)
Ctor.
public FileFontSource(string filePath, int priority)
Parametre | Tip | Tanım |
---|---|---|
filePath | String | Yazı tipi dosyasının yolu. |
priority | Int32 | Yazı tipi kaynağı önceliği. Bkz.Priority Daha fazla bilgi için özellik açıklaması. |
Örnekler
Yerel dosya sistemindeki bir yazı tipi dosyasının yazı tipi kaynağı olarak nasıl kullanılacağını gösterir.
FileFontSource fileFontSource = new FileFontSource(MyDir + "Alte DIN 1451 Mittelschrift.ttf", 0);
Document doc = new Document();
doc.FontSettings = new FontSettings();
doc.FontSettings.SetFontsSources(new FontSourceBase[] {fileFontSource});
Assert.AreEqual(MyDir + "Alte DIN 1451 Mittelschrift.ttf", fileFontSource.FilePath);
Assert.AreEqual(FontSourceType.FontFile, fileFontSource.Type);
Assert.AreEqual(0, fileFontSource.Priority);
Ayrıca bakınız
- class FileFontSource
- ad alanı Aspose.Words.Fonts
- toplantı Aspose.Words
FileFontSource(string, int, string)
Ctor.
public FileFontSource(string filePath, int priority, string cacheKey)
Parametre | Tip | Tanım |
---|---|---|
filePath | String | Yazı tipi dosyasının yolu. |
priority | Int32 | Yazı tipi kaynağı önceliği. Bkz.Priority Daha fazla bilgi için özellik açıklaması. |
cacheKey | String | Bu kaynağın anahtarı önbellektedir. GörmekCacheKey Daha fazla bilgi için özellik açıklaması. |
Örnekler
Yazı tipi önbelleği başlatma işleminin nasıl hızlandırılacağını gösterir.
public void LoadFontSearchCache()
{
const string cacheKey1 = "Arvo";
const string cacheKey2 = "Arvo-Bold";
FontSettings parsedFonts = new FontSettings();
FontSettings loadedCache = new FontSettings();
parsedFonts.SetFontsSources(new FontSourceBase[]
{
new FileFontSource(FontsDir + "Arvo-Regular.ttf", 0, cacheKey1),
new FileFontSource(FontsDir + "Arvo-Bold.ttf", 0, cacheKey2)
});
using (MemoryStream cacheStream = new MemoryStream())
{
parsedFonts.SaveSearchCache(cacheStream);
loadedCache.SetFontsSources(new FontSourceBase[]
{
new SearchCacheStream(cacheKey1),
new MemoryFontSource(File.ReadAllBytes(FontsDir + "Arvo-Bold.ttf"), 0, cacheKey2)
}, cacheStream);
}
Assert.AreEqual(parsedFonts.GetFontsSources().Length, loadedCache.GetFontsSources().Length);
}
/// <summary>
/// Yazı tipi verilerini belleğe kaydetmek yerine yalnızca gerektiğinde yükleyin
/// "FontSettings" nesnesinin tüm ömrü boyunca.
/// </summary>
private class SearchCacheStream : StreamFontSource
{
public SearchCacheStream(string cacheKey):base(0, cacheKey)
{
}
public override Stream OpenFontDataStream()
{
return File.OpenRead(FontsDir + "Arvo-Regular.ttf");
}
}
Ayrıca bakınız
- class FileFontSource
- ad alanı Aspose.Words.Fonts
- toplantı Aspose.Words