Files
libsst/Include/ZRendererUtil/ZFontRenderer.hpp
2026-04-03 00:22:39 -05:00

165 lines
3.9 KiB
C++

/*
ZFontRenderer.h
Author: Patrick Baggett <ptbaggett@762studios.com>
Purpose: TODO
Changelog
2011/09/18 - creation (ptbaggett)
*/
#pragma once
#ifndef _ZFONTRENDERER_HPP
#define _ZFONTRENDERER_HPP
#include <SST/SST_Mat44.h>
#include <ZRenderer/ZRenderer.hpp>
//Font Face
typedef void* ZFontFace;
//ZFontBounds struct, used as such
// top --- right
// | |
// left --- bottom
struct ZFontBounds
{
//ZFontBounds of a rectangle (lower-left orientation)
int left, bottom, right, top;
};
class ZFontRenderer
{
protected:
//Protected Constructor
ZFontRenderer() { }
public:
//Virtual Destructor
virtual ~ZFontRenderer() { }
/*
virtual public ZFontRenderer::createFontFace
Creates a font face from a memory image of a font file.
@param _pixelSize - The pixel size of a character. To use point size (ala MS Word), use (point size / 72.0) * DPI.
@param _fontData - The font file's data
@param _dataSize - The size in bytes of the file data.
@return (ZFontFace)
@context (all)
*/
virtual ZFontFace CreateFontFace(int _pixelSize, const void* _fontData, unsigned int _dataSize) = 0;
/*
virtual public ZFontRenderer::deleteFontFace
Deletes a font face. If this face is the currently active face, then the active face is set to NULL.
@param face - The font face to delete.
@return (void)
@context (all)
*/
virtual void DeleteFontFace(ZFontFace face) = 0;
/*
virtual public ZFontRenderer::beginText
Sets up render state to begin drawing text. The only legal functions to call between beginText(),
and endText() are renderText(), computeBounds(), and setColor().
@param _ctx - The ZFrameContext for this frame
@param _xform - The transformation
@return (void)
@context (all)
*/
virtual void BeginText(ZFrameContext _ctx, const SST_Mat44f& _xform) = 0;
/*
virtual public ZFontRenderer::endText
Restores render state when done drawing text, flushes any buffered text.
@return (void)
@context (all)
*/
virtual void EndText() = 0;
/*
virtual public ZFontRenderer::renderText
Renders text at the given XY location
@param x - The left edge of the text
@param y - The bottom edge of the text
@param text - Some letters render below this line (e.g. the letter g's "tail").
@return (void)
@context (all)
*/
virtual void RenderText(int x, int y, const char* text) = 0;
/*
virtual public ZFontRenderer::computeBounds
Computes the bounding box for text, as if it was placed at the origin.
@param text - The text to compute a bounding box for.
@param bounds - Pointer to where the computed boundaries are stored.
@return (void)
@context (all)
*/
virtual void ComputeBounds(const char* text, ZFontBounds* bounds) = 0;
/*
virtual public ZFontRenderer::setColor
Sets the color of the text. Requires that there is a current font face, set with setFontFace().
@param r - The red component in the range of [0,1]
@param g - The green component in the range of [0,1]
@param b - The blue component in the range of [0,1]
@param a - The alpha (transparency) component in the range of [0,1]
@return (void)
@context (all)
*/
virtual void SetColor(float r, float g, float b, float a) = 0;
/*
virtual public ZFontRenderer::setColor
Sets a color with a packed 32-bit integer, converting to 4x32-bit floats first. Due to
endian-ness differences, don't typecast an char[4] to int* and then dereference it!
@param rgba - The RGBA color stored as (hex) 0xRRGGBBAA
@return (void)
@context (all)
*/
virtual void SetColor(unsigned int rgba) = 0;
/*
public ZFontRenderer::setFontFace
Sets the current font face.
@param face - The face to make current
@return (void)
@context (all)
*/
virtual void SetFontFace(ZFontFace face) = 0;
/*
public ZFontRenderer::getFontFace
Gets the current font face.
@return (ZFontFace) - Handle to the current font face. It is not reference counted.
@context (all)
*/
virtual ZFontFace GetFontFace() = 0;
};
#endif