本文整理汇总了C#中Factory.GetSystemFontCollection方法的典型用法代码示例。如果您正苦于以下问题:C# Factory.GetSystemFontCollection方法的具体用法?C# Factory.GetSystemFontCollection怎么用?C# Factory.GetSystemFontCollection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Factory
的用法示例。
在下文中一共展示了Factory.GetSystemFontCollection方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFonts
// Code taken straight from SharpDX\Samples\DirectWrite\FontEnumeration\Program.cs
public static List<InstalledFont> GetFonts()
{
var fontList = new List<InstalledFont>();
var factory = new Factory();
var fontCollection = factory.GetSystemFontCollection(false);
var familyCount = fontCollection.FontFamilyCount;
for (int i = 0; i < familyCount; i++)
{
var fontFamily = fontCollection.GetFontFamily(i);
var familyNames = fontFamily.FamilyNames;
int index;
if (!familyNames.FindLocaleName(CultureInfo.CurrentCulture.Name, out index))
familyNames.FindLocaleName("en-us", out index);
string name = familyNames.GetString(index);
fontList.Add(new InstalledFont()
{
Name = name,
});
}
return fontList;
}
示例2: Main
private static void Main()
{
var factory = new Factory(FactoryType.Shared);
var fonts = (from f in factory.GetSystemFontCollection(true)
//where !f.GetFirstMatchingFont(FontWeight.Normal, FontStretch.Normal, FontStyle.Normal).IsSymbolFont
orderby f.FamilyNames.GetPreferedString()
select f).SelectMany(f => f.GetMatchingFonts(FontWeight.Normal, FontStretch.Normal, FontStyle.Normal)).ToArray();
foreach (var language in Languages)
{
var languageFonts = fonts.Where(f => CanShowSample(f, language.Value));
var result = GenerateLanguageFonts(language, languageFonts);
File.WriteAllText([email protected]"E:\\{language.Key.Replace(' ', '-').ToLowerInvariant()}.tex", result, Encoding.UTF8);
}
}
示例3: SetFontEnum
public static void SetFontEnum(IHDEHost host, DWriteFactory dwfactory)
{
Factory f = new Factory(dwfactory.ComPointer);
var fontCollection = f.GetSystemFontCollection(false);
List<string> familyNames = new List<string>();
for (int i = 0; i < fontCollection.FontFamilyCount; i++)
{
var family = fontCollection.GetFontFamily(i);
if (family.FamilyNames.Count > 0)
{
familyNames.Add(family.FamilyNames.GetString(0));
}
}
familyNames.Sort();
host.UpdateEnum("DirectWrite_Font_Families", "Arial", familyNames.ToArray());
}
示例4: Main
static void Main(string[] args)
{
Console.WriteLine("Press enter to exit");
var factory = new Factory();
var fontCollection = factory.GetSystemFontCollection(false);
var familyCount = fontCollection.FontFamilyCount;
for (int i = 0; i < familyCount; i++)
{
var fontFamily = fontCollection.GetFontFamily(i);
var familyNames = fontFamily.FamilyNames;
int index;
if (!familyNames.FindLocaleName(CultureInfo.CurrentCulture.Name, out index))
familyNames.FindLocaleName("en-us", out index);
string name = familyNames.GetString(index);
Console.WriteLine(name);
var fontCount = fontFamily.FontCount;
for (int fontIndex = 0; fontIndex < fontCount; fontIndex++)
{
var font = fontFamily.GetFont(fontIndex);
var fontFace = new FontFace(font);
var files = fontFace.GetFiles();
foreach (var file in files)
{
var referenceKey = file.GetReferenceKey();
var originalLoader = (FontFileLoaderNative)file.Loader;
var loader = originalLoader.QueryInterface<LocalFontFileLoader>();
var fontFilePath = loader.GetFilePath(referenceKey);
Console.WriteLine("\tFile path: {0}", fontFilePath);
}
}
}
Console.WriteLine("Press enter to exit");
Console.In.ReadLine();
}
示例5: Main
static void Main(string[] args)
{
Console.WriteLine("Press enter to exit");
var factory = new Factory();
var fontCollection = factory.GetSystemFontCollection(false);
var familyCount = fontCollection.FontFamilyCount;
for (int i = 0; i < familyCount; i++)
{
var fontFamily = fontCollection.GetFontFamily(i);
var familyNames = fontFamily.FamilyNames;
int index;
if (!familyNames.FindLocaleName(CultureInfo.CurrentCulture.Name, out index))
familyNames.FindLocaleName("en-us", out index);
string name = familyNames.GetString(index);
Console.WriteLine(name);
}
Console.WriteLine("Press enter to exit");
Console.In.ReadLine();
}
示例6: GetFontFaceFromSystemFonts
private FontFace GetFontFaceFromSystemFonts(Factory factory, SpriteFontAsset options)
{
SharpDX.DirectWrite.Font font;
using (var fontCollection = factory.GetSystemFontCollection(false))
{
int index;
if (!fontCollection.FindFamilyName(options.FontName, out index))
{
// Lets try to import System.Drawing for old system bitmap fonts (like MS Sans Serif)
throw new FontNotFoundException(options.FontName);
}
using (var fontFamily = fontCollection.GetFontFamily(index))
{
var weight = options.Style.IsBold()? FontWeight.Bold: FontWeight.Regular;
var style = options.Style.IsItalic() ? SharpDX.DirectWrite.FontStyle.Italic : SharpDX.DirectWrite.FontStyle.Normal;
font = fontFamily.GetFirstMatchingFont(weight, FontStretch.Normal, style);
}
}
return new FontFace(font);
}