edelib  2.0.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 FontInfo {
47  char face[EDELIB_FONT_CACHE_FACE_LEN];
49  int sizes[64];
51  int nsizes;
53  int type;
54 };
55 
71 class 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  void for_each_font(void (*) (const char *n, FontInfo *, void *), void *data = NULL);
108 
115  void for_each_font_sorted(void (*) (const char *n, FontInfo *, void *), void *data = NULL);
116 
125  static int init_db(const char *dir, const char *db = "edelib-font-cache", const char *prefix = "ede");
126 
128  static int init_db(void);
129 };
130 
136 bool font_cache_find(const char *face, Fl_Font &f, int &s, Fl_Font df = FL_HELVETICA, int ds = 12);
137 
138 EDELIB_NS_END
139 #endif
140