/// <summary> /// get typeface from wellknown style /// </summary> /// <param name="fontname"></param> /// <param name="style"></param> /// <returns></returns> public Typeface GetTypeface(string fontname, InstalledFontStyle style) { InstalledFont installedFont = FontCollection.GetFont(fontname, style); if (installedFont == null && _fontNotFoundHandler != null) { installedFont = _fontNotFoundHandler(this.FontCollection, fontname, null, style); } if (installedFont == null) { return(null); } return(GetTypefaceOrCreateNew(installedFont)); }
public Typeface GetTypeface(string fontname, string fontSubFam) { InstalledFont installedFont = FontCollection.GetFont(fontname, fontSubFam); //convert from if (installedFont == null && _fontNotFoundHandler != null) { installedFont = _fontNotFoundHandler(this.FontCollection, fontname, fontSubFam, FontCollection.GetWellknownFontStyle(fontSubFam)); } if (installedFont == null) { return(null); } return(GetTypefaceOrCreateNew(installedFont)); }
Typeface GetTypefaceOrCreateNew(InstalledFont installedFont) { //load //check if we have create this typeface or not Typeface typeface; if (!_loadedTypefaces.TryGetValue(installedFont, out typeface)) { //TODO: review how to load font here using (var fs = new FileStream(installedFont.FontPath, FileMode.Open, FileAccess.Read)) { var reader = new OpenFontReader(); typeface = reader.Read(fs); } return(_loadedTypefaces[installedFont] = typeface); } return(typeface); }
bool RegisterFont(InstalledFont newfont) { FontGroup selectedFontGroup; string fontsubFamUpperCaseName = newfont.FontSubFamily.ToUpper(); if (!_subFamToFontGroup.TryGetValue(fontsubFamUpperCaseName, out selectedFontGroup)) { //create new group, we don't known this font group before //so we add to 'other group' list selectedFontGroup = new FontGroup(); _subFamToFontGroup.Add(fontsubFamUpperCaseName, selectedFontGroup); _allFontGroups.Add(selectedFontGroup); } // string fontNameUpper = newfont.FontName.ToUpper(); InstalledFont found; if (selectedFontGroup.TryGetValue(fontNameUpper, out found)) { //TODO: //we already have this font name //(but may be different file //we let user to handle it switch (fontNameDuplicatedHandler(found, newfont)) { default: throw new NotSupportedException(); case FontNameDuplicatedDecision.Skip: return(false); case FontNameDuplicatedDecision.Replace: selectedFontGroup.Replace(newfont); return(true); } } else { selectedFontGroup.AddFont(newfont); return(true); } }
public void Replace(InstalledFont newone) { _members[newone.FontName.ToUpper()] = newone; }
public bool TryGetValue(string fontName, out InstalledFont found) { return(_members.TryGetValue(fontName, out found)); }
public void AddFont(InstalledFont installedFont) { _members.Add(installedFont.FontName.ToUpper(), installedFont); }
public Typeface GetTypeface(InstalledFont installedFont) { return(GetTypefaceOrCreateNew(installedFont)); }