Multi-line and tabbed strings drawn with a scaleMultiplier != 1 overlapped
or misaligned because the font code advanced newlines and tabs by the
unscaled font height/tab width -- most visible in FRED's viewport labels
now that they honor an adjustable font scale.
Scale the newline and tab advance in both the rendering and measurement
paths of each backend: the NVG path (gr_string and NVGFont::getStringSize)
and the VFNT path (gr_string_old and VFNTFont::getStringSize), which also
gains tab handling. The tab width is hoisted onto the shared FSFont base
so both backends share it.
While here, pass the FSFont wrapper to gr_string_old instead of a bag of
scalars, make its font pointer const, and consolidate the
get_char_width_old externs into a single declaration in font_internal.h.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Add coverity[GLOBAL_INIT_ORDER] annotations to ~50 global variables
across 27 files. These were all analyzed and confirmed safe:
- ~48 OptionBuilder::finish() globals use a Meyers singleton
(OptionsManager::instance()), which guarantees safe init order.
Destruction is also safe due to shared_ptr ref-counting.
- 6 default-constructed container globals (vectors, maps) have no
cross-TU dependencies at construction or destruction time.
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
1. Change `ai_profile_lookup` and `multi_xfer_lookup` to use `const char *`, since all the other lookup functions do
2. Remove several unneeded `const_cast`s, some of which are now made possible by the non-const `data()` overload in C++17
3. Change `campaign_link` to use `const char*`
4. Use better string management in `test::FSTestFixture::init_cmdline()`
String processing enhancement prerequisites for the upcoming `split_str_once` PR.
1. Add overloads of some string processing functions with a length parameter, to allow processing of substrings of C-strings
2. Add overloads of gr_printf that work with string lengths
3. Add constructors to `HUD_message_data` and `line_node`
4. Rename "size" to "len" in `vm_strndup` for clarity
5. Fill in some string attribute annotations
6. Make the rest of the HUD render functions `const`
7. Removed unneeded circular #includes in code/globalincs/memory/
Rewrite `force_fit_string` to be more robust and to remove the potential for memory access violations. Also audit all of the length parameters in the calling functions - some of them were the buffer size, not the length. This should fix the mysterious crash in the mission log screen.
The `setAutoScaleBehavior` function call should go after the null check to prevent crashing FSO if the font fails to load.
Also, if a font fails to load, skip over it so that subsequent fonts can be parsed.
* Add method to get a font's font family
* nullptr
* add more safety checks
* pass font data instead of font data members
* return an empty string instead of unknown
FSO doesn't appear to use this any longer. And even when it was enabled the
requirements made it largely useless anyway. Removing to clean up cfile a
bit and so we don't have to keep maintaining it.
* allow VFNTs to auto scale and disallow auto scaling in FRED
* fix shadowing
* Update FSFont.cpp
* don't code from your phone, mjn
* refactor to use one central method
* Add option to set a font size multiplier for ttf fonts
* remove the option if we have no scaling fonts
* Clang the conquerer strikes again
* Update XSTRs
* clang
* Clarify comments
This refactors FontManager to improve it in several ways:
1. Change all the dynamic memory management to use `new`, rather than mixing `new` and `vm_malloc`
2. Change the current font to use an index rather than a pointer
3. Take advantage of more C++11 features to avoid redundant lookups
4. Use case-insensitive name comparison
5. Avoid overflowing the `fnt->filename` field
6. Use `Warning` rather than `Error` in a non-critical error situation
* SCPUI in-game language selector
* xstr support
* proper debug print format
* minor fixes
* Save the language as json data rather than an index into the languages array
* ext instead of id for clarity
* Do this more formally
* unused param
* add subfolder support to cfile
* sort files in VP archives before indexing them
* fix indexing of sub-subfolders
* remove unused 8B22K & 16B11K sound path types
* add more items to skip subfolder scanning
* fix windows build issues
* fix unit tests by allowing 0-byte files to be indexed
* fix file indexing on windows
* add test for cfile subfolders
* remove specific 'markup' and 'css' interface subfolders
They aren't directly referenced anywhere by pathtype and the new
subfolder code will continue to index and load files from them
* add player binds to list of always-root locations
* remove file-based localization support
An alternative is left in place for old fonts, as that was the only place
it appeared to be used.
This method of file localization conflicts with subfolder support however
so if it's needed in the future then changes to the subfolder code will
be necessary.
* add subfolder support to cf_find_file_location_ext()
* add subfolder tests for cf_find_file_location*()
* add shlwapi to needed win32 libs
* small bit of cleanup
* add subfolder support to cf_get_file_list()
* add tests for cfile subfolder lists
* report files that might be shadowed
* fix issue with lists when a filter is used
Also fixes discrepancy in older cf_get_file_list() when a sub path
is specified (should be used in all cases, not just glob).
* address review suggestions
`gr_get_string_size` takes a length parameter, but `split_str_once` was calling it with the position instead. This led to incorrect results occasionally. If the incorrect pixel width had the bad luck to be exactly equal to the remaining space, this would cause an infinite loop. This fixes the bug and adds a bunch of safeguards to prevent a similar situation in the future.
Multiplayer screens such as PXO lobby, chat boxes, and multi-game setup screens had hard coded values for the number of lines to display. These would only work correctly with the default .vf font01 from retail. If a mod or user used a TTF or other .vf font than text would spill over. This PR makes these values take into the account the font used.
Tested and works as expected with TTF fonts and the retail fonts. Marking as draft to see what others think.
* Fix underline length calculation in message scrollback
* Use SCP_string for message source (which allows ships with long display names to work without crashing) and message text
* Upgrade assorted functions to work with SCP_string
1. Stores the filename from the table Parser into the font struct so we can lookup fonts via their filename.
2. Allow "+Special Character Font:" to specify the first entry with the same filename's special character index for their own special character index, provide a default if not, and allow the moddert to specify them manually, but do not override already recorded values if the default is picked in order to protect retail behavior.
3. Vectorize Special Character Indexes, so that we don't have a table limit that will randomly crash FSO based on what table you happened to write! Woohoo!
This adds a mechanism for running generic operations at specific points
of the frame execution. This can be used by any part of the code an not
just Lua since it simply executes std::functions. It also adds an
"execution context" concept that specifies in which situation an
operation should be executed.
This is then used by the Lua Coroutines code for resuming coroutines at
specific points instead of always when the awaited promise resolves.
This adds proper Unicode support by allowing the parse system to read
UTF-8 encoded files. The new mode is controlled by a mod option which
allows older mods to continue using the legacy text encoding.
That option changes the behavior of several systems in FSO. It disallows
the usage of Volition fonts since they don't support Unicode encoding
and changes a few usages of special characters to their unicode
counterparts of generic rendering solutions.
This fixes#1415.
Currently, the graphics code does some color remapping on 8
bit-per-pixel textures since those textures use special 4-bit pixel
values. These changes move that conversion out of the graphics code and
into the image loading/font bitmap creation code.
The reason this is needed is because this conversion breaks 8-bit
textures that try to use the full range of colors. I need to do exactly
that for moving the cutscene renderer to our generic rendering interface
which I can't do at the moment since the existing color conversion
corrupts the video data.
I have tested this with retail data and could not find any visual
changes after applying these changes.