예제 #1
0
 void loadCurrentFont()
 {
     currentFont = LoadFont(new FileInfo(Path.Combine(currentFolder,
                                                      (string)fontsList.SelectedItem)), (int)numFontSz.Value,
                            (ckBold.Checked ? FontStyle.Bold : FontStyle.Regular) |
                            (ckItalic.Checked ? FontStyle.Italic : FontStyle.Regular));
     txtTry.Font = currentFont.Font;
 }
예제 #2
0
        static LoadedFont LoadFont(FileInfo file, int fontSize, FontStyle fontStyle)
        {
            var fontCollection = new PrivateFontCollection();

            fontCollection.AddFontFile(file.FullName);
            if (fontCollection.Families.Length < 0)
            {
                throw new InvalidOperationException("No font familiy found when loading font");
            }

            var loadedFont = new LoadedFont();

            loadedFont.FontFamily = fontCollection.Families[0];
            loadedFont.Font       = new Font(loadedFont.FontFamily, fontSize, fontStyle, GraphicsUnit.Pixel);
            return(loadedFont);
        }