aboutsummaryrefslogtreecommitdiffstats
path: root/libfonts_get_default_font_name.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--libfonts_get_default_font_name.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/libfonts_get_default_font_name.c b/libfonts_get_default_font_name.c
new file mode 100644
index 0000000..5fe7704
--- /dev/null
+++ b/libfonts_get_default_font_name.c
@@ -0,0 +1,49 @@
+/* See LICENSE file for copyright and license details. */
+#include "common.h"
+
+
+ssize_t
+libfonts_get_default_font_name(enum libfonts_default_font font, char *name, size_t size, size_t index)
+{
+ const char *alias;
+ size_t len;
+
+ if (font == LIBFONTS_DEFAULT_SANS_SERIF) {
+ if (index == 0)
+ alias = "sans-serif";
+ else if (index == 1)
+ alias = "sans serif";
+ else if (index == 2)
+ alias = "sans";
+ else
+ return 0;
+
+ } else if (font == LIBFONTS_DEFAULT_SERIF) {
+ if (index == 0)
+ alias = "serif";
+ else
+ return 0;
+
+ } else if (font == LIBFONTS_DEFAULT_MONOSPACE) {
+ if (index == 0)
+ alias = "monospace";
+ else if (index == 1)
+ alias = "monospaced";
+ else
+ return 0;
+
+ } else {
+ errno = EINVAL;
+ return -1;
+ }
+
+ len = strlen(alias);
+ if (size) {
+ size -= 1;
+ if (size > len)
+ size = len;
+ memcpy(name, alias, size);
+ name[size] = '\0';
+ }
+ return (ssize_t)len;
+}