Add missing license headers on *.hh files and others
[oweals/cde.git] / cde / programs / dtinfo / dtinfo / src / OnlineRender / FontCache.hh
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these libraries and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 // $XConsortium: FontCache.hh /main/6 1996/08/30 11:52:57 rcs $
24 #ifndef _FontCache_hh
25 #define _FontCache_hh
26
27 //#include <StyleSheet/cde_next.h>
28 #include "dti_cc/CC_String.h"
29 #include "dti_cc/cc_hdict.h"
30
31 class FontEntry ;
32 class FontList ;
33 class FontCache
34 {
35 public:
36   FontCache();
37   ~FontCache();
38
39   // returns an xlfd
40   // scale factor is current font scale from preferences dialog 
41   const char *lookup(const char *family,
42                      const char *weight,
43                      const char *slant,
44                      int         ptsize,
45                      const char *charset,
46                      int         scale_factor,
47                      const char *fallback = NULL);
48                      
49
50 private:
51   const char *getxlfd(const char *family, int bold,
52                       int italic, const char* charset, int size, 
53                       const char *fallback = NULL);
54
55 private:
56   
57   hashTable<FontEntry, char>    f_cache;
58   hashTable<CC_String, FontList>        f_fontlist;
59
60 };
61
62 class FontEntry
63 {
64 public:
65   FontEntry(const char *family,
66             const char *weight,
67             const char *slant,
68             const char *charset,
69             int         ptsize);
70
71   FontEntry(const FontEntry &);
72   ~FontEntry();
73
74   bool operator ==(const FontEntry &) const;
75
76   unsigned hash() const;
77
78 private:
79   CC_String     f_family ;
80   CC_String     f_weight ;
81   CC_String     f_slant ;
82   CC_String     f_charset ;
83   int           f_ptsize ;
84
85 };
86
87 class FontList
88 {
89 public:
90   FontList()                    // for scalable fonts 
91   : f_names(0), f_count(0)
92     {}
93
94   FontList(int count, const char **names) ;
95   ~FontList();
96   const char **names() { return f_names ; }
97   int          count() { return f_count ; }
98
99   int          scaleable() { return f_names == 0 ; }
100 private:
101   const char    **f_names ;
102   int             f_count ;
103 };
104
105
106
107 #endif /* _FontCache_hh */
108 /* DO NOT ADD ANY LINES AFTER THIS #endif */