Exemplo n.º 1
0
        /// <summary>
        /// Draw BitFont String
        /// </summary>
        /// <exception cref="KeyNotFoundException"></exception>
        /// <param name="canvas"></param>
        /// <param name="FontName"></param>
        /// <param name="color"></param>
        /// <param name="Text"></param>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        /// <param name="Devide"></param>
        public static void DrawBitFontString(this Canvas canvas, string FontName, Color color, string Text, int X, int Y, int Devide = 2, bool DisableAntiAliasing = false)
        {
            if (!RegisteredBitFont.ContainsKey(FontName))
            {
                throw new KeyNotFoundException($"\"{FontName}\" is not registered yet");
            }

            BitFontDescriptor bitFontDescriptor = RegisteredBitFont[FontName];

            string[] Lines = Text.Split('\n');
            for (int l = 0; l < Lines.Length; l++)
            {
                int UsedX = 0;
                for (int i = 0; i < Lines[l].Length; i++)
                {
                    char c = Lines[l][i];
                    UsedX += DrawBitFontChar(canvas, bitFontDescriptor.MS, bitFontDescriptor.Size, color, bitFontDescriptor.Charset.Impl_Str_IndexOf(c), UsedX + X, Y + bitFontDescriptor.Size * l, !DisableAntiAliasing) + Devide;
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// The BitFont Should Be Left Aligned
 /// </summary>
 /// <param name="Name"></param>
 /// <param name="bitFontDescriptor"></param>
 public static void RegisterBitFont(string Name, BitFontDescriptor bitFontDescriptor)
 {
     RegisteredBitFont.Add(Name, bitFontDescriptor);
 }