private static void PutFontNamesToCache(FontCacheKey key, FontProgramDescriptor descriptor) { if (descriptor != null) { fontNamesCache.Put(key, descriptor); } }
/// <summary> /// Equality (typed). /// </summary> public bool Equals(FontCacheKey other) { return(family == other.family && script == other.script && size == other.size && style == other.style); }
internal static iText.Layout.Font.FontInfo Create(byte[] fontProgram, String encoding, String alias) { FontCacheKey cacheKey = FontCacheKey.Create(fontProgram); FontProgramDescriptor descriptor = GetFontNamesFromCache(cacheKey); if (descriptor == null) { descriptor = FontProgramDescriptorFactory.FetchDescriptor(fontProgram); PutFontNamesToCache(cacheKey, descriptor); } return(descriptor != null ? new iText.Layout.Font.FontInfo(null, fontProgram, encoding, descriptor, alias) : null); }
/// <summary> /// Gets the font with the desired parameters for measuring or drawing text. Works from cache. /// </summary> private static FontTray getFont(IdeoFamily fam, IdeoScript script, float size, FontStyle style) { // If font's already in cache, great: use that. FontCacheKey fck = new FontCacheKey(fam, script, size, style); if (fontCache.ContainsKey(fck)) { return(fontCache[fck]); } // First time someone request a font like this. Instantiate and cache it. FontTray ftray = createFont(fam, script, size, style); fontCache[fck] = ftray; return(ftray); }
internal Gdi32Font(FontCacheKey fontCacheKey) { Key = fontCacheKey; lock (FontCache) { if (!FontCache.TryGetValue(Key, out SharedObject sharedObject)) { sharedObject = new SharedObject(Key.FaceName, Key.Height, Key.Weight, Key.Italic, Key.Underline, Key.StrikeOut, Key.CharSet, Key.FontQuality); FontCache[Key] = sharedObject; } _SharedFont = sharedObject; Logfont = _SharedFont.Logfont; _SharedFont.ReferenceCount++; } }
/// <summary> /// Equality (typed). /// </summary> public bool Equals(FontCacheKey other) { return family == other.family && script == other.script && size == other.size && style == other.style; }
/// <summary> /// Gets the font with the desired parameters for measuring or drawing text. Works from cache. /// </summary> private static FontTray getFont(IdeoFamily fam, IdeoScript script, float size, FontStyle style) { // If font's already in cache, great: use that. FontCacheKey fck = new FontCacheKey(fam, script, size, style); if (fontCache.ContainsKey(fck)) return fontCache[fck]; // First time someone request a font like this. Instantiate and cache it. FontTray ftray = createFont(fam, script, size, style); fontCache[fck] = ftray; return ftray; }
private static FontProgramDescriptor GetFontNamesFromCache(FontCacheKey key) { return(fontNamesCache.Get(key)); }