79 lines
2.2 KiB
C
79 lines
2.2 KiB
C
/**
|
|
* 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);
|
|
|
|
/**
|
|
* Generates information about how the given font will render the given text.
|
|
* @param font Font to get the information for.
|
|
* @param text Text that will be used to render
|
|
* @return Some information about how the font will render the text.
|
|
*/
|
|
fonttextinfo_t fontGetTextInfo(font_t *font, char *text);
|
|
|
|
/**
|
|
* 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 info Info about the text being rendered / measured.
|
|
* @param scale Scale of the text.
|
|
* @returns Font measurement calculation.
|
|
*/
|
|
fontmeasure_t * fontTextMeasure(font_t *font, char *text, fonttextinfo_t *info,
|
|
float scale
|
|
);
|
|
|
|
/**
|
|
* Disposes a previously calculated font text measurement.
|
|
* @param measure Measurement to dispose.
|
|
*/
|
|
void fontTextMeasureDispose(fontmeasure_t *measure);
|
|
|
|
/**
|
|
* 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 text Text to render.
|
|
* @param measure The precalculated measurement.
|
|
*/
|
|
void fontTextBufferFromMeasure(font_t *font, primitive_t *primitive, char *text,
|
|
fontmeasure_t *measure
|
|
);
|
|
|
|
/**
|
|
* Initializes an uninitialized primitive for rendering.
|
|
*
|
|
* @param font Font to render.
|
|
* @param primitive Primitive to render into.
|
|
* @param text Text to render.
|
|
* @param info Text Info to use while rendering.
|
|
* @param measure The pre calcuted font measurement.
|
|
*/
|
|
void fontTextInitFromMeasure(font_t *font, primitive_t *primitive, char *text,
|
|
fonttextinfo_t *info, fontmeasure_t *measure
|
|
);
|
|
|
|
/**
|
|
* Clean up a previously loaded font
|
|
* @param font Loaded font.
|
|
*/
|
|
void fontDispose(font_t *Font); |