e59dbdb21b79cf95690ea8c22975c00617555aa0
[oweals/cde.git] / cde / programs / dtinfo / dtinfo / src / OnlineRender / FontCache.hh
1 // $XConsortium: FontCache.hh /main/6 1996/08/30 11:52:57 rcs $
2 #ifndef _FontCache_hh
3 #define _FontCache_hh
4
5 //#include <StyleSheet/cde_next.h>
6 #include "dti_cc/CC_String.h"
7 #include "dti_cc/cc_hdict.h"
8
9 class FontEntry ;
10 class FontList ;
11 class FontCache
12 {
13 public:
14   FontCache();
15   ~FontCache();
16
17   // returns an xlfd
18   // scale factor is current font scale from preferences dialog 
19   const char *lookup(const char *family,
20                      const char *weight,
21                      const char *slant,
22                      int         ptsize,
23                      const char *charset,
24                      int         scale_factor,
25                      const char *fallback = NULL);
26                      
27
28 private:
29   const char *getxlfd(const char *family, int bold,
30                       int italic, const char* charset, int size, 
31                       const char *fallback = NULL);
32
33 private:
34   
35   hashTable<FontEntry, char>    f_cache;
36   hashTable<CC_String, FontList>        f_fontlist;
37
38 };
39
40 class FontEntry
41 {
42 public:
43   FontEntry(const char *family,
44             const char *weight,
45             const char *slant,
46             const char *charset,
47             int         ptsize);
48
49   FontEntry(const FontEntry &);
50   ~FontEntry();
51
52   bool operator ==(const FontEntry &) const;
53
54   unsigned hash() const;
55
56 private:
57   CC_String     f_family ;
58   CC_String     f_weight ;
59   CC_String     f_slant ;
60   CC_String     f_charset ;
61   int           f_ptsize ;
62
63 };
64
65 class FontList
66 {
67 public:
68   FontList()                    // for scalable fonts 
69   : f_names(0), f_count(0)
70     {}
71
72   FontList(int count, const char **names) ;
73   ~FontList();
74   const char **names() { return f_names ; }
75   int          count() { return f_count ; }
76
77   int          scaleable() { return f_names == 0 ; }
78 private:
79   const char    **f_names ;
80   int             f_count ;
81 };
82
83
84
85 #endif /* _FontCache_hh */
86 /* DO NOT ADD ANY LINES AFTER THIS #endif */