Fonteditor/CharViewHandler.cs
/// <summary>
/// Draws a character preview in the given picture box
/// and uses the border space to draw overlapping part of the character if the character does not fit
/// The parameters offsX and offsY are used to move the perview character into the correct position before rasterising it
/// </summary>
Draws a character preview in the given picture box
and uses the border space to draw overlapping part of the character if the character does not fit
The parameters offsX and offsY are used to move the perview character into the correct position before rasterising it
Draws a character preview in the given picture box and uses the border space to draw overlapping part of the character if the character does not fit The parameters offsX and offsY are used to move the perview character into the correct position before rasterising it
public void DrawPreview(Graphics graphics, SizeInfo size, Character character, char c, Font font, int offsX, int offsY)
        {
            int usedWidth = size.Width;
            int usedHeight = size.Height;
            if (character != null)
            {
                usedWidth = character.Width;
                usedHeight = character.Height;
            }
            int bX = (int)Math.Ceiling(usedWidth * cBorderFactor); bX += bX % 2;
            int bY = (int)Math.Ceiling(usedHeight* cBorderFactor); bY += bY % 2;
            int fullWidth = usedWidth + bX;
            int fullHeight = usedHeight + bY;
            Bitmap b = Utils.CreateFontPicture(c, font, fullWidth , fullHeight , bX/2+offsX, bY/2+ offsY);
            byte[,] matrix = new byte[fullWidth , fullHeight ];
            for (int y = 0; y < fullHeight  ; y++)
            {
                for (int x = 0; x < fullWidth ; x++)
                {
                    byte colorID = Constants.BACKGROUND_COLOR_ID;
                    Color color = b.GetPixel(x, y);
                    if (color.R < 128)
                    {
                        colorID = Constants.FOREGROUND_COLOR_ID;
                    }
                    matrix[x, y] = colorID;
                }
            }
            DrawMatrix(graphics, matrix, fullWidth, fullHeight , false, true, usedWidth, usedHeight);
        }
public void DrawPreview ( Graphics graphics , SizeInfo size , Character character , char c , Font font , int offsX , int offsY ) { int usedWidth = size . Width ; int usedHeight = size . Height ; if ( character != null ) { usedWidth = character . Width ; usedHeight = character . Height ; } int bX = ( int ) Math . Ceiling ( usedWidth * cBorderFactor ) ; bX += bX % 2 ; int bY = ( int ) Math . Ceiling ( usedHeight * cBorderFactor ) ; bY += bY % 2 ; int fullWidth = usedWidth + bX ; int fullHeight = usedHeight + bY ; Bitmap b = Utils . CreateFontPicture ( c , font , fullWidth , fullHeight , bX / 2 + offsX , bY / 2 + offsY ) ; byte [ , ] matrix = new byte [ fullWidth , fullHeight ] ; for ( int y = 0 ; y < fullHeight ; y ++ ) { for ( int x = 0 ; x < fullWidth ; x ++ ) { byte colorID = Constants . BACKGROUND_COLOR_ID ; Color color = b . GetPixel ( x , y ) ; if ( color . R < 128 ) { colorID = Constants . FOREGROUND_COLOR_ID ; } matrix [ x , y ] = colorID ; } } DrawMatrix ( graphics , matrix , fullWidth , fullHeight , false , true , usedWidth , usedHeight ) ; }
Draws a character preview in the given picture box
and uses the border space to draw overlapping part of the character if the character does not fit
The parameters offsX and offsY are used to move the perview character into the correct position before rasterising it
Draws a character preview in the given picture box and uses the border space to draw overlapping part of the character if the character does not fit The parameters offsX and offsY are used to move the perview character into the correct position before rasterising it
graphics
Graphics
size
SizeInfo
character
Character
c
char
font
Font
offsX
int
offsY
int