00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __GU_FontTable_h__
00021 #define __GU_FontTable_h__
00022
00023 #include "GU_API.h"
00024 #include <sys/types.h>
00025 #include <UT/UT_String.h>
00026 #include <UT/UT_PtrArray.h>
00027
00028 class UT_PathSearch;
00029 class UT_Interrupt;
00030
00031 class GU_API GU_FontEntry {
00032 public:
00033 GU_FontEntry(const char *path, const char *name);
00034
00035 const char *getPath() const { return myPath; }
00036 const char *getName() const { return myName; }
00037
00038 private:
00039 UT_String myPath;
00040 UT_String myName;
00041 };
00042
00043
00044 class GU_API GU_FontTable {
00045 public:
00046 GU_FontTable();
00047 ~GU_FontTable();
00048
00049
00050
00051 int save();
00052 void setIndexFile(const char *path);
00053
00054 int getNPaths() const { return 1; }
00055 const char *getPath() const { return myIndexFile; }
00056
00057
00058
00059 int addFont(const char *path, int trim_to_path=1, int verbose=0);
00060 void removeFont(int which);
00061 void removeFont(const char *fontName, const char *path = 0);
00062
00063
00064 int rescanFontPath(UT_Interrupt *boss, int verbose);
00065
00066 void updateIfNeeded();
00067
00068 const UT_PtrArray<GU_FontEntry *> &getTable() const { return myTable; }
00069
00070 private:
00071 void getPaths();
00072 const GU_FontEntry *findFontPath(const char *path);
00073 const GU_FontEntry *findFontName(const char *name);
00074 int loadTable(const char *path);
00075 int saveTable(const char *path, int append=1);
00076 void clearTable();
00077
00078 private:
00079 UT_PtrArray<GU_FontEntry *> myTable;
00080 UT_String myIndexFile;
00081 const UT_PathSearch *myPathSearch;
00082 time_t myIndexTimeStamp;
00083 int myModified;
00084 };
00085
00086 #endif