]> git.mdlowis.com Git - proto/aos.git/commitdiff
started implementing font loading function
authorMichael D. Lowis <mike.lowis@gentex.com>
Thu, 1 Oct 2020 20:59:10 +0000 (16:59 -0400)
committerMichael D. Lowis <mike.lowis@gentex.com>
Thu, 1 Oct 2020 20:59:10 +0000 (16:59 -0400)
inc/libui.h
src/libui/font_load.c [new file with mode: 0644]
src/libui/libui_impl.h

index b074aafedee3164629d3a04cd4cabfd7edcaf7d5..984aaee7c1a7627adc7be1acbd9b10742bcd0786 100644 (file)
@@ -1,6 +1,10 @@
+typedef struct UIFont UIFont;
 typedef struct UIWin UIWin;
 
 UIWin* WindowCreate(char* title);
 void WindowDelete(UIWin* win);
 void WindowShow(UIWin* win);
 void WindowHide(UIWin* win);
+
+UIFont FontLoad(char* patt);
+void FontClose(UIFont font);
\ No newline at end of file
diff --git a/src/libui/font_load.c b/src/libui/font_load.c
new file mode 100644 (file)
index 0000000..71eed5c
--- /dev/null
@@ -0,0 +1,36 @@
+#include <stdc.h>
+#include <liba.h>
+#include <libui.h>
+#include "libui_impl.h"
+
+UIFont FontLoad(char* patt)
+{
+    static bool inited = false;
+    if (!inited && !FcInit())
+    {
+        fatal("failed to initialize fontconfig");
+    }
+    inited = true;
+
+    XftFont* font = NULL;
+    FcPattern* pattern = FcNameParse((FcChar8 *)patt);
+    if (pattern)
+    {
+//        /* load the base font */
+//        FcResult result;
+//        FcPattern* match = XftFontMatch(X.display, X.screen_num, pattern, &result);
+//        if (match)
+//        {
+//            font = XftFontOpenPattern(X.display, match);
+//        }
+//        FcPatternDestroy(pattern);
+//        FcPatternDestroy(match);
+    }
+
+    if (!font)
+    {
+        fatal("failed to load font");
+    }
+
+    return (UIFont){ .font = font };
+}
index 31ba9b9509c829de3865c42a95fdca579d7ca167..1da7734ffda5b8618ff36ed8100cd4b2b2743e10 100644 (file)
@@ -2,6 +2,10 @@
 #include <X11/Xutil.h>
 #include <X11/Xft/Xft.h>
 
+struct UIFont {
+    XftFont* font;
+};
+
 struct UIWin
 {
     struct UIWin* next;