Skip to content

Commit fd60d84

Browse files
committed
TTF font and Unicode support
All text is now rendered with TTF fonts using `pangocairo`, and UTF-8 strings are supported natively. Add a dependency on `pango >= 1.46`, `cairo >= 1.18` and `fontconfig`. Player names are restricted to a subset of Latin, Cyrillic and Greek characters in order to prevent abuse. The rest of the UI, console and particles can use any Unicode characters without restriction. In addition to the color codes `\f0` through `\f9`, more codes have been added to support basic markup: - \fb...\fB = bold - \fi...\fI = italic - \fu...\fU = underline - \ft...\fT = strikethrough - \fo...\fO = overline where `...` is the part of the string to apply the markup to. Using TTF fonts: - each TTF file must be registered with the `registerfont` command before it can be used - the `font` command is used to define a font family (and optionally style) to use in-game - several commands are available to customize each font, see `config/font.cfg` for how to use them - the `fontalias` command has been removed Console changes: - add the `conshadow` (0, 255, 255) variable: adds a shadow to console text for increased visibility - change the range of `conscale` from (0.001, 0.45, 1000) to (0.5, 1, 2) Text input changes: - add the `cursorblink` (0, 750, 2000) variable to customize the cursor's blink speed (0 = disable blinking) - add the `cursorcolor` (0xFFFFFF) variable to customize the cursor's color - the cursor does not blink while the user is typing Text particle changes: - the font to use for each particle can be specified as an argument to `particle_text()` - add the `particle_hud_text()` function: renders a text particle as a hud mark, similar to `particle_hud_mark()`, this is now used to render the `GOAL` label in CTF mode UI changes: - `uitext` and related commands accept a `fancy` argument, used for shadows and outlines, and a `language` argument, which may be necessary to render text in certain languages correctly. The language argument must be in `RFC 3066` format. - valid values for `fancy`: 0 = nothing; 1 = shadow; 2 = outline; 3 = shadow + outline - remove the `uitextrows` variable; UI text scale can still be configured with `uiscale` - add the `uifps` (0, 60, 1000) variable: controls how often text elements check for text changes (0 = check every frame, may impact performace) Miscellaneous changes: - change the `filtertext` function to take a `flags` argument rather than a series of booleans - remove the `tabify` and `textbright` commands - remove the `tessfont` tool Global font settings (users may change these to their liking): - fontantialias (0, 1, 1): toggle font antialiasing (only grayscale antialiasing is supported) - fonthinting (-1, -1, 3): set font hinting (-1 = system default, 0 = disabled, 1 = slight, 2 = medium, 3 = full) Settings for individual fonts (to use after the `font` command, refer to `config/font.cfg`): - fontweight [-3..6]: < 0 = lighter, > 0 = bolder - fontstretch [-4..4]: < 0 = tighter, > 0 = wider; many fonts don't support this, use `fontletterspacing` instead - fontstyle [0..2]: 0 = normal, 1 = oblique, 2 = italic - fontsmallcaps 0|1 - fontletterspacing val: `val` is a floating point value, measured in points; < 0 = tighter, > 0 = wider - fontfeatures [...features]: OpenType features, in CSS `font-feature-settings` format - fontvariations "variations": for OpenType variable fonts, format: "AXIS1=VALUE,AXIS2=VALUE..."
1 parent 86f18b5 commit fd60d84

41 files changed

Lines changed: 1555 additions & 1989 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

config/font.cfg

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
11

22
// Execute dedicated game fonts here
33

4-
loopfiles f "data/interface/font" cfg [
5-
exec (+s "data/interface/font/" $f ".cfg")
6-
]
4+
// registerfont "filename" // "family name"
75

