Nuclide
Software Development Kit for id Technology (BETA)
font.h
1/*
2 * Copyright (c) 2016-2022 Vera Visions LLC.
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
14 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*/
16
26typedef enum
27{
33
36typedef enumflags
37{
38 AF_LEFT,
39 AF_TOP,
40 AF_RIGHT,
41 AF_BOTTOM
42} alignflags_t;
43#define AF_NONE 0
44#define AF_DEFAULT (AF_TOP | AF_LEFT)
45#define AF_CENTER AF_NONE
46
48typedef struct
49{
50 int iID;
51 int iScaleX;
52 int iScaleY;
53 vector vecColor;
54 float flAlpha;
55 int iFlags;
56 string hexColor;
57} font_s;
58
63void Font_Load(string strFile, font_s &fntNew);
64
65/* standard drawing */
71void Font_DrawText(vector vecOrigin, string strText, font_s fnt);
78void Font_DrawText_A(vector vecOrigin, string strText, float a, font_s fnt);
85void Font_DrawText_RGB(vector vecOrigin, string strText, vector col, font_s fnt);
94void Font_DrawText_RGBA(vector vecOrigin, string strText, vector col, float a, font_s fnt);
95
96/* right aligned variants */
99void Font_DrawRText(vector vecOrigin, string strText, font_s fnt);
102void Font_DrawRText_A(vector vecOrigin, string strText, float a, font_s fnt);
105void Font_DrawRText_RGB(vector vecOrigin, string strText, vector col, font_s fnt);
108void Font_DrawRText_RGBA(vector vecOrigin, string strText, vector col, float a, font_s fnt);
109
117void Font_DrawField(vector vecOrigin, vector vecSize, string strText, font_s fnt, alignflags_t iAlignFlags);
118
127void Font_DrawFieldAtHeight(vector vecOrigin, vector vecSize, int iTextHeight, string strText, font_s fnt, alignflags_t iAlignFlags);
128
133string Font_RGBtoHex(vector vecColor);
134
140int Font_GetHeight(font_s fnt);
141
155float Font_StringWidth(string strText, bool hasColor, font_s fnt);
156
167float Font_GetID(font_s fnt);
168
169void Font_DrawTextScroll(vector vecOrigin, string strText, vector canvasSize, font_s fnt);
170void Font_DrawTextScroll_A(vector vecOrigin, string strText, vector canvasSize, float a, font_s fnt);
171void Font_DrawTextScroll_RGB(vector vecOrigin, string strText, vector canvasSize, vector rgb, font_s fnt);
172void Font_DrawTextScroll_RGBA(vector vecOrigin, string strText, vector canvasSize, vector rgb, float a, font_s fnt);
173 // end of client
int Font_GetHeight(font_s fnt)
Returns the height of a specified font in pixels.
Definition: font.qc:295
void Font_Load(string strFile, font_s &fntNew)
Load a desired .font definition into memory.
Definition: font.qc:24
void Font_DrawTextScroll_RGB(vector vecOrigin, string strText, vector canvasSize, vector rgb, font_s fnt)
Definition: font.qc:175
void Font_DrawField(vector vecOrigin, vector vecSize, string strText, font_s fnt, alignflags_t iAlignFlags)
Draws a textfield with line wrapping.
Definition: font.qc:256
void Font_DrawRText_A(vector vecOrigin, string strText, float a, font_s fnt)
Right-aligned variant of Font_DrawText_A.
Definition: font.qc:235
void Font_DrawText_RGBA(vector vecOrigin, string strText, vector col, float a, font_s fnt)
Draw tinted and alpha blended text on the screen at the desired position with a desired font.
Definition: font.qc:220
void Font_DrawRText_RGBA(vector vecOrigin, string strText, vector col, float a, font_s fnt)
Right-aligned variant of Font_DrawText_RGBA.
Definition: font.qc:249
void Font_DrawText_RGB(vector vecOrigin, string strText, vector col, font_s fnt)
Draw tinted text on the screen at the desired position with a desired font.
Definition: font.qc:212
void Font_DrawTextScroll(vector vecOrigin, string strText, vector canvasSize, font_s fnt)
Definition: font.qc:163
void Font_DrawTextScroll_RGBA(vector vecOrigin, string strText, vector canvasSize, vector rgb, float a, font_s fnt)
Definition: font.qc:181
drawflag_t
Flags for 2D drawing operations.
Definition: font.h:27
void Font_DrawRText(vector vecOrigin, string strText, font_s fnt)
Right-aligned variant of Font_DrawText.
Definition: font.qc:228
void Font_DrawText(vector vecOrigin, string strText, font_s fnt)
Draw text on the screen at the desired position with a desired font.
Definition: font.qc:155
float Font_StringWidth(string strText, bool hasColor, font_s fnt)
Returns the width of a series of characters in pixels.
Definition: font.qc:301
void Font_DrawText_A(vector vecOrigin, string strText, float a, font_s fnt)
Draw alpha-blended text on the screen at the desired position with a desired font.
Definition: font.qc:204
void Font_DrawFieldAtHeight(vector vecOrigin, vector vecSize, int iTextHeight, string strText, font_s fnt, alignflags_t iAlignFlags)
Draws a textfield with line wrapping at a custom text height.
Definition: font.qc:267
void Font_DrawTextScroll_A(vector vecOrigin, string strText, vector canvasSize, float a, font_s fnt)
Definition: font.qc:169
string Font_RGBtoHex(vector vecColor)
Converts a normalized RGB color vector to a hex color string.
Definition: font.qc:278
void Font_DrawRText_RGB(vector vecOrigin, string strText, vector col, font_s fnt)
Right-aligned variant of Font_DrawText_RGB.
Definition: font.qc:242
typedef enumflags
Defines the valid alignment flags for text fields.
Definition: font.h:37
float Font_GetID(font_s fnt)
Get the internal font id.
Definition: font.qc:18
@ DRAWFLAG_ADDITIVE
Render with an additive blend mode.
Definition: font.h:29
@ DRAWFLAG_MODULATE
Not implemented in FTEQW.
Definition: font.h:30
@ DRAWFLAG_2XMODULATE
Not implemented in FTEQW.
Definition: font.h:31
@ DRAWFLAG_NORMAL
The default.
Definition: font.h:28
Representation of a font.
Definition: api_func.h:39