edelib  2.0.0
edelib/FontCache.h
00001 /*
00002  * $Id: File.h 2967 2009-12-02 14:31:34Z karijes $
00003  *
00004  * Font database and cache facility
00005  * Copyright (c) 2005-2011 edelib authors
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Lesser General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2 of the License, or (at your option) any later version.
00011  *
00012  * This library is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00015  * Lesser General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Lesser General Public License
00018  * along with this library. If not, see <http://www.gnu.org/licenses/>.
00019  */
00020 
00021 #ifndef __EDELIB_FONTCACHE_H__
00022 #define __EDELIB_FONTCACHE_H__
00023 
00024 #include "edelib-global.h"
00025 #include <FL/Enumerations.H>
00026 
00027 EDELIB_NS_BEGIN
00028 
00029 struct FontCache_P;
00030 
00035 #define EDELIB_FONT_CACHE_FACE_LEN 64
00036 
00045 struct FontInfo {
00047         char face[EDELIB_FONT_CACHE_FACE_LEN];
00049         int  sizes[64];
00051         int  nsizes;
00053         int  type;
00054 };
00055 
00071 class FontCache {
00072 private:
00073         FontCache_P *priv;
00074         E_DISABLE_CLASS_COPY(FontCache)
00075 public:
00077         FontCache() : priv(NULL) {}
00078 
00080         ~FontCache() { clear(); }
00081 
00086         bool load(const char *dir, const char *db = "edelib-font-cache", const char *prefix = "ede");
00087 
00089         bool load(void);
00090 
00092         void clear(void);
00093 
00095         int count(void) const;
00096 
00101         bool find(const char *n, Fl_Font &font, int &size);
00102 
00107         void for_each_font(void (*) (const char *n, FontInfo *, void *), void *data = NULL);
00108 
00115         void for_each_font_sorted(void (*) (const char *n, FontInfo *, void *), void *data = NULL);
00116 
00125         static int init_db(const char *dir, const char *db = "edelib-font-cache", const char *prefix = "ede");
00126 
00128         static int init_db(void);
00129 };
00130 
00136 bool font_cache_find(const char *face, Fl_Font &f, int &s, Fl_Font df = FL_HELVETICA, int ds = 12);
00137 
00138 EDELIB_NS_END
00139 #endif
00140