当前位置: 首页>>代码示例>>C#>>正文


C# Factory.GetSystemFontCollection方法代码示例

本文整理汇总了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;
        }
开发者ID:robert-virkus,项目名称:winrt-snippets,代码行数:27,代码来源:InstalledFont.cs

示例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);
            }
        }
开发者ID:EFanZh,项目名称:EFanZh,代码行数:17,代码来源:Program.cs

示例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());
        }
开发者ID:dotprodukt,项目名称:dx11-vvvv,代码行数:18,代码来源:DirectWriteFontUtils.cs

示例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();
        }
开发者ID:MaybeMars,项目名称:SharpDX-Samples,代码行数:41,代码来源:Program.cs

示例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();
        }
开发者ID:leprosarium,项目名称:red-stone-simulator,代码行数:23,代码来源:Program.cs

示例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);
        }
开发者ID:releed,项目名称:paradox,代码行数:22,代码来源:TrueTypeImporter.cs


注:本文中的Factory.GetSystemFontCollection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。