Ejemplo n.º 1
0
        /// <summary>
        /// Copies glyphs from this font into a new MFE font, using the
        /// characters found in the code page file to specify what characters
        /// to extract.
        /// </summary>
        /// <param name="cp"></param>
        /// <returns></returns>
        public Mfe.Font MakeMfeFont(CodePageTable cp)
        {
            Font font = new Font();

            font.Height = this.Height;
            font.WidthMustBeMultipleOfEight = false;
            //font["Name"] = this.Name;
            font["Code Page"] = cp.Name;
            font.BaseLine     = (byte)(Height - (Yoff < 0 ? -Yoff : Yoff));
            for (int i = 0; i < cp.CodePoints.Length; i++)
            {
                var v = Chars.Where(ch => ch.Codepoint == cp[i]);
                if (v.FirstOrDefault() != null)
                {
                    font[i] = v.First();
                }
                else
                {
                    Mfe.Char t = new Char();
                    t.Height = font.Height;
                    font[i]  = t;
                }
            }
            return(font);
        }
Ejemplo n.º 2
0
        public static CodePageTable FromFile(string path)
        {
            CodePageTable ret = new CodePageTable();

            string[] lines = System.IO.File.ReadAllLines(path);
            ret.Name = lines[0];
            for (int i = 1; i <= 256; i++)
            {
                if (lines[i].Length > 0)
                {
                    ret.CodePoints[i - 1] = lines[i][0];
                    if (lines[i].Length > 1)
                    {
                        ret.Names[i - 1] = lines[i].Substring(1);
                    }
                    else
                    {
                        ret.Names[i - 1] = ret.CodePoints[i - 1].ToString();
                    }
                }
                else
                {
                    ret.CodePoints[i - 1] = '�';
                    ret.Names[i - 1]      = "";
                }
            }

            return(ret);
        }
Ejemplo n.º 3
0
 public static CodePageTable CopyFromFont(Mfe.Font font)
 {
     CodePageTable ret = new CodePageTable();
     for (int i = 0; i < Font.MaximumCodePoints; i++)
         ret.CodePoints[i] = font[i].Codepoint;
     ret.Name = font["Code Page"] ?? "<unspecified>";
     return ret;
 }
Ejemplo n.º 4
0
        public static CodePageTable CopyFromFont(Mfe.Font font)
        {
            CodePageTable ret = new CodePageTable();

            for (int i = 0; i < Font.MaximumCodePoints; i++)
            {
                ret.CodePoints[i] = font[i].Codepoint;
            }
            ret.Name = font["Code Page"] ?? "<unspecified>";
            return(ret);
        }
Ejemplo n.º 5
0
 protected override void OnShown(EventArgs e)
 {
     base.OnShown(e);
     if (CurrentFont.Chars.Count == 0)
     {
         return;
     }
     charSelectUpDown.Maximum = CurrentFont.Chars.Count - 1;
     charSelectUpDown_ValueChanged(null, new EventArgs());
     Master.ImportedFont    = CurrentFont.MakeMfeFont(CodePageTable.CopyFromFont(new Font()));
     destCharPreviewer.Char = ImportedFont[(int)destSelectUpDown.Value];
     Master.Chart.RefreshData();
 }
Ejemplo n.º 6
0
 private void defaultCpButton_Click(object sender, EventArgs e)
 {
     try
     {
         // Ugly kludge, but whatever
         Master.ImportedFont    = CurrentFont.MakeMfeFont(CodePageTable.CopyFromFont(new Font()));
         destCharPreviewer.Char = ImportedFont[(int)destSelectUpDown.Value];
         Master.Chart.RefreshData();
     }
     catch (Exception f)
     {
         MessageBox.Show("Error: " + f.ToString(), "Error Loading Codepage File", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 7
0
 private void codepageExportButton_Click(object sender, EventArgs e)
 {
     try
     {
         if (exportCodePageFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
         {
             CodePageTable.CopyFromFont(CurrentFont).WriteToFile(exportCodePageFileDialog.FileName);
             Master.RefreshStuff();
         }
     }
     catch (Exception x)
     {
         MessageBox.Show("Error in export: " + x.ToString(), "Error in Export", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Ejemplo n.º 8
0
 private void loadCpButton_Click(object sender, EventArgs e)
 {
     if (loadCodepageDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
     {
         try
         {
             ImportedFont = CurrentFont.MakeMfeFont(
                 CodePageTable.FromFile(loadCodepageDialog.FileName)
                 );
             destCharPreviewer.Char = ImportedFont[(int)destSelectUpDown.Value];
             Master.Chart.RefreshData();
         }
         catch (Exception f)
         {
             MessageBox.Show("Error: " + f.ToString(), "Error Loading Codepage File", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
 }
Ejemplo n.º 9
0
        public static CodePageTable FromFile(string path)
        {
            CodePageTable ret = new CodePageTable();
            string[] lines = System.IO.File.ReadAllLines(path);
            ret.Name = lines[0];
            for (int i = 1; i <= 256; i++)
            {
                if (lines[i].Length > 0)
                {
                    ret.CodePoints[i - 1] = lines[i][0];
                    if (lines[i].Length > 1)
                        ret.Names[i - 1] = lines[i].Substring(1);
                    else
                        ret.Names[i - 1] = ret.CodePoints[i - 1].ToString();
                }
                else
                {
                    ret.CodePoints[i - 1] = '�';
                    ret.Names[i - 1] = "";
                }
            }

            return ret;
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Copies glyphs from this font into a new MFE font, using the
 /// characters found in the code page file to specify what characters
 /// to extract.
 /// </summary>
 /// <param name="cp"></param>
 /// <returns></returns>
 public Mfe.Font MakeMfeFont(CodePageTable cp)
 {
     Font font = new Font();
     font.Height = this.Height;
     font.WidthMustBeMultipleOfEight = false;
     //font["Name"] = this.Name;
     font["Code Page"] = cp.Name;
     font.BaseLine = (byte)(Height - (Yoff < 0 ? -Yoff : Yoff));
     for (int i = 0; i < cp.CodePoints.Length; i++)
     {
         var v = Chars.Where(ch => ch.Codepoint == cp[i]);
         if (v.FirstOrDefault() != null)
             font[i] = v.First();
         else
         {
             Mfe.Char t = new Char();
             t.Height = font.Height;
             font[i] = t;
         }
     }
     return font;
 }