8-
// Change the two following lines to define default font
9-
fontalias "default" "main"
10-
fontalias "default.ol" "main.ol"
6+
// font "name" "family name"
7+
// fontweight -3..6 // < 0 = thinner, > 0 = thicker
8+
// fontstretch -4..4 // < 0 = tighter, > 0 = wider ; many fonts don't support this
9+
// fontstyle 0|1|2 // 0 = normal, 1 = oblique, 2 = italic
10+
// fontsmallcaps 0|1
11+
// fontletterspacing val // float; < 0 = tighter, > 0 = wider
12+
// fontfeatures [...features] // OpenType features (in CSS format)
13+
// fontvariations "variations" // for variable fonts; format: "AXIS1=VALUE,AXIS2=VALUE..."
1114

12-
// Shorthand aliases
13-
fontalias "def" "default"
14-
fontalias "def.ol" "default.ol"
15+
registerfont "data/interface/font/InterVariable.ttf" // Inter Variable
16+
registerfont "data/interface/font/InterVariable-Italic.ttf" // Inter Variable Italic
17+
registerfont "data/interface/font/DejaVuSansMono.ttf" // DejaVu Sans Mono
18+
registerfont "data/interface/font/Oxanium-VariableFont_wght.ttf" // Oxanium
19+
registerfont "data/interface/font/webdings.ttf" // Webdings
20+
21+
font "default" "Inter Variable, Sans"
22+
fontfeatures ["ss04", "cv12", "cv13"]
23+
font "mono" "DejaVu Sans Mono, Monospace"
24+
font "wide" "Oxanium, Inter Variable, Sans"
25+
fontweight 4
26+
font "webdings" "Webdings"

config/glsl/hud.cfg

Lines changed: 24 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -28,33 +28,6 @@ shader 0 "hud" [
2828
}
2929
]
3030

31-
shader 0 "hudtext" [
32-
attribute vec4 vvertex, vcolor;
33-
attribute vec2 vtexcoord0;
34-
uniform mat4 hudmatrix;
35-
varying vec2 texcoord0;
36-
varying vec4 colorscale;
37-
void main(void)
38-
{
39-
gl_Position = hudmatrix * vvertex;
40-
texcoord0 = vtexcoord0;
41-
colorscale = vcolor;
42-
}
43-
] [
44-
uniform sampler2D tex0;
45-
uniform vec4 textparams;
46-
varying vec2 texcoord0;
47-
varying vec4 colorscale;
48-
fragdata(0) vec4 fragcolor;
49-
void main(void)
50-
{
51-
float dist = texture2D(tex0, texcoord0).r;
52-
float border = smoothstep(textparams.x, textparams.y, dist);
53-
float outline = smoothstep(textparams.z, textparams.w, dist);
54-
fragcolor = vec4(colorscale.rgb * outline, colorscale.a * border);
55-
}
56-
]
57-
5831
shader 0 "hudrgb" [
5932
attribute vec4 vvertex, vcolor;
6033
attribute vec2 vtexcoord0;
@@ -152,6 +125,30 @@ shader 0 "hudrect" [
152125
}
153126
]
154127

128+
shader 0 "hudtext" [
129+
attribute vec4 vvertex, vcolor;
130+
attribute vec2 vtexcoord0;
131+
uniform mat4 hudmatrix;
132+
varying vec2 texcoord0;
133+
varying vec4 colorscale;
134+
void main(void)
135+
{
136+
gl_Position = hudmatrix * vvertex;
137+
texcoord0 = vtexcoord0;
138+
colorscale = vcolor;
139+
}
140+
] [
141+
uniform sampler2DRect tex0;
142+
varying vec2 texcoord0;
143+
varying vec4 colorscale;
144+
fragdata(0) vec4 fragcolor;
145+
void main(void)
146+
{
147+
fragcolor = colorscale * texture2DRect(tex0, texcoord0);
148+
if(fragcolor.a != 0) fragcolor.rgb = fragcolor.rgb / fragcolor.a;
149+
}
150+
]
151+
155152
shader 0 "hud3d" [
156153
attribute vec4 vvertex, vcolor;
157154
attribute vec3 vtexcoord0;

config/glsl/particle.cfg

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,14 @@ shader 0 "particletext" [
107107
color = vec4(vcolor.rgb * ldrscale, vcolor.a);
108108
}
109109
] [
110-
uniform vec4 textparams;
111-
uniform sampler2D tex0;
110+
uniform sampler2DRect tex0;
112111
varying vec4 color;
113112
varying vec2 texcoord0;
114113
fragdata(0) vec4 fragcolor;
115114
void main(void)
116115
{
117-
float dist = texture2D(tex0, texcoord0).r;
118-
float border = smoothstep(textparams.x, textparams.y, dist);
119-
float outline = smoothstep(textparams.z, textparams.w, dist);
120-
fragcolor = vec4(color.rgb * outline, color.a * border);
116+
fragcolor = color * texture2DRect(tex0, texcoord0);
117+
if(fragcolor.a != 0) fragcolor.rgb /= fragcolor.a;
121118
}
122119
]
123120

