~halega/+junk/sharpdevelop

« back to all changes in this revision

Viewing changes to src/AddIns/Misc/Reports/ICSharpCode.Reports.Core/Project/Globals/FontCache.cs

  • Committer: sk
  • Date: 2011-09-10 05:17:57 UTC
  • Revision ID: halega@halega.com-20110910051757-qfouz1llya9m6boy
4.1.0.7915 Release Candidate 1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
 
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
 
3
 
 
4
using System;
 
5
using System.Collections;
 
6
using System.Drawing;
 
7
 
 
8
namespace ICSharpCode.Reports.Core.Globals
 
9
{
 
10
        /// <summary>
 
11
        /// Description of FontCache.
 
12
        /// </summary>
 
13
        public class FontCache:IDisposable
 
14
        {
 
15
                Hashtable Fonts=new Hashtable();
 
16
                
 
17
                public FontCache()
 
18
                {
 
19
                }
 
20
 
 
21
                
 
22
                protected virtual Font GetFont(string family, float size, FontStyle style)
 
23
                {
 
24
                        string s=family+size.ToString(System.Globalization.CultureInfo.InvariantCulture)+((int)style).ToString(System.Globalization.CultureInfo.InvariantCulture);
 
25
                        if(Fonts.Contains(s))
 
26
 
 
27
                                return (Font)Fonts[s];
 
28
                        Font f=new Font(family,size,style);
 
29
                        Fonts.Add(s,f);
 
30
                        return f;
 
31
                }
 
32
 
 
33
                
 
34
                public void Dispose ()
 
35
                {
 
36
                        this.Dispose(true);
 
37
                }
 
38
                
 
39
 
 
40
                public void Dispose(bool disposing)
 
41
                {
 
42
                        foreach(Font f in Fonts.Values)
 
43
                                f.Dispose();
 
44
                        Fonts.Clear();
 
45
                }
 
46
        }
 
47
}