[theme] setting fonts
This commit is contained in:
parent
e5dbad88d3
commit
da031f297e
|
@ -2,6 +2,12 @@
|
|||
#include "../util.h"
|
||||
#include "../util/region.h"
|
||||
|
||||
static const char* default_font_path(struct rgn* rgn)
|
||||
{
|
||||
(void) rgn;
|
||||
return "/usr/share/fonts/liberation/LiberationSans-Regular.ttf";
|
||||
}
|
||||
|
||||
static void theme_init(struct ax_theme* thm)
|
||||
{
|
||||
thm->colors[AX_COLOR_BACKGROUND] = 0xffffff;
|
||||
|
@ -47,30 +53,41 @@ void ax__theme_set_font(
|
|||
enum ax_font_cat cat,
|
||||
const char* path, size_t size)
|
||||
{
|
||||
const char** dst_path;
|
||||
|
||||
if (cat == AX_FONT__DEFAULT) {
|
||||
dst_path = &thmb->dflt_font_path;
|
||||
thmb->dflt_font_path = rstrdup(thmb->rgn, path);
|
||||
} else {
|
||||
ASSERT(cat < AX_FONT__COUNT, "invalid font category");
|
||||
dst_path = &thmb->thm.font_path[cat];
|
||||
thmb->thm.font_size[cat] = size;
|
||||
thmb->thm.font_path[cat] = rstrdup(thmb->rgn, path);
|
||||
}
|
||||
|
||||
char* new_path;
|
||||
UNIMPLEMENTED();
|
||||
*dst_path = new_path;
|
||||
}
|
||||
|
||||
void ax__theme_builder_finish(
|
||||
struct ax_theme_builder* thmb,
|
||||
struct rgn* rgn,
|
||||
struct rgn* dst_rgn,
|
||||
struct ax_theme** out_thm)
|
||||
{
|
||||
struct ax_theme* thm = ralloc_typed(rgn, struct ax_theme, 1);
|
||||
if (out_thm == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
struct ax_theme* thm = ralloc_typed(dst_rgn, struct ax_theme, 1);
|
||||
*thm = thmb->thm;
|
||||
if (out_thm != NULL) {
|
||||
*out_thm = thm;
|
||||
*out_thm = thm;
|
||||
|
||||
// fix font path strings by copying into dest region
|
||||
const char* dflt_font_path;
|
||||
if (thmb->dflt_font_path != NULL) {
|
||||
dflt_font_path = rstrdup(dst_rgn, thmb->dflt_font_path);
|
||||
} else {
|
||||
dflt_font_path = default_font_path(dst_rgn);
|
||||
}
|
||||
for (size_t i = 0; i < AX_FONT__COUNT; i++) {
|
||||
if (thm->font_path[i] == NULL) {
|
||||
thm->font_path[i] = dflt_font_path;
|
||||
} else {
|
||||
thm->font_path[i] = rstrdup(dst_rgn, thm->font_path[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,7 @@ void ax__theme_set_font(
|
|||
|
||||
void ax__theme_builder_finish(
|
||||
struct ax_theme_builder* thmb,
|
||||
struct rgn* rgn,
|
||||
struct rgn* dst_rgn,
|
||||
struct ax_theme** out_thm);
|
||||
|
||||
static inline int64_t ax__theme_color(
|
||||
|
|
Loading…
Reference in New Issue