/// <summary> /// Gets an existing font source or creates a new one. /// A new font source is cached in font factory. /// </summary> public static XFontSource GetOrCreateFrom(byte[] bytes) { ulong key = FontHelper.CalcChecksum(bytes); if (!FontFactory.TryGetFontSourceByKey(key, out XFontSource fontSource)) { fontSource = new XFontSource(bytes, key); // Theoretically the font source could be created by a differend thread in the meantime. fontSource = FontFactory.CacheFontSource(fontSource); } return(fontSource); }