Ejemplo n.º 1
0
        /// <summary>
        /// Writes a single Character to the display buffer.
        /// </summary>
        /// <returns>The char buff.</returns>
        /// <param name="font">Font.</param>
        /// <param name="Chr">Chr.</param>
        /// <param name="Row">Row.</param>
        /// <param name="Col">Col.</param>
        public uint WriteCharBuff(IFont font, Char Chr, UInt32 Row, UInt32 Col)
        {
            if (Chr == ' ')
            {
                return(font.CharSpacing);
            }

            var fontinfo = font.GetChar(Chr);

            UInt32 StartCol = Col;
            UInt32 EndCol   = StartCol + fontinfo.Columns - 1;

            for (var index = fontinfo.IndexFrom; index <= fontinfo.IndexTo; index++)
            {
                if (Col < ScreenWidthPX && Row < ScreenPages)
                {
                    DisplayBuffer[Row, Col] = font.Data[index];
                }
                if (++Col > EndCol)
                {
                    Col = StartCol;
                    Row++;
                }
            }
            return(fontinfo.Columns);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the Column Width (px) for the given text.
        /// </summary>
        /// <returns>The column width.</returns>
        /// <param name="font">Font.</param>
        /// <param name="Text">Text.</param>
        /// <param name="MaxWidthToFill">Max width to fill.</param>
        public uint CalculateColumnWidth(IFont font, String Text, uint MaxWidthToFill)
        {
            uint Col = 0;

            foreach (Char Chr in Text)
            {
                if (Chr == ' ')
                {
                    Col += font.CharSpacing;
                }
                else
                {
                    var fontinfo = font.GetChar(Chr);
                    Col += fontinfo.Columns;
                    if (Col > MaxWidthToFill)
                    {
                        return(0);
                    }
                }
            }
            return(Col);
        }