Duality.Resources.Font.LoadFontFamilyFromMemory C# (CSharp) Method

LoadFontFamilyFromMemory() private static method

Loads a System.Drawing.FontFamily from memory.
private static LoadFontFamilyFromMemory ( byte memory ) : FontFamily
memory byte The memory chunk to load the FontFamily from.
return System.Drawing.FontFamily
        private static FontFamily LoadFontFamilyFromMemory(byte[] memory)
        {
            FontFamily result = null;
            FontFamily[] familiesBefore = fontManager.Families.ToArray();

            GCHandle handle = GCHandle.Alloc(memory, GCHandleType.Pinned);
            try
            {
                IntPtr fontMemPtr = handle.AddrOfPinnedObject();
                fontManager.AddMemoryFont(fontMemPtr, memory.Length);
                result = fontManager.Families.Except(familiesBefore).FirstOrDefault();
            }
            finally
            {
                handle.Free();
            }

            loadedFontRegistry[result.Name] = result;
            return result;
        }