Beispiel #1
0
        /// <summary>
        /// Takes a texture and applies some text to it.
        /// </summary>
        /// <param name="text">The text to texture.</param>
        /// <param name="font">The font of the text.</param>
        /// <param name="loadedTexture">The texture to be loaded on to.</param>
        /// <param name="background">The background of the text. (default: none/null)</param>
        public void GenOrUpdateTextTexture(string text, CairoFont font, ref LoadedTexture loadedTexture, TextBackground background = null)
        {
            if (background == null)
            {
                background = defaultBackground.Clone();
                if (font.StrokeWidth > 0)
                {
                    background.Padding = (int)Math.Ceiling(font.StrokeWidth);
                }
            }

            ElementBounds bounds = new ElementBounds();

            font.AutoBoxSize(text, bounds);


            int width  = (int)Math.Ceiling(GuiElement.scaled(bounds.fixedWidth + 1 + 2 * background.Padding));
            int height = (int)Math.Ceiling(GuiElement.scaled(bounds.fixedHeight + 1 + 2 * background.Padding));

            GenOrUpdateTextTexture(text, font, width, height, ref loadedTexture, background);
        }