public static void SetFactory(IDWriteFontCollectionLoader loader, IDWriteFactory factory)
        {
            var shadowPtr = ToIntPtr(loader);
            var shadow    = ToShadow <IDWriteFontCollectionLoaderShadow>(shadowPtr);

            shadow._factory = factory;
        }
Beispiel #2
0
        public static void SetFactory(IDWriteFontCollectionLoader loader, IDWriteFactory factory)
        {
            IntPtr shadowPtr = ToCallbackPtr <IDWriteFontCollectionLoader>(loader);
            IDWriteFontCollectionLoaderShadow shadow = ToShadow <IDWriteFontCollectionLoaderShadow>(shadowPtr);

            shadow._factory = factory;
        }
 /// <summary>
 /// Unregisters a custom font collection loader that was previously registered using <see cref="RegisterFontCollectionLoader"/>	method.
 /// </summary>
 /// <param name="fontCollectionLoader">Instance of <see cref="IDWriteFontCollectionLoader"/> object to be unregistered.</param>
 public void UnregisterFontCollectionLoader(IDWriteFontCollectionLoader fontCollectionLoader)
 {
     if (!_fontCollectionLoaderCallbacks.Contains(fontCollectionLoader))
     {
         throw new ArgumentException("This font collection loader is not registered", "fontCollectionLoader");
     }
     UnregisterFontCollectionLoader_(fontCollectionLoader);
     _fontCollectionLoaderCallbacks.Remove(fontCollectionLoader);
 }
Beispiel #4
0
            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);
 }
 public static IntPtr ToIntPtr(IDWriteFontCollectionLoader loader) => ToCallbackPtr <IDWriteFontCollectionLoader>(loader);