config/ui/hud/editstats.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,8 @@ uiLiteMenu "edithud" [
333333
uigrid 2 $uiPad:3XL $uiPad:L [
334334
uihlist $uiPad:XL [
335335
uitext "WTR" 0.5
336-
uitext (tabify (format "%1k" $editstatwtr) 1) 0.5
337-
uitext (tabify (format "(%1%%)" $editstatvtr) 2) 0.5
336+
uitext (format "%1k" $editstatwtr) 0.5
337+
uitext (format "(%1%%)" $editstatvtr) 0.5
338338
]
339339
uihlist $uiPad:XL [
340340
uitext "WVT" 0.5

config/ui/hud/gamehud.cfg

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ newui "scoreboard" [
735735
uiFastImg (fade (? $arg1 0.5 0.25)) "hud/" "shelf" "" $uiPad:5XL
736736
uiFastImg <mad:.18/.18/.18> "hud/" "glow" "" $uiPad:5XL
737737
push n (+ $n 1) [
738-
uifontcolortext "def.ol" $n (|A! (? $arg1 0xB0 0x60)) 0.55
738+
uifontcolortext "default" $n (|A! (? $arg1 0xB0 0x60)) 0.55
739739
]
740740
] ; uialign- -1
741741
]
@@ -786,14 +786,14 @@ newui ".killUI" [
786786
uifill 0 0.3
787787
t = (getrespawnwait)
788788
uispace 0.02 0.02 [
789-
uifonttext "wide.ol" $lasthudkillinfo $uiPad:USS
789+
uifonttext "wide" $lasthudkillinfo $uiPad:USS
790790
]
791791
uispace 0 0 [
792792
uioffset 0 $uiPad:D2XL- [
793793
if (m_invasion $getmode) [
794-
uifonttext "wide.ol" (+s "^f4Lives remaining: " $getclientlives) $uiPad:USS
794+
uifonttext "wide" (+s "^f4Lives remaining: " $getclientlives) $uiPad:USS
795795
] [
796-
uifontcolortext "wide.ol" (? $t $t " ") (? (< (getmillis) (+ 100 (getlastspawnattempt))) $c_red $c_white) 1
796+
uifontcolortext "wide" (? $t $t " ") (? (< (getmillis) (+ 100 (getlastspawnattempt))) $c_red $c_white) 1
797797
]
798798
]
799799
]

config/ui/hud/geo_prefab.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ uiLiteMenu "geo_prefab" [
2424
uiclamp*e
2525
uispace $uiPad:S $uiPad:O3 [
2626
uialign -1 -1
27-
uifontcolortext "def.ol" $i (|A! 0x98) 0.55
27+
uifontcolortext "default" $i (|A! 0x98) 0.55
2828
]
2929
uihover [
3030
if (!= $i $.UI_obrsel) [

config/ui/hud/mapmodel_browser.cfg

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,11 @@ uiLiteMenu "mapmodel_browser" [
5454
uimodelpreview (mapmodelname $i 1) "mapmodel"
5555
uiclamp*e
5656
uispace $uiPad:S $uiPad:O3 [
57-
uifonttext "def.ol" $i 0.55
57+
uifonttext "default" $i 0.55
5858
] ; uialign- -1 -1
5959
if (iskeyheld "LSHIFT") [
6060
uispace $uiPad:S 0 [
61-
uifonttext "webdings.ol" "q" 0.65
61+
uifonttext "webdings" "q" 0.65
6262
] ; uialign- -1 1
6363
uirelease [ clearmodel (+s "mapmodel/" (mapmodelname $i)) ]
6464
] [
@@ -77,14 +77,14 @@ uiLiteMenu "mapmodel_browser" [
7777
uimodelpreview (mapmodelname $i 1) "mapmodel"
7878
uiclamp*e
7979
uispace $uiPad:S $uiPad:O3 [
80-
uifontcolortext "def.ol" $i (|A! 0xA0) 0.55
80+
uifontcolortext "default" $i (|A! 0xA0) 0.55
8181
] ; uialign- -1 -1
8282
uihover [ .mm_selidx = $n ; uiSetMillis ]
8383
uioutline $c_line1 $.z $.z
8484
]
8585
if (mapmodelloaded $i) [
8686
uispace $uiPad:S $uiPad:O3 [
87-
uifonttext "webdings.ol" "a" 0.55
87+
uifonttext "webdings" "a" 0.55
8888
] ; uialign- 1 -1
8989
]
9090
uiHoverOnce [ uiHoverSound ]

config/ui/hud/texture_browser.cfg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ uiLiteMenu "texture_browser" [
2929
]
3030
uispace $uiPad:S $uiPad:O3 [
3131
uialign -1 -1
32-
uifontcolortext "def.ol" $i (|A! 0x98) 0.55
32+
uifontcolortext "default" $i (|A! 0x98) 0.55
3333
]
3434
]
3535
uipress [ uiSetMillis ]
@@ -83,7 +83,7 @@ uiLiteMenu "texture_browser" [
8383
uiclip 0 $uiPad:6XL [ uicolortext "/" $c_gray 1.2 ]
8484
] // text takes up a lot of vertical space, have to "cut" it
8585
uifill $uiPad:DXS 0 [
86-
uifonttext "def.ol" (max $.tb_totalpg 1) 0.7
86+
uifonttext "default" (max $.tb_totalpg 1) 0.7
8787
uialign- -1 1
8888
]
8989
uiclamp*y
@@ -110,7 +110,7 @@ uiLiteMenu "texture_browser" [
110110
uislotview $i
111111
uiclamp*e
112112
uispace $uiPad:S $uiPad:O3 [
113-
uifontcolortext "def.ol" $i (|A! 0xA0) 0.55
113+
uifontcolortext "default" $i (|A! 0xA0) 0.55
114114
] ; uialign- -1 -1
115115
uirelease [
116116
settex (getslottex $i)

config/ui/lib.cfg

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ uiclamp*x = [ uiclamp* 1 1 0 0 ]
4545
uiclamp*y = [ uiclamp* 0 0 1 1 ]
4646
uiclamp*e = [ uiclamp* 1 1 1 1 ]
4747

48-
uifonttext = [ uifont $arg1 [ uitext $arg2 $arg3 ] ]
49-
uifontcolortext = [ uifont $arg1 [ uicolortext $arg2 $arg3 $arg4 ] ]
48+
uifonttext = [ uifont $arg1 [ uitext $arg2 $arg3 $arg4 ] ]
49+
uifontcolortext = [ uifont $arg1 [ uicolortext $arg2 $arg3 $arg4 $arg5 ] ]
5050

5151
changeui = [
5252
if $arg2 [] [ arg2 = $uiname ]
@@ -793,23 +793,17 @@ uiButton = [
793793

794794
// uiFancyText FONT TEXT SIZE 0xCOLOR TRANSPARENCY
795795
uiFancyText = [
796-
if (=s $arg1 "") [ arg1 = "def" ]
796+
if (=s $arg1 "") [ arg1 = "default" ]
797797
if $arg4 [] [ arg4 = $c_white ]
798798
if (< $numargs 5) [ arg5 = 1 ]
799-
uigroup [
800-
uioffset $uiPad:O1- $uiPad:O1 [
801-
uifontcolortext [@arg1.ol] (stripcolors $arg2) (|A (*fA $arg5 0x20)) $arg3
802-
uifontcolortext $arg1 (stripcolors $arg2) (|A (*fA $arg5)) $arg3
803-
]
804-
uioffset $uiPad:O1 $uiPad:O1- [
805-
uifontcolortext $arg1 $arg2 (|A (*fA $arg5) $arg4) $arg3
806-
]
799+
uigroup [ // DO NOT REMOVE!
800+
uifontcolortext $arg1 $arg2 (|A (*fA $arg5) $arg4) $arg3 1
807801
]
808802
]
809803

810804
// uiEmbossText FONT TEXT SIZE 0xCOLOR
811805
uiEmbossText = [
812-
if (=s $arg1 "") [ arg1 = "def" ]
806+
if (=s $arg1 "") [ arg1 = "default" ]
813807
uigroup [
814808
uioffset $uiPad:O2- $uiPad:O2 [
815809
uifontcolortext $arg1 (stripcolors $arg2) 0 $arg3
@@ -851,7 +845,7 @@ uiVerSld = [
851845
] ; uiclamp-x
852846
uivlist $uiPad:M- [
853847
loop i (strlen $arg6) [
854-
uifontcolortext "def.ol" (substr $arg6 $i 1) (|A! (? $arg9 0xA0 0x60)) 0.65
848+
uifontcolortext "default" (substr $arg6 $i 1) (|A! (? $arg9 0xA0 0x60)) 0.65
855849
]
856850
]
857851
]
@@ -880,7 +874,7 @@ uiHorSld = [
880874
uiclamp*y
881875
]
882876
] ; uiclamp-y
883-
uifontcolortext "def.ol" $arg6 (|A! (? $arg9 0xA0 0x60)) 0.65
877+
uifontcolortext "default" $arg6 (|A! (? $arg9 0xA0 0x60)) 0.65
884878
]
885879
uiclamp*e
886880
]
@@ -910,7 +904,7 @@ uiVerColorSld = [
910904
] ; uiclamp-x
911905
uivlist $uiPad:M- [
912906
loop i (strlen $$arg1) [
913-
uifontcolortext "wide.ol" (substr $$arg1 $i 1) (|A! (? $arg9 0xA0 0x60)) 0.7
907+
uifontcolortext "wide" (substr $$arg1 $i 1) (|A! (? $arg9 0xA0 0x60)) 0.7
914908
]
915909
]
916910
]
@@ -940,7 +934,7 @@ uiHorColorSld = [
940934
uiclamp*y
941935
]
942936
] ; uiclamp-y
943-
uifontcolortext "wide.ol" $$arg1 (|A! (? $arg9 0xA0 0x60)) 0.7
937+
uifontcolortext "wide" $$arg1 (|A! (? $arg9 0xA0 0x60)) 0.7
944938
]
945939
uiclamp*e
946940
]

config/ui/libnew.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ uiSliderH = [
170170
uiFastImgStretched "" "shadow2" "" "" [ uiclamp.x ]
171171
uiclamp*e
172172
if $arg9 [ arg10 = 0xA0FFFFFF ] [ arg10 = 0x60FFFFFF ]
173-
uiFontColorText "def.ol" $arg6 0.65 $arg10
173+
uiFontColorText "default" $arg6 0.65 $arg10
174174
] ; uiclamp-y
175175
]
176176
] ; uiclamp-y

0 commit comments

Comments
 (0)