Exemplo n.º 1
0
        /// <summary>
        ///     Read the font directory entry.
        /// </summary>
        /// <param name="lpRes">Pointer in memory.</param>
        /// <returns>Pointer to the end of the font directory entry.</returns>
        internal IntPtr Read(IntPtr lpRes)
        {
            var lpHead = lpRes;

            _fontOrdinal = (UInt16)Marshal.ReadInt16(lpRes);
            lpRes        = new IntPtr(lpRes.ToInt32() + 2);

            _font = (FontDirEntry)Marshal.PtrToStructure(lpRes, typeof(FontDirEntry));

            lpRes = new IntPtr(lpRes.ToInt32() + Marshal.SizeOf(_font));

            _deviceName = Marshal.PtrToStringAnsi(lpRes);
            lpRes       = new IntPtr(lpRes.ToInt32() + _deviceName.Length + 1);

            _faceName = Marshal.PtrToStringAnsi(lpRes);
            lpRes     = new IntPtr(lpRes.ToInt32() + _faceName.Length + 1);

            return(lpRes);
        }
Exemplo n.º 2
0
        /// <summary>Get all fonts from directory</summary>
        /// <returns>Fonts from directory</returns>
        public IEnumerator <FontDirEntry> GetEnumerator()
        {
            UInt16 numberOfFonts = this.NumberOfFonts;

            if (numberOfFonts > 0)
            {
                UInt32 padding = sizeof(UInt16);
                using (PinnedBufferReader reader = base.CreateDataReader())
                    for (UInt16 loop = 0; loop < numberOfFonts; loop++)
                    {
                        FontDirEntry entry = new FontDirEntry()
                        {
                            fontOrdinal = reader.BytesToStructure <UInt16>(ref padding),
                        };
                        ResourceFont.GetFont(reader, ref entry, ref padding);
                        yield return(entry);
                    }
            }
        }
        /// <summary>
        ///     Read the font directory entry.
        /// </summary>
        /// <param name="lpRes">Pointer in memory.</param>
        /// <returns>Pointer to the end of the font directory entry.</returns>
        internal IntPtr Read(IntPtr lpRes) {
            var lpHead = lpRes;

            _fontOrdinal = (UInt16)Marshal.ReadInt16(lpRes);
            lpRes = new IntPtr(lpRes.ToInt32() + 2);

            _font = (FontDirEntry)Marshal.PtrToStructure(lpRes, typeof (FontDirEntry));

            lpRes = new IntPtr(lpRes.ToInt32() + Marshal.SizeOf(_font));

            _deviceName = Marshal.PtrToStringAnsi(lpRes);
            lpRes = new IntPtr(lpRes.ToInt32() + _deviceName.Length + 1);

            _faceName = Marshal.PtrToStringAnsi(lpRes);
            lpRes = new IntPtr(lpRes.ToInt32() + _faceName.Length + 1);

            return lpRes;
        }