ConvertFont() public static method

Converts the font out of an OpenGLFont object.
public static ConvertFont ( OpenGLFont font ) : Font
font OpenGLFont The OpenGLFont.
return System.Drawing.Font
示例#1
0
        /// <summary>
        /// Initializes a new TextEntity class.
        /// </summary>
        /// <param name="text">The Text.</param>
        /// <param name="font">The Font.</param>
        /// <param name="color">The Color.</param>
        /// <param name="wrapWidth">The Wordwrap Width.</param>
        public TextEntity(string text, OpenGLFont font, Color color, int wrapWidth = 0)
        {
            if (wrapWidth > 0)
            {
                text = text.WordWrap(wrapWidth);
            }
            var gdiFont = OpenGLHelper.ConvertFont(font);

            Id     = text.GetHashCode() + gdiFont.GetHashCode() + color.GetHashCode();
            _text  = text;
            _font  = gdiFont;
            _color = color;
        }
示例#2
0
        /// <summary>
        /// Measures the string.
        /// </summary>
        /// <param name="text">The String.</param>
        /// <param name="font">The Font.</param>
        /// <returns>Vector2.</returns>
        public Vector2 MeasureString(string text, IFont font)
        {
            var oglFont = font as OpenGLFont;

            if (oglFont == null)
            {
                throw new ArgumentException("Expected a OpenGLFont as resource.");
            }

            System.Drawing.Font gdiFont = OpenGLHelper.ConvertFont(oglFont);
            Size result = TextRenderer.MeasureText(text, gdiFont);

            return(new Vector2(result.Width, result.Height));
        }