mirror of
https://github.com/ckaczor/Common.Wpf.git
synced 2026-01-14 01:25:37 -05:00
Initial commit
This commit is contained in:
43
Extensions/FontExtensions.cs
Normal file
43
Extensions/FontExtensions.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace Common.Wpf.Extensions
|
||||
{
|
||||
public static class FontExtensions
|
||||
{
|
||||
public static bool IsComposite(FontFamily fontFamily)
|
||||
{
|
||||
return fontFamily.Source.StartsWith("Global");
|
||||
}
|
||||
|
||||
public static bool IsSymbol(FontFamily fontFamily)
|
||||
{
|
||||
Typeface typeface = fontFamily.GetTypefaces().First();
|
||||
GlyphTypeface glyph;
|
||||
typeface.TryGetGlyphTypeface(out glyph);
|
||||
return glyph.Symbol;
|
||||
}
|
||||
|
||||
public static bool IsVisible(FontFamily fontFamily)
|
||||
{
|
||||
return !IsHidden(fontFamily);
|
||||
}
|
||||
|
||||
public static bool IsHidden(FontFamily fontFamily)
|
||||
{
|
||||
const string fontManagementKey = @"Software\Microsoft\Windows NT\CurrentVersion\Font Management";
|
||||
const string inactiveFontsValue = "Inactive Fonts";
|
||||
|
||||
RegistryKey key = Registry.CurrentUser.OpenSubKey(fontManagementKey);
|
||||
|
||||
if (key == null)
|
||||
return false;
|
||||
|
||||
IEnumerable<string> hiddenFonts = (string[]) key.GetValue(inactiveFontsValue);
|
||||
|
||||
return hiddenFonts.Contains(fontFamily.Source);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user