Exemple #1
0
        /// <summary>
        /// Unregisters a font file loader that was previously registered with the DirectWrite font system using {{RegisterFontFileLoader}}.
        /// </summary>
        /// <remarks>
        /// This function unregisters font file loader callbacks with the DirectWrite font system. You should implement the font file loader interface by a singleton object. Note that font file loader implementations must not register themselves with DirectWrite inside their constructors and must not unregister themselves in their destructors, because registration and unregistraton operations increment and decrement the object reference count respectively. Instead, registration and unregistration of font file loaders with DirectWrite should be performed outside of the font file loader implementation.
        /// </remarks>
        /// <param name="fontFileLoader">Pointer to the file loader that was previously registered with the DirectWrite font system using {{RegisterFontFileLoader}}. </param>
        /// <returns>If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. </returns>
        /// <unmanaged>HRESULT IDWriteFactory::UnregisterFontFileLoader([None] IDWriteFontFileLoader* fontFileLoader)</unmanaged>
        public void UnregisterFontFileLoader(FontFileLoader fontFileLoader)
        {
            if (!_fontFileLoaderCallbacks.Contains(fontFileLoader))
            {
                throw new ArgumentException("This font file loader is not registered", "FontFileLoader");
            }

            UnregisterFontFileLoader_(FontFileLoaderShadow.ToIntPtr(fontFileLoader));
            _fontFileLoaderCallbacks.Remove(fontFileLoader);
        }
Exemple #2
0
 /// <summary>
 /// Creates a reference to an application-specific font file resource.
 /// </summary>
 /// <param name="factory">A reference to a DirectWrite factory <see cref="Factory"/></param>
 /// <param name="fontFileReferenceKey">A font file reference key that uniquely identifies the font file resource during the lifetime of fontFileLoader.</param>
 /// <param name="fontFileReferenceKeySize">The size of the font file reference key in bytes.</param>
 /// <param name="fontFileLoader">The font file loader that will be used by the font system to load data from the file identified by fontFileReferenceKey.</param>
 /// <remarks>
 /// This function is provided for cases when an application or a document needs to use a private font without having to install it on the system. fontFileReferenceKey has to be unique only in the scope of the fontFileLoader used in this call.
 /// </remarks>
 /// <unmanaged>HRESULT IDWriteFactory::CreateCustomFontFileReference([In, Buffer] const void* fontFileReferenceKey,[None] int fontFileReferenceKeySize,[None] IDWriteFontFileLoader* fontFileLoader,[Out] IDWriteFontFile** fontFile)</unmanaged>
 public FontFile(Factory factory, IntPtr fontFileReferenceKey, int fontFileReferenceKeySize, FontFileLoader fontFileLoader)
 {
     factory.CreateCustomFontFileReference_(fontFileReferenceKey, fontFileReferenceKeySize, FontFileLoaderShadow.ToIntPtr(fontFileLoader), this);
 }
Exemple #3
0
 /// <summary>
 /// Registers a font file loader with DirectWrite.
 /// </summary>
 /// <remarks>
 /// This function registers a font file loader with DirectWrite. The font file loader interface, which should be implemented   by a singleton object, handles loading font file resources of a particular type from a key. A given instance can only be registered once. Succeeding attempts will return an error, indicating that it has already been registered. Note that font file loader implementations must not register themselves with DirectWrite inside their constructors, and must not unregister themselves inside their destructors, because registration and unregistraton operations increment and decrement the object reference count respectively. Instead, registration and unregistration with DirectWrite of font file loaders should be performed outside of the font file loader implementation.
 /// </remarks>
 /// <param name="fontFileLoader">Pointer to a <see cref="SharpDX.DirectWrite.FontFileLoader"/> object for a particular file resource type. </param>
 /// <returns>If the method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. </returns>
 /// <unmanaged>HRESULT IDWriteFactory::RegisterFontFileLoader([None] IDWriteFontFileLoader* fontFileLoader)</unmanaged>
 public void RegisterFontFileLoader(FontFileLoader fontFileLoader)
 {
     this.RegisterFontFileLoader_(FontFileLoaderShadow.ToIntPtr(fontFileLoader));
     _fontFileLoaderCallbacks.Add(fontFileLoader);
 }