summaryrefslogtreecommitdiff
path: root/ted-base.c
diff options
context:
space:
mode:
authorLeo Tenenbaum <pommicket@gmail.com>2021-01-22 16:25:05 -0500
committerLeo Tenenbaum <pommicket@gmail.com>2021-01-22 16:25:05 -0500
commit73a00e3b343526887579f698ca2db324cc4c7cee (patch)
tree213434234065c76e6fe0f8db9c1078937641989b /ted-base.c
parent968bbd92cf9bf9cc364baa973d81f4dcfa647ca3 (diff)
bold text for file selector cwd
Diffstat (limited to 'ted-base.c')
-rw-r--r--ted-base.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/ted-base.c b/ted-base.c
index 001cb94..d8acf0c 100644
--- a/ted-base.c
+++ b/ted-base.c
@@ -68,15 +68,17 @@ static Status ted_get_file(char const *name, char *out, size_t outsz) {
return false;
}
-static void ted_load_font(Ted *ted) {
+// Loads font from filename into *out, freeing any font that was previously there.
+// *out is left unchanged on failure.
+static void ted_load_font(Ted *ted, char const *filename, Font **out) {
char font_filename[TED_PATH_MAX];
- if (ted_get_file("assets/font.ttf", font_filename, sizeof font_filename)) {
+ if (ted_get_file(filename, font_filename, sizeof font_filename)) {
Font *font = text_font_load(font_filename, ted->settings.text_size);
if (font) {
- if (ted->font) {
- text_font_free(ted->font);
+ if (*out) {
+ text_font_free(*out);
}
- ted->font = font;
+ *out = font;
} else {
ted_seterr(ted, "Couldn't load font: %s", text_get_err());
text_clear_err();
@@ -84,6 +86,13 @@ static void ted_load_font(Ted *ted) {
} else {
ted_seterr(ted, "Couldn't find font file. There is probably a problem with your ted installation.");
}
+
+}
+
+// Load all the fonts ted will use.
+static void ted_load_fonts(Ted *ted) {
+ ted_load_font(ted, "assets/font.ttf", &ted->font);
+ ted_load_font(ted, "assets/font-bold.ttf", &ted->font_bold);
}
// returns buffer of new file, or NULL on failure