Example #1
0
 private static void PutFontNamesToCache(FontCacheKey key, FontProgramDescriptor descriptor)
 {
     if (descriptor != null)
     {
         fontNamesCache.Put(key, descriptor);
     }
 }
Example #2
0
 /// <summary>
 /// Equality (typed).
 /// </summary>
 public bool Equals(FontCacheKey other)
 {
     return(family == other.family &&
            script == other.script &&
            size == other.size &&
            style == other.style);
 }
Example #3
0
        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);
        }
Example #4
0
        /// <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);
        }
Example #5
0
        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++;
            }
        }
Example #6
0
 /// <summary>
 /// Equality (typed).
 /// </summary>
 public bool Equals(FontCacheKey other)
 {
     return family == other.family &&
         script == other.script &&
         size == other.size &&
         style == other.style;
 }
Example #7
0
        /// <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;
        }
Example #8
0
 private static FontProgramDescriptor GetFontNamesFromCache(FontCacheKey key)
 {
     return(fontNamesCache.Get(key));
 }