]> git.wh0rd.org - fontconfig.git/blobdiff - src/fcint.h
Add ref counting to font config patterns so that FcFontSort return values
[fontconfig.git] / src / fcint.h
index 2d9b13f7e1d3b8be8ce5a6746a432c309a986ffa..69187300aa39afc894bc2ac4265c7f71d9d930d6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $XFree86: $
+ * $XFree86: xc/lib/fontconfig/src/fcint.h,v 1.13 2002/06/03 08:31:15 keithp Exp $
  *
  * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
  *
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <libxml/parserInternals.h>
+#include <time.h>
 #include <fontconfig/fontconfig.h>
 #include <fontconfig/fcprivate.h>
-#include <fontconfig/fcxml.h>
+#include <fontconfig/fcfreetype.h>
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
@@ -44,6 +44,7 @@
 typedef struct _FcMatcher {
     char    *object;
     double  (*compare) (char *object, FcValue value1, FcValue value2);
+    int            priority;
 } FcMatcher;
 
 typedef struct _FcSymbolic {
@@ -55,6 +56,9 @@ typedef struct _FcSymbolic {
 #define FC_CONFIG_PATH "fonts.conf"
 #endif
 
+#define FC_FONT_FILE_INVALID   ((FcChar8 *) ".")
+#define FC_FONT_FILE_DIR       ((FcChar8 *) ".dir")
+
 #define FC_DBG_MATCH   1
 #define FC_DBG_MATCHV  2
 #define FC_DBG_EDIT    4
@@ -79,6 +83,9 @@ typedef struct _FcSymbolic {
 #define FC_MEM_STRING      11
 #define FC_MEM_LISTBUCK            12
 #define FC_MEM_NUM         13
+#define FC_MEM_STRSET      14
+#define FC_MEM_STRLIST     15
+#define FC_MEM_CONFIG      16
 
 typedef struct _FcValueList {
     struct _FcValueList    *next;
@@ -87,13 +94,14 @@ typedef struct _FcValueList {
 
 typedef struct _FcPatternElt {
     const char     *object;
-    FcValueList    *values;
+    FcValueList            *values;
 } FcPatternElt;
 
 struct _FcPattern {
     int                    num;
     int                    size;
-    FcPatternElt   *elts;
+    int                    ref;
+    FcPatternElt    *elts;
 };
 
 typedef enum _FcOp {
@@ -127,7 +135,7 @@ typedef struct _FcExpr {
 } FcExpr;
 
 typedef enum _FcQual {
-    FcQualAny, FcQualAll
+    FcQualAny, FcQualAll, FcQualFirst, FcQualNotFirst
 } FcQual;
 
 typedef struct _FcTest {
@@ -151,37 +159,37 @@ typedef struct _FcSubst {
     FcEdit             *edit;
 } FcSubst;
 
-typedef struct _FcCharLeaf FcCharLeaf;
-typedef struct _FcCharBranch FcCharBranch;
-typedef union  _FcCharNode FcCharNode;
-
-struct _FcCharLeaf {
+typedef struct _FcCharLeaf {
     FcChar32   map[256/32];
-};
+} FcCharLeaf;
 
-union _FcCharNode {
-    FcCharBranch    *branch;
-    FcCharLeaf     *leaf;
+struct _FcCharSet {
+    int                    ref;        /* reference count */
+    FcBool         constant;   /* in hash table constant */
+    int                    num;        /* size of leaves and numbers arrays */
+    FcCharLeaf     **leaves;
+    FcChar16       *numbers;
 };
 
-struct _FcCharBranch {
-    FcCharNode     nodes[256];
+struct _FcStrSet {
+    int                    ref;        /* reference count */
+    int                    num;
+    int                    size;
+    FcChar8        **strs;
 };
 
-struct _FcCharSet {
-    int                    levels;
-    int                    ref;        /* reference count */
-    FcBool         constant;   /* shared constant */
-    FcCharNode     node;
+struct _FcStrList {
+    FcStrSet       *set;
+    int                    n;
 };
 
-typedef struct _FcNameBuf {
+typedef struct _FcStrBuf {
     FcChar8 *buf;
     FcBool  allocated;
     FcBool  failed;
     int            len;
     int            size;
-} FcNameBuf;
+} FcStrBuf;
 
 typedef struct _FcFileCacheEnt {
     struct _FcFileCacheEnt *next;
@@ -202,6 +210,13 @@ struct _FcFileCache {
     int                        referenced;
 };
 
+struct _FcAtomic {
+    FcChar8    *file;          /* original file name */
+    FcChar8    *new;           /* temp file name -- write data here */
+    FcChar8    *lck;           /* lockfile name (used for locking) */
+    FcChar8    *tmp;           /* tmpfile name (used for locking) */
+};
+
 struct _FcBlanks {
     int                nblank;
     int                sblank;
@@ -214,18 +229,24 @@ struct _FcConfig {
      * cache file must be consulted before the directories are scanned,
      * and those directives may occur in any order
      */
-    FcChar8    **dirs;             /* directories containing fonts */
+    FcStrSet   *configDirs;        /* directories to scan for fonts */
     FcChar8    *cache;             /* name of per-user cache file */
     /*
      * Set of allowed blank chars -- used to
      * trim fonts of bogus glyphs
      */
     FcBlanks   *blanks;
+    /*
+     * List of directories containing fonts,
+     * built by recursively scanning the set 
+     * of configured directories
+     */
+    FcStrSet   *fontDirs;
     /*
      * Names of all of the configuration files used
      * to create this configuration
      */
-    FcChar8    **configFiles;      /* config files loaded */
+    FcStrSet   *configFiles;       /* config files loaded */
     /*
      * Substitution instructions for patterns and fonts;
      * maxObjects is used to allocate appropriate intermediate storage
@@ -241,8 +262,18 @@ struct _FcConfig {
      * match preferrentially
      */
     FcFontSet  *fonts[FcSetApplication + 1];
+    /*
+     * Fontconfig can periodically rescan the system configuration
+     * and font directories.  This rescanning occurs when font
+     * listing requests are made, but no more often than rescanInterval
+     * seconds apart.
+     */
+    time_t     rescanTime;         /* last time information was scanned */
+    int                rescanInterval;     /* interval between scans */
 };
  
+extern FcConfig        *_fcConfig;
+
 /* fcblanks.c */
 
 /* fccache.c */
@@ -259,6 +290,9 @@ FcFileCacheFind (FcFileCache        *cache,
 void
 FcFileCacheDestroy (FcFileCache        *cache);
 
+FcBool
+FcFileCacheValid (const FcChar8 *cache_file);
+
 void
 FcFileCacheLoad (FcFileCache   *cache,
                 const FcChar8  *cache_file);
@@ -274,13 +308,21 @@ FcFileCacheSave (FcFileCache      *cache,
                 const FcChar8  *cache_file);
 
 FcBool
-FcFileCacheReadDir (FcFontSet *set, const FcChar8 *cache_file);
+FcFileCacheReadDir (FcFontSet *set, FcStrSet *dirs, const FcChar8 *cache_file);
 
 FcBool
-FcFileCacheWriteDir (FcFontSet *set, const FcChar8 *cache_file);
+FcFileCacheWriteDir (FcFontSet *set, FcStrSet *dirs, const FcChar8 *cache_file);
     
 /* fccfg.c */
 
+FcBool
+FcConfigAddConfigDir (FcConfig     *config,
+                     const FcChar8 *d);
+
+FcBool
+FcConfigAddFontDir (FcConfig       *config,
+                   const FcChar8   *d);
+
 FcBool
 FcConfigAddDir (FcConfig       *config,
                const FcChar8   *d);
@@ -315,21 +357,15 @@ FcConfigCompareValue (const FcValue m,
 
 /* fccharset.c */
 FcBool
-FcNameUnparseCharSet (FcNameBuf *buf, const FcCharSet *c);
+FcNameUnparseCharSet (FcStrBuf *buf, const FcCharSet *c);
 
 FcCharSet *
 FcNameParseCharSet (FcChar8 *string);
 
 /* fcdbg.c */
-void
-FcValuePrint (FcValue v);
-
 void
 FcValueListPrint (FcValueList *l);
 
-void
-FcPatternPrint (FcPattern *p);
-
 void
 FcOpPrint (FcOp op);
 
@@ -345,9 +381,6 @@ FcEditPrint (FcEdit *edit);
 void
 FcSubstPrint (FcSubst *subst);
 
-void
-FcFontSetPrint (FcFontSet *s);
-
 int
 FcDebug (void);
 
@@ -372,7 +405,7 @@ char *
 FcConfigSaveField (const char *field);
 
 FcTest *
-FcTestCreate (FcQual qual, const char *field, FcOp compare, FcExpr *expr);
+FcTestCreate (FcQual qual, const FcChar8 *field, FcOp compare, FcExpr *expr);
 
 void
 FcTestDestroy (FcTest *test);
@@ -433,18 +466,15 @@ FcMemFree (int kind, int size);
 FcBool
 FcNameBool (FcChar8 *v, FcBool *result);
 
-FcBool
-FcNameBufChar (FcNameBuf *buf, FcChar8 c);
-
-FcBool
-FcNameBufString (FcNameBuf *buf, const FcChar8 *s);
-
 /* fcpat.c */
 void
 FcValueListDestroy (FcValueList *l);
     
 FcPatternElt *
-FcPatternFind (FcPattern *p, const char *object, FcBool insert);
+FcPatternFindElt (const FcPattern *p, const char *object);
+
+FcPatternElt *
+FcPatternInsertElt (FcPattern *p, const char *object);
 
 /* fcrender.c */
 
@@ -459,4 +489,22 @@ FcStrPlus (const FcChar8 *s1, const FcChar8 *s2);
 void
 FcStrFree (FcChar8 *s);
 
+void
+FcStrBufInit (FcStrBuf *buf, FcChar8 *init, int size);
+
+void
+FcStrBufDestroy (FcStrBuf *buf);
+
+FcChar8 *
+FcStrBufDone (FcStrBuf *buf);
+
+FcBool
+FcStrBufChar (FcStrBuf *buf, FcChar8 c);
+
+FcBool
+FcStrBufString (FcStrBuf *buf, const FcChar8 *s);
+
+FcBool
+FcStrBufData (FcStrBuf *buf, const FcChar8 *s, int len);
+
 #endif /* _FC_INT_H_ */