public CopticFont ToCopticFont() { var font = new CopticFont() { Name = Name, FontName = FontName, IsJenkimBefore = IsJenkimBefore, IsCopticStandard = IsCopticStandard, Charmap = new Dictionary <string, string>() }; foreach (MapXml map in Charmap) { font.Charmap.Add(map.BaseCharacter, map.NewCharacter); } return(font); }
public static Font ToFontXml(CopticFont font) { var xml = new Font() { Name = font.Name, FontName = font.FontName, IsJenkimBefore = font.IsJenkimBefore, IsCopticStandard = font.IsCopticStandard, Charmap = new List <MapXml>() }; foreach (string key in font.Charmap.Keys) { string value; font.Charmap.TryGetValue(key, out value); var pair = new MapXml() { BaseCharacter = key, NewCharacter = value }; xml.Charmap.Add(pair); } return(xml); }
static void Main(string[] args) { string logPath = @"C:\Users\jjask\Desktop\log.txt"; Console.OutputEncoding = System.Text.Encoding.Unicode; var parameters = ParseArgs(args); CopticFont sourceFont = CopticFont.CsAvvaShenouda; CopticFont targetFont = CopticFont.CopticUnicode; if (parameters.ContainsKey("source-font")) { sourceFont = CopticFont.Fonts.Find((f) => f.Name == parameters["source-font"]); } if (parameters.ContainsKey("target-font")) { targetFont = CopticFont.Fonts.Find((f) => f.Name == parameters["target-font"]); } string output = ""; if (parameters.ContainsKey("source-txt")) { try { output = CopticInterpreter.ConvertFont( File.ReadAllText(parameters["source-file"]), sourceFont, targetFont ); } catch (FileNotFoundException) { Console.Error.WriteLine("Unable to read the source file"); } } else if (parameters.ContainsKey("")) { output = CopticInterpreter.ConvertFont( parameters[""], sourceFont, targetFont ); } else if (parameters.ContainsKey("source-csv")) { try { // Get the column to convert int columnNum = 0; if (parameters.ContainsKey("csv-column")) { columnNum = Int32.Parse(parameters["csv-column"]); } // Read the specified column List <string> inputText = new List <string>(); var table = ReadCsvFile(parameters["source-csv"]); foreach (List <string> row in table) { inputText.Add(row[columnNum]); } // Convert each line foreach (string input in inputText) { output += CopticInterpreter.ConvertFont( input, sourceFont, targetFont ); output += "\r\n"; } } catch (FileNotFoundException) { Console.Error.WriteLine("Unable to read the source file"); } } Console.WriteLine(output); File.WriteAllText(logPath, output, System.Text.Encoding.Unicode); }