Example #1
0
        public SubtitleFonts()
        {
            fonts = new LinkedList <SubtitleFont>();

            defaultFont = null;

            fontStats = new Hashtable();

            debugStrings = new LinkedList <PositionedString>();

            DirectoryInfo di = new DirectoryInfo(".");

            FileInfo[] rgFiles = di.GetFiles("*.font.txt");
            foreach (FileInfo fi in rgFiles)
            {
                string fontName = fi.Name;
                fontName = fontName.Substring(0, fontName.LastIndexOf('.'));
                fontName = fontName.Substring(0, fontName.LastIndexOf('.'));
                fonts.AddLast(new SubtitleFont(SubtitleFont.FontType.ProgramFont, fontName));
            }

            try
            {
                userFont = new SubtitleFont(SubtitleFont.FontType.UserFont, "temp");
            }
            catch (FontfileFormatException)
            {
                SubtitleFont.DeleteUserFont("temp");
                userFont = new SubtitleFont(SubtitleFont.FontType.UserFont, "temp");
            }
        }
Example #2
0
        public SubtitleFonts()
        {
            fonts = new LinkedList<SubtitleFont>();

            defaultFont = null;

            fontStats = new Hashtable();

            debugStrings = new LinkedList<PositionedString>();

            DirectoryInfo di = new DirectoryInfo(".");
            FileInfo[] rgFiles = di.GetFiles("*.font.txt");
            foreach(FileInfo fi in rgFiles)
            {
                string fontName = fi.Name;
                fontName = fontName.Substring(0, fontName.LastIndexOf('.'));
                fontName = fontName.Substring(0, fontName.LastIndexOf('.'));
                fonts.AddLast(new SubtitleFont(SubtitleFont.FontType.ProgramFont, fontName));
            }

            try
            {
                userFont = new SubtitleFont(SubtitleFont.FontType.UserFont, "temp");
            }
            catch (FontfileFormatException)
            {
                SubtitleFont.DeleteUserFont("temp");
                userFont = new SubtitleFont(SubtitleFont.FontType.UserFont, "temp");
            }
        }
Example #3
0
        /// <summary>
        /// Moves all the letters from this font to another font
        /// </summary>
        /// <param name="target">The target font that the letters should be moved to</param>
        public void MoveLetters(SubtitleFont target)
        {
            foreach (SubtitleLetter letter in letters)
            {
                target.AddLetter(letter);
            }

            letters.Clear();
            changed = true;
        }
Example #4
0
        /// <summary>
        /// Remembers one of the built in fonts as default font so it gets searched first for subsequent letters
        /// </summary>
        /// <param name="name">The name of the font to set as default</param>
        private void SetDefaultFont(string name)
        {
            foreach (SubtitleFont font in fonts)
            {
                if (font.Name == name)
                {
                    defaultFont = font;
                    return;
                }
            }

            throw new Exception("Trying to set an unknown font as default");
        }
Example #5
0
        public void MergeUserFont(string targetFontName)
        {
            SubtitleFont targetFont = null;

            foreach (SubtitleFont font in fonts)
            {
                if (font.Name == targetFontName)
                {
                    targetFont = font;
                    break;
                }
            }

            if (targetFont == null)
            {
                throw new Exception("invalid font name for merge fonts");
            }

            userFont.MoveLetters(targetFont);
        }
Example #6
0
        /// <summary>
        /// Remembers one of the built in fonts as default font so it gets searched first for subsequent letters
        /// </summary>
        /// <param name="name">The name of the font to set as default</param>
        private void SetDefaultFont(string name)
        {
            foreach (SubtitleFont font in fonts)
            {
                if (font.Name == name)
                {
                    defaultFont = font;
                    return;
                }
            }

            throw new Exception("Trying to set an unknown font as default");
        }
Example #7
0
        /// <summary>
        /// Moves all the letters from this font to another font
        /// </summary>
        /// <param name="target">The target font that the letters should be moved to</param>
        public void MoveLetters(SubtitleFont target)
        {
            foreach (SubtitleLetter letter in letters)
                target.AddLetter(letter);

            letters.Clear();
            changed = true;
        }