public static void CheckSimulatedFontStyles(Win32DCSafeHandle hdc, AspNetCore.ReportingServices.Rendering.RichText.Win32.TEXTMETRIC textMetric, ref bool simulateItalic, ref bool simulateBold)
 {
     simulateItalic = false;
     simulateBold   = false;
     if ((textMetric.tmPitchAndFamily & 4) == 4)
     {
         if (textMetric.tmWeight < 600 && textMetric.tmItalic <= 0)
         {
             return;
         }
         ushort num  = default(ushort);
         ushort num2 = default(ushort);
         if (FontPackage.GetWeightClassAndSelection(hdc, out num, out num2))
         {
             if (textMetric.tmItalic > 0 && (num2 & 1) == 0)
             {
                 simulateItalic = true;
             }
             if (textMetric.tmWeight >= 600 && num < textMetric.tmWeight)
             {
                 simulateBold = true;
             }
         }
     }
 }
        public static bool CheckEmbeddingRights(Win32DCSafeHandle hdc)
        {
            uint num = 0u;

            if (FontPackage.TTGetEmbeddingType(hdc, ref num) == 0)
            {
                return(num != 4);
            }
            return(false);
        }
        private static bool GetWeightClassAndSelection(Win32DCSafeHandle hdc, out ushort weightClass, out ushort selection)
        {
            weightClass = 0;
            selection   = 0;
            byte[] array    = new byte[64];
            uint   fontData = FontPackage.GetFontData(hdc, 841962319u, 0u, array, (uint)array.Length);

            if (fontData == array.Length)
            {
                weightClass = FontPackage.ToUInt16BigEndian(array, 4);
                selection   = FontPackage.ToUInt16BigEndian(array, 62);
                return(true);
            }
            return(false);
        }
        public static byte[] Generate(Win32DCSafeHandle hdc, string fontFamily, ushort[] glyphIdArray)
        {
            IntPtr intPtr = IntPtr.Zero;
            uint   num    = 0u;
            IntPtr zero   = IntPtr.Zero;
            uint   num2   = 0u;

            byte[] array = null;
            try
            {
                if (FontPackage.GetFontData(hdc, 1717793908u, 0u, IntPtr.Zero, 0u) == 4294967295u)
                {
                    num = FontPackage.GetFontData(hdc, 0u, 0u, IntPtr.Zero, 0u);
                    FontPackage.CheckGetFontDataResult(num);
                    intPtr = Marshal.AllocHGlobal((int)num);
                    uint fontData = FontPackage.GetFontData(hdc, 0u, 0u, intPtr, num);
                    FontPackage.CheckGetFontDataResult(fontData);
                }
                else
                {
                    byte[] tTCFontData = FontPackage.GetTTCFontData(hdc, ref num);
                    intPtr = Marshal.AllocHGlobal((int)num);
                    Marshal.Copy(tTCFontData, 0, intPtr, (int)num);
                }
                ushort usFlags = 9;
                uint   num3    = 0u;
                short  num4    = FontPackage.CreateFontPackage(intPtr, num, out zero, ref num2, ref num3, usFlags, (ushort)0, (ushort)0, (ushort)0, (ushort)3, (ushort)65535, glyphIdArray, (ushort)glyphIdArray.Length, (Delegate) new AllocateMemory(FontPackage.AllocateFontBufferMemory), (Delegate) new ReAllocateMemory(FontPackage.ReAllocateFontBufferMemory), (Delegate) new FreeMemory(FontPackage.FreeFontBufferMemory), IntPtr.Zero);
                if (num4 != 0)
                {
                    string source = string.Format(CultureInfo.InvariantCulture, "CreateFontPackage(fontFamily={0})", fontFamily);
                    FontPackage.ThrowNativeException(source, num4, false);
                }
                array = new byte[num3];
                Marshal.Copy(zero, array, 0, (int)num3);
                return(array);
            }
            finally
            {
                if (intPtr != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(intPtr);
                }
                if (zero != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(zero);
                }
            }
        }
        private static byte[] GetTTCFontData(Win32DCSafeHandle hdc, ref uint fontDataLength)
        {
            byte[] array = null;
            fontDataLength = 0u;
            byte[] array2   = null;
            byte[] array3   = new byte[2];
            uint   fontData = FontPackage.GetFontData(hdc, 0u, 4u, array3, 2u);

            FontPackage.CheckGetFontDataResult(fontData);
            ushort num  = BitConverter.ToUInt16(FontPackage.Swap(array3), 0);
            ushort num2 = (ushort)(12 + num * 16);

            array2   = new byte[num2];
            fontData = FontPackage.GetFontData(hdc, 0u, 0u, array2, num2);
            FontPackage.CheckGetFontDataResult(fontData);
            ArrayList arrayList = new ArrayList();
            uint      num3      = num2;

            for (int i = 0; i < num; i++)
            {
                byte[] array4 = new byte[16];
                Array.Copy(array2, 12 + i * 16, array4, 0, 16);
                DirectoryEntry directoryEntry = new DirectoryEntry(array4, i);
                num3 += directoryEntry.TableLength;
                arrayList.Add(directoryEntry);
            }
            array = new byte[num3];
            Array.Copy(array2, array, num2);
            fontDataLength += num2;
            arrayList.Sort(new CompareDirectoryEntryOffsets());
            foreach (DirectoryEntry item in arrayList)
            {
                byte[] array5 = new byte[item.TableLength];
                fontData = FontPackage.GetFontData(hdc, item.TableTag, 0u, array5, (uint)array5.Length);
                FontPackage.CheckGetFontDataResult(fontData);
                int    destinationIndex = 12 + item.DirectoryIndex * 16 + 8;
                byte[] array6           = FontPackage.Swap(BitConverter.GetBytes(fontDataLength));
                Array.Copy(array6, 0, array, destinationIndex, array6.Length);
                Array.Copy(array5, 0L, array, fontDataLength, array5.Length);
                fontDataLength += (uint)array5.Length;
            }
            return(array);
        }