glfttest_SOURCES=test.c
lib_LTLIBRARIES=libglft.la
-libglft_la_SOURCES=init.c
-
-
-noinst_HEADERS=glft.h
+libglft_la_SOURCES=\
+ init.c \
+ font.c \
+ debug.c
+
+noinst_HEADERS=\
+ glft.h \
+ font.h \
+ init.h \
+ debug.h
MAINTAINERCLEANFILES=Makefile.in
--- /dev/null
+#include "font.h"
+#include "glft.h"
+#include "init.h"
+#include "debug.h"
+#include <assert.h>
+#include <stdlib.h>
+
+struct GlftFont *GlftFontOpen(const char *name)
+{
+ struct GlftFont *font;
+ FcPattern *pat;
+ FcFontSet *set;
+ double alpha;
+
+ assert(init_done);
+
+ pat = FcNameParse((const unsigned char*)name);
+ assert(pat);
+ set = FcFontSetCreate();
+ if (!FcFontSetAdd(set, pat)) {
+ FcPatternDestroy(pat);
+ FcFontSetDestroy(set);
+ GlftDebug("failed to load font\n");
+ return NULL;
+ }
+
+ font = malloc(sizeof(struct GlftFont));
+ font->set = set;
+ if (FcResultMatch != FcPatternGetBool(pat, "shadow", 0, &font->shadow))
+ font->shadow = FcFalse;
+ if (FcResultMatch !=
+ FcPatternGetInteger(pat, "shadowoffset", 0, &font->shadow_offset))
+ font->shadow_offset = 2;
+ if (FcResultMatch != FcPatternGetDouble(pat, "shadowalpha", 0, &alpha))
+ alpha = 0.5;
+ font->shadow_alpha = (float)alpha;
+ return font;
+}
+
+void GlftFontClose(struct GlftFont *font)
+{
+ if (font) {
+ FcFontSetDestroy(font->set);
+ free(font);
+ }
+}
#include <fontconfig/fontconfig.h>
-struct GlftFont;
+/* initialization */
FcBool GlftInit();
+/* fonts */
+
+struct GlftFont;
+
+struct GlftFont *GlftFontOpen(const char *name);
+
+void GlftFontClose(struct GlftFont *font);
+
+/* rendering */
+
#endif
#include "glft.h"
+#include <stdio.h>
-int main()
+int main(int argc, char **argv)
{
- GlftInit();
+ struct GlftFont *font;
+
+ if (argc < 2) {
+ printf("Usage: %s fontname\n", argv[0]);
+ return 1;
+ }
+
+ if (!GlftInit()) return 1;
+
+ font = GlftFontOpen(argv[1]);
+ GlftFontClose(font);
+
+ return 0;
}