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"); } }
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"); } }
/// <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; }
/// <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"); }
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); }
/// <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; }