/**
 * Copyright (c) 2021 Dominic Masters
 * 
 * This software is released under the MIT License.
 * https://opensource.org/licenses/MIT
 */

#pragma once

#include <dawn/dawn.h>
#include "../texture.h"
#include "../primitive.h"
#include "../primitives/quad.h"

/**
 * Initializes Font from raw TTF data.
 * @param font Font to initialize
 * @param data Data to intialize for.
 */
void fontInit(font_t *font, char *data);

/**
 * Clean up a previously loaded font
 * @param font Loaded font.
 */
void fontDispose(font_t *Font);


/**
 * Measures (and calculates the quads for) a text prior to rendering it.
 * 
 * @param font Font to use for rendering and measuring
 * @param text Text to measure/render.
 * @param scale Scale of the text.
 * @returns Font info calculated.
 */
fonttextinfo_t * fontGetTextInfo(font_t *font, char *text, float scale);

/**
 * Disposes a previously calculated font info struct..
 * @param info Info to dispose.
 */
void fontTextInfoDispose(fonttextinfo_t *info);


/**
 * Buffers the vertices of a font text onto a primitive. Requires some info
 * about how the font is meant to render from the text info section.
 * 
 * @param font Font to render.
 * @param primitive Primitive to render into.
 * @param info The precalculated text info.
 */
void fontTextBuffer(font_t *font, primitive_t *primitive, fonttextinfo_t *info);

/**
 * Initializes an uninitialized primitive for rendering.
 * 
 * @param font Font to render.
 * @param primitive Primitive to render into.
 * @param info Text Info to use while rendering.
 */
void fontTextInit(font_t *font, primitive_t *primitive, fonttextinfo_t *info);