Ejemplo n.º 1
0
        /// <summary>
        /// Main loop.
        /// </summary>
        /// <param name="args">Command line arguments</param>
        static void Main(string[] args)
        {
            Helper = new ConsolePrinter();

            Helper.Name        = "Bmp2Font";
            Helper.Description = "Converts a BMP font image into a bit-packed font class for use with Woopsi.";
            Helper.Version     = "V1.2";
            Helper.AddArgument(new Argument("INFILE", "string", "Path and filename of the BMP file to convert", false));
            Helper.AddArgument(new Argument("CLASSNAME", "string", "Name of the resultant font class", false));

            Argument arg = new Argument("FONTTYPE", "string", "Type of font to produce.  Options are:", true);

            arg.AddOption("packedfont1", "Monochrome packed proportional font");
            arg.AddOption("packedfont16", "16-bit packed proportional font");

            Helper.AddArgument(arg);

            Helper.AddArgument(new Argument("WIDTH", "int", "Width of a single character in the font", true));
            Helper.AddArgument(new Argument("HEIGHT", "int", "Height of a single character in the font", true));
            Helper.AddArgument(new Argument("R", "int", "Red component of the background colour", true));
            Helper.AddArgument(new Argument("G", "int", "Green component of the background colour", true));
            Helper.AddArgument(new Argument("B", "int", "Blue component of the background colour", true));

            Helper.AddParagraph(@"WIDTH and HEIGHT represent the width and height of a single character in the font.
Fonts must be fixed width.  If WIDTH and HEIGHT are not specified, they will be calculated from the dimensions of the
bitmap.  In that case, the bitmap must be a multiple of 32 wide (32 chars per line) and a multiple of 8 high
(32 * 8 = 256,the number of chars in a font).");

            Helper.AddParagraph(@"If the RGB background colour is not specified, it is automatically determined from
the colour of the top-left pixel.  If this pixel is not part of the background, the resultant font class will be corrupt.");

            // Fetch arguments
            if (!ParseArgs(args))
            {
                return;
            }

            // Load original file
            if (!LoadFile())
            {
                return;
            }

            // Perform the conversion
            try
            {
                WoopsiFont font = Converter.Convert(mClassName, mBitmapName, mFontType, mBitmap, mFontWidth, mFontHeight, mBackgroundR, mBackgroundG, mBackgroundB);

                // Output files
                WriteFile(font.HeaderFileName, font.HeaderContent);
                WriteFile(font.BodyFileName, font.BodyContent);

                Console.WriteLine("All done!");
            }
            catch (Exception)
            {
                Error("Unable to parse and pack data");
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Main program.
        /// </summary>
        /// <param name="args">Command line arguments.</param>
        static void Main(string[] args)
        {
            Helper = new ConsolePrinter();

            Helper.Name        = "Font2Bmp";
            Helper.Description = "Converts a Windows font to a BMP file.";
            Helper.Version     = "V1.2";
            Helper.AddArgument(new Argument("FONT", "string", "Name of the Windows font to convert", false));
            Helper.AddArgument(new Argument("SIZE", "int", "Size of the font in pixels", false));

            Argument arg = new Argument("STYLE", "int", "Style of the font.  Options are:", true);

            arg.AddOption("regular", "Standard font");
            arg.AddOption("bold", "Bold font");
            arg.AddOption("italic", "Italic font");

            Helper.AddArgument(arg);

            Helper.AddArgument(new Argument("FILE", "int", "Output path and filename", false));
            Helper.AddArgument(new Argument("BACKR", "int", "Red component of the background colour", true));
            Helper.AddArgument(new Argument("BACKG", "int", "Green component of the background colour", true));
            Helper.AddArgument(new Argument("BACKB", "int", "Blue component of the background colour", true));
            Helper.AddArgument(new Argument("TEXTR", "int", "Red component of the text colour", true));
            Helper.AddArgument(new Argument("TEXTG", "int", "Green component of the text colour", true));
            Helper.AddArgument(new Argument("TEXTB", "int", "Blue component of the text colour", true));
            Helper.AddArgument(new Argument("LIST", "int", "Lists all available Windows font names", true));
            Helper.AddParagraph("If the background colour is not specified it defaults to white.");
            Helper.AddParagraph("If the text colour is not specified it defaults to black.");
            Helper.AddParagraph("If the style is not specified it defaults to regular.");

            // Output title
            Console.WriteLine(Helper.Title);

            // Fetch arguments
            ParseArgs(args);

            // Get the font to convert
            Font font = GetFont(mFontName, mFontSize, mFontStyle);

            // Convert the font to a bitmap
            Console.WriteLine("Converting font to bitmap...");
            Bitmap bmp = BitmapCreator.CreateFontBitmap(font, mBackgroundR, mBackgroundG, mBackgroundB, mTextR, mTextG, mTextB);

            Console.WriteLine("Font converted.");
            Console.WriteLine("");

            // Save the bitmap
            Console.WriteLine(String.Format("Saving bitmap to {0}...", mFileName));
            bmp.Save(mFileName, System.Drawing.Imaging.ImageFormat.Bmp);
            Console.WriteLine("All done!");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Main program.
        /// </summary>
        /// <param name="args">Command line arguments.</param>
        static void Main(string[] args)
        {
            Helper = new ConsolePrinter();

            Helper.Name        = "Font2Font";
            Helper.Description = "Converts a Windows font to a Woopsi font.";
            Helper.Version     = "V1.2";
            Helper.AddArgument(new Argument("FONT", "string", "Name of the Windows font to convert", false));
            Helper.AddArgument(new Argument("SIZE", "int", "Size of the font in pixels", false));
            Argument arg = new Argument("STYLE", "int", "Style of the font.  Options are:", true);

            arg.AddOption("regular", "Standard font");
            arg.AddOption("bold", "Bold font");
            arg.AddOption("italic", "Italic font");

            Helper.AddArgument(arg);

            arg = new Argument("FONTTYPE", "string", "Type of font to produce.  Options are:", true);
            arg.AddOption("packedfont1", "Monochrome packed proportional font");
            arg.AddOption("packedfont16", "16-bit packed proportional font");

            Helper.AddArgument(arg);

            Helper.AddArgument(new Argument("PATH", "string", "Output path", false));
            Helper.AddArgument(new Argument("R", "int", "Red component of the text colour", true));
            Helper.AddArgument(new Argument("G", "int", "Green component of the text colour", true));
            Helper.AddArgument(new Argument("B", "int", "Blue component of the text colour", true));
            Helper.AddArgument(new Argument("LIST", "int", "Lists all available Windows font names", true));

            Helper.AddParagraph("If the text colour is not specified it defaults to black.");
            Helper.AddParagraph("If the style is not specified it defaults to regular.");
            Helper.AddParagraph("If the path is not specified it defaults to the current path.");
            Helper.AddParagraph("If the font type is not specified it defaults to packedfont1.");

            Console.WriteLine(Helper.Title);

            Console.WriteLine(Helper.HelpText);

            // Fetch arguments
            ParseArgs(args);

            // Use background colour that is opposite of text colour
            int backgroundR = (mTextR ^ 255) & 255;
            int backgroundG = (mTextG ^ 255) & 255;
            int backgroundB = (mTextB ^ 255) & 255;

            // Get the font
            Font font = GetFont(mFontName, mFontSize, mFontStyle);

            // Convert the font to a bitmap
            Bitmap bmp = BitmapCreator.CreateFontBitmap(font, backgroundR, backgroundG, backgroundB, mTextR, mTextG, mTextB);

            // Convert bitmap to Woopsi font
            WoopsiFont woopsiFont = Converter.Convert(mFontName, mFontName, mFontType, bmp, bmp.Width / CHARS_PER_ROW, bmp.Height / ROWS_PER_FONT, backgroundR, backgroundG, backgroundB);

            // Output files
            WriteFile(mOutputPath + "\\" + woopsiFont.HeaderFileName, woopsiFont.HeaderContent);
            WriteFile(mOutputPath + "\\" + woopsiFont.BodyFileName, woopsiFont.BodyContent);

            Console.WriteLine("All done!");
        }