Ejemplo n.º 1
0
        public static bool LoadTextFile(string filename)
        {
            try
            {
                StringBuilder stringBuilder = new StringBuilder();
                char[]        stripChars    = new[] { '\t', '\r', '\n' };

                using (StreamReader reader = new StreamReader(filename))
                {
                    while (true)
                    {
                        int c = reader.Read();
                        if (c == -1)
                        {
                            break;
                        }

                        char readChar = (char)c;
                        if (Array.IndexOf(stripChars, readChar) < 0)
                        {
                            stringBuilder.Append(readChar);
                        }
                    }
                }

                FontGenerator.AddGlyphsFromWord(stringBuilder.ToString());
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error reading the txt file.\n" + ex.Message);
                return(false);
            }

            return(true);
        }
Ejemplo n.º 2
0
        private static bool LoadXMLFile(string filename)
        {
            try
            {
                if (!IsValidFile(filename))
                {
                    Console.WriteLine("Not a valid lyric file.");
                    return(false);
                }

                XElement jpXML = XElement.Load(filename);

                foreach (var vocal in jpXML.Elements("vocal"))
                {
                    string lyric        = vocal.Attribute("lyric").Value;
                    string lyricTrimmed = lyric.EndsWith("+") || lyric.EndsWith("-") ? lyric.Substring(0, lyric.Length - 1) : lyric;

                    FontGenerator.AddGlyphsFromWord(lyricTrimmed);
                }

                // Space is always included in official Japanese lyrics
                FontGenerator.AddGlyph(" ");
                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error reading the xml file.\n" + ex.Message);
                return(false);
            }
        }