public static void SetFactory(IDWriteFontCollectionLoader loader, IDWriteFactory factory) { IntPtr shadowPtr = ToCallbackPtr <IDWriteFontCollectionLoader>(loader); IDWriteFontCollectionLoaderShadow shadow = ToShadow <IDWriteFontCollectionLoaderShadow>(shadowPtr); shadow._factory = factory; }
private static int CreateEnumeratorFromKeyImpl(IntPtr thisPtr, IntPtr factory, IntPtr collectionKey, int collectionKeySize, out IntPtr fontFileEnumerator) { fontFileEnumerator = IntPtr.Zero; try { IDWriteFontCollectionLoaderShadow shadow = ToShadow <IDWriteFontCollectionLoaderShadow>(thisPtr); IDWriteFontCollectionLoader callback = (IDWriteFontCollectionLoader)shadow.Callback; Debug.Assert(factory == shadow._factory.NativePointer); IDWriteFontFileEnumerator enumerator = callback.CreateEnumeratorFromKey(shadow._factory, collectionKey, collectionKeySize); fontFileEnumerator = IDWriteFontFileEnumeratorShadow.ToIntPtr(enumerator); } catch (Exception exception) { return((int)Result.GetResultFromException(exception)); } return(Result.Ok.Code); }
/// <summary> /// Registers a custom font collection loader with the factory object. /// </summary> /// <param name="fontCollectionLoader">Reference to a <see cref="IDWriteFontCollectionLoader"/> object to be registered.</param> public void RegisterFontCollectionLoader(IDWriteFontCollectionLoader fontCollectionLoader) { IDWriteFontCollectionLoaderShadow.SetFactory(fontCollectionLoader, this); RegisterFontCollectionLoader_(fontCollectionLoader); _fontCollectionLoaderCallbacks.Add(fontCollectionLoader); }