Refactor string drawing functions
This branch implements general-use functions for drawing strings & measuring string width/height, and replaces the existing string drawing & measuring functions with #define
s using these generalized functions, removing a lot of duplicated code in the process.
V_DrawFontStringAtFixed
-
x
,y
: Thefixed_t
coordinates. -
option
: Video flags. -
pscale
,vscale
: Thefixed_t
horizontal & vertical scale at which the characters get drawn. These also affect space width and line spacing. -
string
: The string to draw. -
font
: A font definition (fontdef_t
, see below).
V_DrawAlignedFontStringAtFixed
- Similar to the above, but also allows centered and right-aligned drawing, which is set using a
text_align
enum. -
text_align
has 3 options:align_left
,align_center
andalign_right
. - Unlike previous centered & right-aligned string drawing functions, this function properly aligns multi-line strings.
V_FontStringWidth
& V_FontStringHeight
-
string
: The string to measure the width/height of, taking newlines into account. -
option
: Video flags. -
font:
A font definition (fontdef_t
, see below).
Instead of just patch_t
arrays, fonts like hu_font
or tny_font
are now stored as the following structure, with some additional parameters:
fontdef_t
-
chars[]
: Thepatch_t
array containing all the font's graphics. -
kerning
: The distance between each character. Can also be negative, to move characters closer together. -
spacewidth
: The width of a space. -
charwidth
: The width of one character. Only used for old video flags likeV_MONOSPACE
andV_OLDSPACING
. -
linespacing
: The height difference between two lines, used for newlines. (Gets overridden byV_RETURN8
, which sets it to 8.)
Edited by sphere