예제 #1
0
        /*
         * Save font
         */
        public static void Save(SizedFont sf,String xmlFilename,Control refControl,TargetDevice targetDevice)
        {
            String headerFilename,sourceFilename;
              XmlDocument doc;
              XmlElement root;
              FontWriter fw;

              // filename has .xml extension. calculate same name with .h and .cpp

              headerFilename=Path.GetFileNameWithoutExtension(xmlFilename)+".h";
              headerFilename=Path.Combine(Path.GetDirectoryName(xmlFilename),headerFilename);

              sourceFilename=Path.GetFileNameWithoutExtension(xmlFilename)+".cpp";
              sourceFilename=Path.Combine(Path.GetDirectoryName(xmlFilename),sourceFilename);

              // create header stream

              using(StreamWriter headerWriter=new StreamWriter(headerFilename)) {
            using(StreamWriter sourceWriter=new StreamWriter(sourceFilename)) {

              // create XML parent

              doc=new XmlDocument();
              root=doc.CreateElement("FontConv");
              doc.AppendChild(root);

              switch(targetDevice) {

            case TargetDevice.ARDUINO:
              fw=new ArduinoFontWriter(sf,headerWriter,sourceWriter,root,refControl);
              break;

            case TargetDevice.STM32PLUS:
              fw=new Stm32plusFontWriter(sf,headerWriter,sourceWriter,root,refControl);
              break;

            default:
              throw new Exception("Unknown device");
              }

              fw.Save();
              doc.Save(xmlFilename);
            }
              }
        }
예제 #2
0
        /*
         * Save font
         */

        static public void Save(SizedFont sf, String xmlFilename, Control refControl, TargetDevice targetDevice)
        {
            String      headerFilename, sourceFilename;
            XmlDocument doc;
            XmlElement  root;
            FontWriter  fw;

            // filename has .xml extension. calculate same name with .h and .cpp

            headerFilename = Path.GetFileNameWithoutExtension(xmlFilename) + ".h";
            headerFilename = Path.Combine(Path.GetDirectoryName(xmlFilename), headerFilename);

            sourceFilename = Path.GetFileNameWithoutExtension(xmlFilename) + ".cpp";
            sourceFilename = Path.Combine(Path.GetDirectoryName(xmlFilename), sourceFilename);

            // create header stream

            using (StreamWriter headerWriter = new StreamWriter(headerFilename)) {
                using (StreamWriter sourceWriter = new StreamWriter(sourceFilename)) {
                    // create XML parent

                    doc  = new XmlDocument();
                    root = doc.CreateElement("FontConv");
                    doc.AppendChild(root);

                    switch (targetDevice)
                    {
                    case TargetDevice.ARDUINO:
                        fw = new ArduinoFontWriter(sf, headerWriter, sourceWriter, root, refControl);
                        break;

                    case TargetDevice.STM32PLUS:
                        fw = new Stm32plusFontWriter(sf, headerWriter, sourceWriter, root, refControl);
                        break;

                    default:
                        throw new Exception("Unknown device");
                    }

                    fw.Save();
                    doc.Save(xmlFilename);
                }
            }
        }