-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TTF font support #69
Draft
Jed-
wants to merge
80
commits into
project-valhalla:main
Choose a base branch
from
Jed-:text
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
TTF font support #69
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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..."
Drop the minimum supported version of `pango` to 1.38 Remove unnecessary `#include`
…if the strings are different
To avoid overlapping semitransparent elements
…asily turned on and off
…latest Unicode data
On Linux, the game can still be compiled against `pango >= 1.38` and `fontconfig` by adding `-DOLDPANGO` to the compile flags.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.56
.On Linux, the game can alternatively be compiled against
pango >= 1.38
andfontconfig
by adding-DOLDPANGO
as a compiler flag.Bump the minimum standard version to C++11.
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 set of Unicode characters without restriction. If two player names are visually identical or very similar, they are marked as duplicates even if the actual string are different.
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
= strikethroughwhere
...
is the part of the string to apply the markup to.The colors corresponding to
\f
codes can now be customized with thetextcolor
command.Using TTF fonts:
registerfont
command before it can be usedfont
command is used to define a font family to use in-gameconfig/font.cfg
for how to use themfontalias
command has been removedConsole changes:
conshadow
(0, 255, 255): adds a black shadow to console text for increased visibilityconoutline
(0, 0, 255): adds a black outline around console textconscale
from (0.001, 0.45, 1000) to (0.5, 1, 2)Command line changes:
cursorblink
(0, 750, 2000) variable to customize the cursor's blink speed (0 = disable blinking)cursorcolor
(0xFFFFFF) variable to customize the cursor's colorresetcursorblink
command can be used to stop the cursor blink animation for a short timeText particle changes:
particle_text()
now acceptsfont
andlanguage
argumentsparticle_hud_text()
: renders a text particle as a hud mark, similar toparticle_hud_mark()
, this is now used to render theGOAL
label in CTF modeUI changes:
uitextrows
; UI text scale can still be configured withuiscale
uifps
(0, 60, 1000): controls how often text elements check for text changes (0 = check every frame, may impact performace)New UI commands:
uiwrapalign -1|0|1 [children]
: sets the alignment for multi-line paragraphs (-1 = left, 0 = center, 1 = right)uijustify 0|1 [children]
: controls justification for multi-line paragraphsuishadow alpha [children]
: draw a transparent black shadow behind the text (alpha
from 0 to 255)uifontoutline thickness alpha [children]
: draw a transparent black outline around the text (thickness
is expressed in 1/16ths of the current font height;alpha
from 0 to 255)uinofallback 0|1 [children]
: disable falling back to system fonts for unavailable charactersuilanguage lang [children]
: specify the language of the text, which can affect text shaping (lang
must be a string in RFC-3066 format)Global font settings (users may change these to their liking):
Settings for individual fonts (to use after the
font
command, refer toconfig/font.cfg
):font-feature-settings
formatOther added commands:
Miscellaneous changes:
filtertext
function to take aflags
argument rather than a series of booleanstabify
andtextbright
commandstessfont
tool