Commit graph

23 commits

Author SHA1 Message Date
Ralph Sennhauser
a2f15bae4e
Fix some includes in source/graphics
Make include-what-you-use happy with some files in source/graphics and
fix what needs to be fixed.

Ref: #8086
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
2025-07-18 07:30:04 +02:00
trompetin17
c0a3f2d885
Preload common glyphs after font load to reduce rendering delay
To improve visual consistency during dynamic font rendering, especially
on lower-end machines or during low FPS moments, we now preload a set of
common Latin letters, digits, and punctuation glyphs immediately after a
font is loaded by the FontManager.

This reduces the likelihood of users seeing empty or missing characters
on the first frame after a font is used, minimizing visual glitches
during simulation.

The preloaded characters include:
- Uppercase and lowercase Latin letters (A–Z, a–z)
- Digits (0–9)
- Common punctuation and symbols (e.g., .,;:!?()[]{}<> etc.)

This change helps smooth the user experience and avoids blank spaces
during the initial rendering of text in performance-constrained
scenarios.
2025-06-15 08:05:12 -05:00
trompetin17
4dc686564e
Fix FreeType font loading from zipped mods
The FreeType font loader was directly passing filesystem-style paths
(e.g., mod.zip/...) to FT_New_Face, which does not support paths inside
ZIP archives. As a result, FreeType failed to open the font, triggering
a crash when the engine attempted to use an invalid face object.

This patch changes the font loading logic to:

Use the VFS to read the .ttf font file into memory (shared_ptr<u8> and
size).

Load the font using FT_New_Memory_Face with the in-memory buffer,
ensuring compatibility with zipped mods.
2025-06-03 11:20:56 -05:00
trompetin17
2781d9a6a3
Add Fallback Font support
In previous fontbuilder.py we have the capacity to specified chain fonts
when a glyph is missed from one font.

This commit enable that behavior.
2025-05-28 01:01:03 -05:00
trompetin17
bdd94bd264
Add font engine aware of Gui.scale
This commit enhances text rendering by leveraging FreeType and a dynamic
font atlas. Previously, GUI scaling relied on bitmap fonts, which led to
blurry and distorted text when scaling up. Now, we scale the font size
directly using FreeType, resulting in much sharper and more readable
text at any GUI scale.

Key improvements:
- Replaced bitmap font scaling with true font size scaling via FreeType.
- Reduced glyph cache dependency on fixed positions, relying on shader
  scaling instead.
- Switched to float-based glyph positioning for more accurate rendering
  and scaling.

These changes ensure clean and consistent text appearance across
different GUI scales.
2025-05-26 13:12:47 -05:00
Dunedan
f28ca5d684
Fix bold and italic fonts
A last minute change in #7787 caused the bold and italic identifiers of
fonts to be ignored once it got merged in 734386ce9f and all fonts to
be rendered as regular fonts. This commit fixes that.
2025-05-18 18:41:25 +02:00
trompetin17
734386ce9f
Use freetype for font rendering
Replace premade bitmap fonts with FreeType2 and dynamic texture atlas.

Switched from static, premade bitmap fonts to runtime-generated glyphs using FreeType2.
Glyphs are rendered on demand into a dynamic texture atlas, improving scalability,
font quality, and support for internationalization.

Currently using RGBA format for compatibility across all render
paths while initial support for R8_UNORM is being added.
This prepares for future optimizations in VRAM and performance

Includes groundwork for gamma-corrected blending and future swizzling support.
2025-05-16 14:57:59 -05:00
vladislavbelov
ffc4a56b9f Revert non-ASCII characters from source and configuration files introduced in 157c6af18e.
Fixes #6846

Differential Revision: https://code.wildfiregames.com/D5185
This was SVN commit r27965.
2023-12-03 00:30:12 +00:00
bb
157c6af18e Make the space in 0 A.D. non-breaking throughout the codebase.
Avoid cases of filenames
Update years in terms and other legal(ish) documents
Don't update years in license headers, since change is not meaningful

Will add linter rule in seperate commit

Happy recompiling everyone!

