edelib  2.1.0
FontCache.h
1 /*
2  * $Id: File.h 2967 2009-12-02 14:31:34Z karijes $
3  *
4  * Font database and cache facility
5  * Copyright (c) 2005-2011 edelib authors
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2 of the License, or (at your option) any later version.
11  *
12  * This library is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public License
18  * along with this library. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef __EDELIB_FONTCACHE_H__
22 #define __EDELIB_FONTCACHE_H__
23 
24 #include "edelib-global.h"
25 #include <FL/Enumerations.H>
26 
27 EDELIB_NS_BEGIN
28 
29 struct FontCache_P;
30 
35 #define EDELIB_FONT_CACHE_FACE_LEN 64
36 
45 struct EDELIB_API FontInfo {
47  char face[EDELIB_FONT_CACHE_FACE_LEN];
49  int sizes[64];
51  int nsizes;
53  int type;
54 };
55 
71 class EDELIB_API FontCache {
72 private:
73  FontCache_P *priv;
75 public:
77  FontCache() : priv(NULL) {}
78 
80  ~FontCache() { clear(); }
81 
86  bool load(const char *dir, const char *db = "edelib-font-cache", const char *prefix = "ede");
87 
89  bool load(void);
90 
92  void clear(void);
93 
95  int count(void) const;
96 
101  bool find(const char *n, Fl_Font &font, int &size);
102 
107  FontInfo *find(const char *n, int &size);
108 
113  void for_each_font(void (*) (const char *n, FontInfo *, void *), void *data = NULL);
114 
121  void for_each_font_sorted(void (*) (const char *n, FontInfo *, void *), void *data = NULL);
122 
131  static int init_db(const char *dir, const char *db = "edelib-font-cache", const char *prefix = "ede");
132 
134  static int init_db(void);
135 };
136 
142 EDELIB_API bool font_cache_find(const char *face, Fl_Font &f, int &s, Fl_Font df = FL_HELVETICA, int ds = 12);
143 
144 EDELIB_NS_END
145 #endif
146 
~FontCache()
Definition: FontCache.h:80
Base structure for storing font information; used by FontCache.
Definition: FontCache.h:45
FontCache()
Definition: FontCache.h:77
#define E_DISABLE_CLASS_COPY(klass)
Definition: edelib-global.h:161
Allow readable font names and cache their access.
Definition: FontCache.h:71
int nsizes
Definition: FontCache.h:51
bool font_cache_find(const char *face, Fl_Font &f, int &s, Fl_Font df=FL_HELVETICA, int ds=12)
int type
Definition: FontCache.h:53