/// <summary> /// byte배열 형태의 폰트 데이터를 저장한다. (MKV 내의 폰트 등) /// </summary> /// <param name="fontsData"></param> /// <returns></returns> public static async void InstallFont(IEnumerable <KeyValuePair <string, byte[]> > fontsData, bool fireListChangedEvent) { var folder = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync("Fonts", CreationCollisionOption.OpenIfExists); await Task.Factory.StartNew(() => { var compare = new FontPathCompare(); Parallel.ForEach(fontsData, async(fontData) => { StorageFile fontFile = null; fontFile = await folder.CreateFileAsync(fontData.Key, Windows.Storage.CreationCollisionOption.OpenIfExists); var prop = await fontFile.GetBasicPropertiesAsync(); if (prop.Size == 0) { //시뉵 폰트 파일 저장 await Windows.Storage.FileIO.WriteBytesAsync(fontFile, fontData.Value); //System.Diagnostics.Debug.WriteLine($"폰트 저장 : {fontData.Key}"); } else { //이미 폰트가 존재하는 경우, 새롭게 설치 요청이 들어오면 기존 삭제 대상폰트 리스트에서 제거 한다. (초기화) FontDAO.DeleteTempFont(new string[] { fontFile.Path }); //System.Diagnostics.Debug.WriteLine($"폰트 이미 존재 : {fontData.Key}"); } List <KeyName> addedList = new List <KeyName>(); foreach (var font in await GetFontItems(fontFile)) { lock (lockobj) { if (!FontList.Contains(font, compare)) { if (!addedList.Contains(font)) { addedList.Add(font); } FontList.Add(font); } } } if (fireListChangedEvent) { //이벤트 처리 if (FontFamilyListChanged != null && addedList.Count > 0) { FontFamilyListChanged(FontList, new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, addedList)); //System.Diagnostics.Debug.WriteLine($"추가 이벤트 발생 : {fontData.Key}"); } } }); }); }
private void populateFontFamilyCombobox() { using (InstalledFontCollection fontsCollection = new InstalledFontCollection()) { System.Drawing.FontFamily[] fontFamilies = fontsCollection.Families; foreach (System.Drawing.FontFamily font in fontFamilies) { FontList.Add(font.Name); } } }
static FontFactory() { Stream fontzip = Assembly.GetExecutingAssembly().GetManifestResourceStream("CLIForms_FIGFonts.fonts.zip"); using (ZipFile zip = ZipFile.Read(fontzip)) { foreach (string entry in zip.EntryFileNames) { if (entry.EndsWith(".flf")) { FontList.Add(entry); } } } }
private void Init(string file) { XmlDocument xmlDocument = new XmlDocument(); if (File.Exists(file)) { xmlDocument.Load(file); XmlNodeList languageList = xmlDocument.SelectNodes("/Configuration/Languages/Language"); if (languageList.Count > 0) { foreach (XmlNode item in languageList) { LanguageList.Add(item.Attributes["Name"].Value); FilenameExtensionDic.Add(item.Attributes["Name"].Value, item.Attributes["Extension"].Value); } } XmlNodeList themeList = xmlDocument.SelectNodes("/Configuration/Themes/Theme"); if (themeList.Count > 0) { foreach (XmlNode item in themeList) { ThemeList.Add(item.InnerText); } } XmlNodeList fontSizeList = xmlDocument.SelectNodes("/Configuration/FontSizes/FontSize"); if (fontSizeList.Count > 0) { foreach (XmlNode item in fontSizeList) { FontSizeList.Add(int.Parse(item.InnerText)); } } XmlNodeList fontList = xmlDocument.SelectNodes("/Configuration/Fonts/Font"); if (fontList.Count > 0) { foreach (XmlNode item in fontList) { FontList.Add(item.InnerText); } } } }
public static async void LoadAllFont(Action complete) { if (FontList == null) { IsLoaded = false; FontList = new List <KeyName>(); } //사용자 폰트 var folder = await Windows.Storage.ApplicationData.Current.LocalFolder.CreateFolderAsync("Fonts", CreationCollisionOption.OpenIfExists); var files = await folder.GetFilesAsync(); //삭제 대상 폰트 var reservedDeletionFontList = FontDAO.GetTempFontList(); //사용자폰트 로드 foreach (var file in files.OrderBy(x => x.Name)) { foreach (var fontItem in await GetFontItems(file)) { if (!FontList.Any(x => x.Key.ToString() == fontItem.Key.ToString()) && !reservedDeletionFontList.Any(x => x == (fontItem.Payload as StorageFile).Path)) { FontList.Add(fontItem); //System.Diagnostics.Debug.WriteLine($"모든 폰트 로드 : {fontItem.Key}"); } } } //기본값 FontList.Add(new KeyName(FONT_FAMILY_DEFAUT, FONT_FAMILY_DEFAUT) { Type = FontTypes.OS.ToString() }); //시스템 폰트 IList <NativeHelper.Font> systemFontList = NativeHelper.FontList.GetSystemFontList("en-us"); FontList.AddRange(systemFontList.Where(x => !IgnoreFonts.Contains(x.FamilyName) && !string.IsNullOrWhiteSpace(x.FamilyName)) .Select(x => new KeyName(x.FamilyName, x.FamilyName) { Type = FontTypes.OS.ToString() })); IsLoaded = true; complete?.Invoke(); }