private static void EnumFonts(IDWriteFontCollection coll) { var count = coll.GetFontFamilyCount(); var locale = System.Globalization.CultureInfo.CurrentCulture.Name; for (var i = 0U; i < count; i++) { try { using var pFontFam = ComReleaserFactory.Create(coll.GetFontFamily(i)); using var pFamNames = ComReleaserFactory.Create(pFontFam.Item.GetFamilyNames()); pFamNames.Item.FindLocaleName(locale, out var index, out var exists); if (!exists) { index = 0; } var len = pFamNames.Item.GetStringLength(index) + 1; var str = new StringBuilder((int)len); pFamNames.Item.GetString(index, str, len); TestContext.WriteLine(str); } catch (Exception ex) { TestContext.WriteLine("ERROR: " + ex.Message); } } }
public FontCollection GetSystemFontCollection(bool checkForUpdates) { IDWriteFontCollection dwriteFontCollection = null; _pFactory.GetSystemFontCollection(out dwriteFontCollection, checkForUpdates); return(new FontCollection(dwriteFontCollection)); }
public unsafe IDWriteFont CreateFontFromLOGFONT(LogFont logFont, IDWriteFontCollection fontCollection) { int sizeOfLogFont = Marshal.SizeOf(logFont); byte *nativeLogFont = stackalloc byte[sizeOfLogFont]; Marshal.StructureToPtr(logFont, new IntPtr(nativeLogFont), false); return(CreateFontFromLOGFONT(new IntPtr(nativeLogFont), fontCollection)); }
public static IComObject <IDWriteTextFormat> CreateTextFormat(this IComObject <IDWriteFactory> factory, string familyName, float size, IDWriteFontCollection fonts = null, DWRITE_FONT_WEIGHT weight = DWRITE_FONT_WEIGHT.DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE style = DWRITE_FONT_STYLE.DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH stretch = DWRITE_FONT_STRETCH.DWRITE_FONT_STRETCH_NORMAL, string localeName = null) => CreateTextFormat <IDWriteTextFormat>(factory?.Object, familyName, size, fonts, weight, style, stretch, localeName);
public IDWriteTextFormat CreateTextFormat( string fontFamilyName, IDWriteFontCollection fontCollection, FontWeight fontWeight, FontStyle fontStyle, FontStretch fontStretch, float fontSize) { return(CreateTextFormat(fontFamilyName, fontCollection, fontWeight, fontStyle, fontStretch, fontSize, "")); }
unsafe public FontCollection GetFontCollection(Uri uri) { string uriString = uri.AbsoluteUri; IDWriteFontCollection dwriteFontCollection = null; fixed(char *pUriString = uriString) { dwriteFontCollection = _pFactory.CreateCustomFontCollection( WpfFontCollectionLoader, new IntPtr(pUriString), (uint)(uriString.Length + 1) * 2 ); } return(new FontCollection(dwriteFontCollection)); }
public static IReadOnlyList <IDWriteFontFamily> GetFamilies(this IDWriteFontCollection collection) { if (collection == null) { throw new ArgumentNullException(nameof(collection)); } var list = new List <IDWriteFontFamily>((int)collection.GetFontFamilyCount()); for (var i = 0; i < list.Capacity; i++) { collection.GetFontFamily((uint)i, out var family).ThrowOnError(); list.Add(family); } return(list); }
public static IComObject <T> CreateTextFormat <T>(this IDWriteFactory factory, string familyName, float size, IDWriteFontCollection fonts = null, DWRITE_FONT_WEIGHT weight = DWRITE_FONT_WEIGHT.DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE style = DWRITE_FONT_STYLE.DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH stretch = DWRITE_FONT_STRETCH.DWRITE_FONT_STRETCH_NORMAL, string localeName = null) where T : IDWriteTextFormat { if (factory == null) { throw new ArgumentNullException(nameof(factory)); } if (familyName == null) { throw new ArgumentNullException(nameof(familyName)); } localeName = localeName ?? string.Empty; factory.CreateTextFormat(familyName, fonts, weight, style, stretch, size, localeName, out var format).ThrowOnError(); return(new ComObject <T>((T)format)); }
internal DWriteFontCollection(IDWriteFontCollection handle) { this.handle = handle; }
public FontCollection(IDWriteFontCollection fontCollection) { _fontCollection = fontCollection; }