Пример #1
0
 public unsafe void EnumFont_Arial()
 {
     using (var context = GdiMethods.GetDeviceContext(WindowMethods.GetDesktopWindow()))
     {
         var info = GdiMethods.EnumerateFontFamilies(context, CharacterSet.ANSI_CHARSET, "Arial");
         info.Count().Should().Be(4);
         var regular = info.First();
         regular.FontAttributes.elfEnumLogfontEx.elfFullName.CreateString().Should().Be("Arial");
         regular.FontAttributes.elfEnumLogfontEx.elfStyle.CreateString().Should().Be("Regular");
         regular.FontAttributes.elfEnumLogfontEx.elfScript.CreateString().Should().Be("Western");
         regular.TextMetrics.ntmTm.ntmFlags.Should().Be(TextMetricFlags.NTM_REGULAR | TextMetricFlags.NTM_TT_OPENTYPE | TextMetricFlags.NTM_DSIG);
         regular.TextMetrics.ntmTm.tmPitchAndFamily.PitchTypes.Should().Be(FontPitchTypes.VariablePitch | FontPitchTypes.TrueType | FontPitchTypes.Vector);
         regular.TextMetrics.ntmTm.tmPitchAndFamily.Family.Should().Be(FontFamily.Swiss);
         regular.TextMetrics.ntmFontSig.UnicodeSubsetsOne.Should().Be(
             UnicodeSubsetsOne.BasicLatin | UnicodeSubsetsOne.Latin1Supplement | UnicodeSubsetsOne.LatinExtendedA | UnicodeSubsetsOne.LatinExtendedB
             | UnicodeSubsetsOne.IPAPhoneticExtensions | UnicodeSubsetsOne.SpacingToneModifier | UnicodeSubsetsOne.CombiningDiacriticalMarks
             | UnicodeSubsetsOne.GreekAndCoptic | UnicodeSubsetsOne.Cyrillic | UnicodeSubsetsOne.Armenian | UnicodeSubsetsOne.Hebrew
             | UnicodeSubsetsOne.Arabic | UnicodeSubsetsOne.LatinExtendedAdditionalCD | UnicodeSubsetsOne.GreekExtended | UnicodeSubsetsOne.Punctuation);
         regular.TextMetrics.ntmFontSig.UnicodeSubsetsFour.Should().Be((UnicodeSubsetsFour)0);
         regular.TextMetrics.ntmFontSig.CodePagesOem.Should().Be(CodePagesOem.ModernGreek | CodePagesOem.Russian | CodePagesOem.Nordic
                                                                 | CodePagesOem.Arabic | CodePagesOem.CanadianFrench | CodePagesOem.Hebrew | CodePagesOem.Icelandic | CodePagesOem.Portugese
                                                                 | CodePagesOem.Turkish | CodePagesOem.Cyrillic | CodePagesOem.Latin2 | CodePagesOem.Baltic | CodePagesOem.Greek
                                                                 | CodePagesOem.ArabicAsmo | CodePagesOem.MuiltilingualLatin | CodePagesOem.US);
     }
 }
Пример #2
0
 public void EnumFont_All()
 {
     // Just making sure we don't fall over
     using (var context = GdiMethods.GetDeviceContext(WindowMethods.GetDesktopWindow()))
     {
         GdiMethods.EnumerateFontFamilies(context, CharacterSet.DEFAULT_CHARSET, null).Should().NotBeEmpty();
     }
 }
Пример #3
0
        public void GetDeviceContext_NullWindow()
        {
            // Null here should be the entire screen
            DeviceContext context = GdiMethods.GetDeviceContext(WindowHandle.Null);

            context.IsInvalid.Should().BeFalse();
            int pixelWidth  = GdiMethods.GetDeviceCapability(context, DeviceCapability.HORZRES);
            int pixelHeight = GdiMethods.GetDeviceCapability(context, DeviceCapability.VERTRES);
        }
Пример #4
0
 public static DeviceContext GetDeviceContext(this WindowHandle window) => GdiMethods.GetDeviceContext(window);