Original Patch By: Nescio
Comment By: Gallaecio
Differential Revision: D2620
This was SVN commit r27786.
2023-07-27 20:54:46 +00:00
vladislavbelov
3399791677 Adds renderer backend vertex formats and normalizes texture formats.
This was SVN commit r26588.
2022-03-06 22:14:57 +00:00
vladislavbelov
4de89c3db1 Moves texture management to CDeviceCommandContext, adds quality options.
Comments By: nwtour, Stan
Tested By: nwtour, Stan
Differential Revision: https://code.wildfiregames.com/D4488
This was SVN commit r26365.
2022-02-13 19:30:28 +00:00
vladislavbelov
9cb6e4c105 Cleanups Font and FontManager a little.
This was SVN commit r26050.
2021-12-10 16:59:32 +00:00
vladislavbelov
b03b560e71 Adds std namespace to shared_ptr usages in graphics.
This was SVN commit r25525.
2021-05-22 19:21:33 +00:00
wraitii
0c23e595fa Include CStrInternStatic where necessary only.
This makes incremental recompilation faster when changing static
interned strings.

Differential Revision: https://code.wildfiregames.com/D3975
This was SVN commit r25457.
2021-05-18 11:09:54 +00:00
elexis
d18374bffe Fix ugly font rendering using GL linear interpolation if the UI scale was changed.
Patch By: Dariost
Refs D332

This was SVN commit r20735.
2017-12-30 17:56:07 +00:00
Ykkrosh
e02d7ad949 Automatically replace %hs/%ls with %s in CLogger format strings.
Everything is char* now, so we don't need to mess around with different
string types.

Done with:

  ag -ls 'LOG(MESSAGE|MESSAGERENDER|WARNING|ERROR)' source | xargs perl
-pi -e'1 while
s/(LOG(MESSAGE|MESSAGERENDER|WARNING|ERROR).*)%[hl]s/$1%s/g'

This was SVN commit r16187.
2015-01-22 20:36:24 +00:00
Ykkrosh
38a8e2e0d6 Automatically convert most path.string().c_str() to path.string8()
Done with:

  ag -l 'LOG.*string\(\).c_str\(\)' source | xargs perl -pi -e'1 while
s/(LOG.*string)\(\)\.c_str\(\)/${1}8()/g'

This was SVN commit r16186.
2015-01-22 20:35:17 +00:00
Ykkrosh
49e2ecea63 Automatically convert all CLogger format strings from wchar_t* to char*.
Done with:

  ag -ls 'LOG(MESSAGE|MESSAGERENDER|WARNING|ERROR)' source | xargs sed
-i 's/LOG\(MESSAGE\|MESSAGERENDER\|WARNING\|ERROR\)(L/LOG\1(/g'

This was SVN commit r16183.
2015-01-22 20:31:30 +00:00
Ykkrosh
024dd82209 Fix non-PCH build
This was SVN commit r14024.
2013-10-19 01:11:20 +00:00
Ykkrosh
701508922f Use CStrIntern for font names to reduce lookup cost
This was SVN commit r14020.
2013-10-18 16:15:42 +00:00
Ykkrosh
91169c82c7 Optimise rendering of scrollable text boxes by clipping
Add optional clipping rectangle to CTextRenderer. Strings that are
printed
outside the vertical extent of the clipping rectangle will be
immediately
skipped. This greatly reduces the cost of large scrollable text boxes.

This was SVN commit r14019.
2013-10-18 16:05:02 +00:00
Ykkrosh
b6c7c0d799 Optimise glyph lookup in text renderer
std::map lookup was a major cost when rendering large amounts of text.
Replace it with a more efficient 2-level array.

This was SVN commit r14017.
2013-10-18 15:56:12 +00:00
Ykkrosh
5778484a77 Refactor text renderer
Replace unifont with CFont and CFontManager, since the h_mgr interface
was
needlessly inconvenient.

Load the font textures through CTextureManager, to support dynamic
reloading (e.g. when resetting GL state - see #741).

Add CFontMetrics as a convenient wrapper for code that just wants to
measure text.

Fixes #1117.

This was SVN commit r14016.
2013-10-18 15:53:07 +00:00