Nuclide
Software Development Kit for id Tech
font.h
Go to the documentation of this file.
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
18typedef enum
19{
25
28typedef enumflags
29{
30 AF_LEFT,
31 AF_TOP,
32 AF_RIGHT,
33 AF_BOTTOM
34} alignflags_t;
35
37typedef struct
38{
39 int iID;
40 int iScaleX;
41 int iScaleY;
43 float flAlpha;
44 int iFlags;
45} font_s;
46
51void Font_Load(string strFile, font_s &fntNew);
52
53/* standard drawing */
59void Font_DrawText(vector vecOrigin, string strText, font_s fnt);
66void Font_DrawText_A(vector vecOrigin, string strText, float a, font_s fnt);
73void Font_DrawText_RGB(vector vecOrigin, string strText, vector col, font_s fnt);
82void Font_DrawText_RGBA(vector vecOrigin, string strText, vector col, float a, font_s fnt);
83
84/* right aligned variants */
87void Font_DrawRText(vector vecOrigin, string strText, font_s fnt);
90void Font_DrawRText_A(vector vecOrigin, string strText, float a, font_s fnt);
93void Font_DrawRText_RGB(vector vecOrigin, string strText, vector col, font_s fnt);
96void Font_DrawRText_RGBA(vector vecOrigin, string strText, vector col, float a, font_s fnt);
97
105void Font_DrawField(vector vecOrigin, vector vecSize, string strText, font_s fnt, alignflags_t iAlignFlags);
106
115void Font_DrawFieldAtHeight(vector vecOrigin, vector vecSize, int iTextHeight, string strText, font_s fnt, alignflags_t iAlignFlags);
116
121string Font_RGBtoHex(vector vecColor);
122
128int Font_GetHeight(font_s fnt);
129
143float Font_StringWidth(string strText, bool hasColor, font_s fnt);
144
155float Font_GetID(font_s fnt);
int Font_GetHeight(font_s fnt)
Returns the height of a specified font in pixels.
Definition: font.qc:204
void Font_Load(string strFile, font_s &fntNew)
Load a desired .font definition into memory.
Definition: font.qc:24
void Font_DrawField(vector vecOrigin, vector vecSize, string strText, font_s fnt, alignflags_t iAlignFlags)
Draws a textfield with line wrapping.
Definition: font.qc:165
void Font_DrawRText_A(vector vecOrigin, string strText, float a, font_s fnt)
Right-aligned variant of Font_DrawText_A.
Definition: font.qc:144
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:129
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:158
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:121
drawflag_t
Flags for 2D drawing operations.
Definition: font.h:19
@ DRAWFLAG_ADDITIVE
Render with an additive blend mode.
Definition: font.h:21
@ DRAWFLAG_MODULATE
Not implemented in FTEQW.
Definition: font.h:22
@ DRAWFLAG_2XMODULATE
Not implemented in FTEQW.
Definition: font.h:23
@ DRAWFLAG_NORMAL
The default.
Definition: font.h:20
void Font_DrawRText(vector vecOrigin, string strText, font_s fnt)
Right-aligned variant of Font_DrawText.
Definition: font.qc:137
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:105
float Font_StringWidth(string strText, bool hasColor, font_s fnt)
Returns the width of a series of characters in pixels.
Definition: font.qc:210
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:113
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:176
string Font_RGBtoHex(vector vecColor)
Converts a normalized RGB color vector to a hex color string.
Definition: font.qc:187
void Font_DrawRText_RGB(vector vecOrigin, string strText, vector col, font_s fnt)
Right-aligned variant of Font_DrawText_RGB.
Definition: font.qc:151
typedef enumflags
Defines the valid alignment flags for text fields.
Definition: font.h:29
float Font_GetID(font_s fnt)
Get the internal font id.
Definition: font.qc:18
vector(vector) normalize
get jsonnode a[__int key]
Definition: fteextensions.qc:3828
Representation of a font.
Definition: font.h:38
int iFlags
Rendering flags that the font posesses.
Definition: font.h:44
int iScaleX
Suggested maximum width of a character in the font.
Definition: font.h:40
int iScaleY
Maximum height of a chracter in the font.
Definition: font.h:41
vector vecColor
Suggested default color of the font.
Definition: font.h:42
float flAlpha
Suggested default alpha of the font.
Definition: font.h:43
int iID
Internal ID, will be passed to 'drawfont' before rendering text.
Definition: font.h:39