Ejemplo n.º 1
0
        /// <summary>
        /// Draws a string at a specified location.
        /// </summary>
        /// <param name="str">The string to draw..</param>
        /// <param name="X">The X location to draw it at.</param>
        /// <param name="Y">The Y location to draw it at.</param>
        /// <param name="color">The color.</param>
        /// <param name="vbo">The VBO to render with.</param>
        /// <param name="flip">Whether to flip text upside-down.</param>
        /// <returns>The length of the string in pixels.</returns>
        public float DrawString(string str, float X, float Y, Vector4 color, TextVBO vbo, bool flip = false)
        {
            IEnumerable <string> strs = SeparateEmojiAndSpecialChars(str).ToList();
            float nX = 0;

            if (flip)
            {
                foreach (string stri in strs)
                {
                    if (stri == "\n")
                    {
                        Y += Height;
                        nX = 0;
                    }
                    nX += DrawSingleCharacterFlipped(stri, X + nX, Y, vbo, color);
                }
            }
            else
            {
                foreach (string stri in strs)
                {
                    if (stri == "\n")
                    {
                        Y += Height;
                        nX = 0;
                    }
                    nX += DrawSingleCharacter(stri, X + nX, Y, vbo, color);
                }
            }
            return(nX);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Draws a single symbol at a specified location, flipped.
        /// </summary>
        /// <param name="symbol">The symbol to draw..</param>
        /// <param name="X">The X location to draw it at.</param>
        /// <param name="Y">The Y location to draw it at.</param>
        /// <param name="vbo">The VBO to render with.</param>
        /// <param name="color">The color.</param>
        /// <returns>The length of the character in pixels.</returns>
        public float DrawSingleCharacterFlipped(string symbol, float X, float Y, TextVBO vbo, Vector4 color)
        {
            RectangleF rec = RectForSymbol(symbol);

            vbo.AddQuad(X, Y, X + rec.Width, Y + rec.Height, rec.X / GLFontEngine.DEFAULT_TEXTURE_SIZE_WIDTH, rec.Y / GLFontEngine.DEFAULT_TEXTURE_SIZE_WIDTH,
                        (rec.X + rec.Width) / Engine.CurrentHeight, (rec.Y + rec.Height) / Engine.CurrentHeight, color);
            return(rec.Width);
        }