#include "resource_font.h"

/* Initializes font resource. */
bool
resource_font_init(Resources* self, FontType type)
{
	if (!font_init(&self->fonts[type], FONT_PATHS[type], FONT_SIZES[type]))
	{
		printf(STRING_RESOURCE_ERROR, FONT_PATHS[type]);
		return false;
	}

	printf(STRING_RESOURCE_INIT, FONT_PATHS[type]);

	return true;
}

/* Frees font resources. */
void
resource_font_free(Resources* self, FontType type)
{
	if (self->fonts[type].isInit)
	{
		font_free(&self->fonts[type]);

		printf(STRING_RESOURCE_FREE, FONT_PATHS[type]);
	}
}

/* Given an array, initializes font resources. */
void
resource_font_state_init(Resources* self, const FontType* types, u32 count)
{
	for (s32 i = 0; i < (s32)count; i++)
		resource_font_init(self, types[i]);
}

/* Frees font resources. */
void
resource_font_state_free(Resources* self, const FontType* types, u32 count)
{
	for (s32 i = 0; i < (s32)count; i++)
		resource_font_free(self, types[i]);
}
