Ejemplo n.º 1
0
        /// <summary>
        /// Function to get the ABC kerning widths for the active font object.
        /// </summary>
        /// <param name="firstCharacter">First character to return.</param>
        /// <param name="lastCharacter">Last character to return.</param>
        /// <returns>A list of font ABC values.</returns>
        public static Dictionary <char, ABC> GetCharABCWidths(char firstCharacter, char lastCharacter)
        {
            uint firstCharIndex = Convert.ToUInt32(firstCharacter);
            uint lastCharIndex  = Convert.ToUInt32(lastCharacter);
            int  size           = (int)(lastCharIndex - firstCharIndex) + 1;
            var  result         = new Dictionary <char, ABC>();

            if (_hdc == IntPtr.Zero)
            {
                throw new GorgonException(GorgonResult.CannotEnumerate, Resources.GORGFX_ERR_FONT_CANNOT_RETRIEVE_ABC);
            }

            ABC *abcData = stackalloc ABC[size];

            if (!GetCharABCWidthsW(_hdc, firstCharIndex, lastCharIndex, abcData))
            {
                throw new GorgonException(GorgonResult.CannotEnumerate, Resources.GORGFX_ERR_FONT_CANNOT_RETRIEVE_ABC);
            }

            // Copy to our result.
            for (int i = 0; i < size; i++)
            {
                result.Add(Convert.ToChar(i + Convert.ToInt32(firstCharacter)), abcData[i]);
            }

            return(result);
        }
Ejemplo n.º 2
0
 private static extern bool GetCharABCWidthsW(IntPtr HDC, uint uFirstChar, uint uLastChar, ABC *lpABC);
Ejemplo n.º 3
0
 public static extern unsafe bool GetCharABCWidthsW(IntPtr hdc, uint uFirstChar, uint uLastChar, ABC *lpabc);