commit a15b2d56b0bff9904c63ef3965206f8d2ba7c3f0
parent 730d90a1914d1ae9f136a5a2f7ae403e8ef58e2e
Author: nibo <nibo@relim.de>
Date: Tue, 2 Jul 2024 18:21:59 +0200
Rename FS_NORMAL to FS_REGULAR
Diffstat:
3 files changed, 40 insertions(+), 14 deletions(-)
diff --git a/chordpro.c b/chordpro.c
@@ -142,8 +142,8 @@ const char *the_font_style(enum FontStyle style)
switch (style) {
case FS_EMPTY:
return "FS_EMPTY";
- case FS_NORMAL:
- return "FS_NORMAL";
+ case FS_REGULAR:
+ return "FS_REGULAR";
case FS_OBLIQUE:
return "FS_OBLIQUE";
case FS_ITALIC:
@@ -349,7 +349,7 @@ struct Font *cho_font_new(void)
struct Font *font = malloc(sizeof(struct Font));
font->name = NULL;
font->family = FF_NORMAL;
- font->style = FS_NORMAL;
+ font->style = FS_REGULAR;
font->weight = FW_NORMAL;
font->size = DEFAULT_FONT_SIZE;
return font;
@@ -406,14 +406,23 @@ enum FontStyle cho_font_style_parse(const char *str)
} else if (strcasecmp(str, "oblique") == 0) {
return FS_OBLIQUE;
} else if (strcasecmp(str, "normal") == 0) {
- return FS_NORMAL;
+ return FS_REGULAR;
} else if (strcasecmp(str, "regular") == 0) {
- return FS_NORMAL;
+ return FS_REGULAR;
} else {
return FS_EMPTY;
}
}
+const char *cho_font_style_to_string(enum FontStyle style)
+{
+ if (style == FS_ITALIC)
+ return "italic";
+ if (style == FS_OBLIQUE)
+ return "oblique";
+ return "regular";
+}
+
enum FontWeight cho_font_weight_parse(const char *str)
{
if (strcasecmp(str, "bold") == 0) {
@@ -427,6 +436,20 @@ enum FontWeight cho_font_weight_parse(const char *str)
}
}
+const char *cho_font_weight_to_string(enum FontWeight weight)
+{
+ if (weight == FW_BOLD)
+ return "bold";
+ return "regular";
+}
+
+int cho_font_weight_to_int(enum FontWeight weight)
+{
+ if (weight == FW_BOLD)
+ return 200;
+ return 80;
+}
+
struct Style *cho_style_new(void)
{
struct Style *style = malloc(sizeof(struct Style));
@@ -530,7 +553,7 @@ struct Font *cho_style_font_desc_parse(const char *str)
if (stop_at == -1)
stop_at = w;
} else if (strcasecmp(words[w], "normal") == 0) {
- font->style = FS_NORMAL;
+ font->style = FS_REGULAR;
if (stop_at == -1)
stop_at = w;
} else if (strcasecmp(words[w], "sans") == 0) {
@@ -668,7 +691,7 @@ struct Style *cho_style_get(const char *tag_name, struct Attr **attrs, struct St
}
} else if (strcmp(attrs[a]->name, "style") == 0) {
if (strcmp(attrs[a]->value, "normal") == 0) {
- style->font->style = FS_NORMAL;
+ style->font->style = FS_REGULAR;
} else if (strcmp(attrs[a]->value, "oblique") == 0) {
style->font->style = FS_OBLIQUE;
} else if (strcmp(attrs[a]->value, "italic") == 0) {
diff --git a/chordpro.h b/chordpro.h
@@ -166,7 +166,10 @@ struct Font *cho_font_new(void);
void cho_font_free(struct Font *font);
void cho_fonts_free(struct Font **fonts);
enum FontStyle cho_font_style_parse(const char *str);
+const char *cho_font_style_to_string(enum FontStyle style);
enum FontWeight cho_font_weight_parse(const char *str);
+const char *cho_font_weight_to_string(enum FontWeight weight);
+int cho_font_weight_to_int(enum FontWeight weight);
/* Debugging */
void cho_font_print(struct Font *font);
diff --git a/config.c b/config.c
@@ -10,22 +10,22 @@ struct Config *config_load_default(void)
struct Config *config = malloc(sizeof(struct Config));
config->title = malloc(sizeof(struct ConfigSection));
config->title->font_name = strdup("Inter");
- config->title->font_style = FS_NORMAL;
+ config->title->font_style = FS_REGULAR;
config->title->font_weight = FW_BOLD;
config->title->font_size = 18.0;
config->text = malloc(sizeof(struct ConfigSection));
config->text->font_name = strdup("Inter");
- config->text->font_style = FS_NORMAL;
+ config->text->font_style = FS_REGULAR;
config->text->font_weight = FW_NORMAL;
config->text->font_size = 14.0;
config->chord = malloc(sizeof(struct ConfigSection));
config->chord->font_name = strdup("Inter");
- config->chord->font_style = FS_NORMAL;
+ config->chord->font_style = FS_REGULAR;
config->chord->font_weight = FW_BOLD;
config->chord->font_size = 14.0;
config->comment = malloc(sizeof(struct ConfigSection));
config->comment->font_name = strdup("Inter");
- config->comment->font_style = FS_NORMAL;
+ config->comment->font_style = FS_REGULAR;
config->comment->font_weight = FW_NORMAL;
config->comment->font_size = 14.0;
config->comment_italic = malloc(sizeof(struct ConfigSection));
@@ -35,17 +35,17 @@ struct Config *config_load_default(void)
config->comment_italic->font_size = 14.0;
config->comment_box = malloc(sizeof(struct ConfigSection));
config->comment_box->font_name = strdup("Inter");
- config->comment_box->font_style = FS_NORMAL;
+ config->comment_box->font_style = FS_REGULAR;
config->comment_box->font_weight = FW_NORMAL;
config->comment_box->font_size = 14.0;
config->tab = malloc(sizeof(struct ConfigSection));
config->tab->font_name = strdup("Inter");
- config->tab->font_style = FS_NORMAL;
+ config->tab->font_style = FS_REGULAR;
config->tab->font_weight = FW_NORMAL;
config->tab->font_size = 14.0;
config->grid = malloc(sizeof(struct ConfigSection));
config->grid->font_name = strdup("Inter");
- config->grid->font_style = FS_NORMAL;
+ config->grid->font_style = FS_REGULAR;
config->grid->font_weight = FW_BOLD;
config->grid->font_size = 14.0;
return config;