static XFontSource GetOrCreateFrom(string typefaceKey, byte[] fontBytes, string fontName) { XFontSource fontSource; ulong key = FontHelper.CalcChecksum(fontBytes); if (FontFactory.TryGetFontSourceByKey(key, out fontSource)) { // The font source already exists, but is not yet cached under the specified typeface key. FontFactory.CacheExistingFontSourceWithNewTypefaceKey(typefaceKey, fontSource); } else { // No font source exists. Create new one and cache it. fontSource = new XFontSource(fontBytes, key); // Name is necessary for reading TTC files if (fontSource.FontName == null) { fontSource._fontName = fontName; } FontFactory.CacheNewFontSource(typefaceKey, fontSource); } return(fontSource); }
static XFontSource GetOrCreateFrom(string typefaceKey, byte[] fontBytes) { var key = FontHelper.CalcChecksum(fontBytes); if (FontFactory.TryGetFontSourceByKey(key, out XFontSource fontSource)) { // The font source already exists, but is not yet cached under the specified typeface key. FontFactory.CacheExistingFontSourceWithNewTypefaceKey(typefaceKey, fontSource); } else { // No font source exists. Create new one and cache it. fontSource = new XFontSource(fontBytes, key); FontFactory.CacheNewFontSource(typefaceKey, fontSource); } return(fontSource); }