1
0
Fork 0
Commit Graph

56 Commits (9229956f04731a38ee382807faeb08a7a0b2dff4)

Author SHA1 Message Date
frosch 9229956f04 Codechange: Replace strcasestr with StrContainsIgnoreCase. 2025-04-09 17:19:11 +02:00
Patric Stout 86841ba1f0
Codechange: no longer add "src" to the include-path (#13511) 2025-02-09 19:43:15 +00:00
Peter Nelson ba20ea5d18
Codechange: Use EnumBitSet for SpriteComponent. (#13509) 2025-02-09 18:37:01 +00:00
Loïc Guilloux ef826a048a
Codechange: [WIN32] Use language isocode for fallback font detection (#13310) 2025-01-21 15:57:09 +01:00
Loïc Guilloux 4670a62342
Fix: [Win32] Font detection didn't work for locales not supporting code pages (#13306) 2025-01-12 17:23:41 +01:00
Peter Nelson e2a796dbcd Codefix: Potential unterminated string returned from convert_to_fs.
Converting from UTF-8 to UTF-16 could have resulted in a buffer overflow if the buffer size was exactly the length of the converted string.

Pass string_view/span to convert_from/to_fs instead, and ensure the buffer is terminated. This replaces passing a pointer to the buffer and the buffer size as separate parameters, allowing the compiler to pass both in one parameter.

Removes use of `lengthof()`.
2024-07-10 20:57:02 +01:00
Peter Nelson 209b0320d5
Fix #12735: Default fonts should use default font size as-is. (#12814)
Minimum readable font size should only apply to fallback and configured fonts.
2024-06-26 12:45:39 +01:00
Peter Nelson 48539992e8 Codechange: Use std::unordered_map for storing TrueTypeFontCache's GlyphEntry. 2024-05-30 20:16:28 +01:00
Peter Nelson 7b717fcccb Codechange: Replace AllocatorProc with SpriteAllocator class.
This allows for state to be passed to or maintained by the allocator.
2024-05-30 20:16:28 +01:00
Peter Nelson 3c42f701d7
Fix: Allow changing size of default OpenTTD font. (#12641)
* Fix: Allow changing size of default OpenTTD font.

Size configuration for default font was ignored as a different code path to load the font was followed.

Resolved by removing this additional path and conditionally selecting the default font.
2024-05-26 15:59:25 +01:00
Peter Nelson c85481564f
Codechange: Use reusable temporary buffer in Win32FontCache. (#12666)
This avoids allocating and deleting a temporary buffer for every glyph that is rendered into a sprite.
2024-05-17 08:50:59 +01:00
Peter Nelson 980dcaac6e
Cleanup: Remove GetFontTable from FontCache. (#12677)
This interface is no longer used, so does not need to be implemented.

Removes manual memory management with malloc/free.
2024-05-14 21:13:26 +01:00
Peter Nelson d78f39a9df
Cleanup: Remove GetUnitsPerEM and units_per_em. (#12656)
GetUnitsPerEM is never called.
2024-05-11 14:50:34 +01:00
Peter Nelson ec61951512
Cleanup: Remove Windows 9x font locale workaround. (#12644) 2024-05-09 07:03:02 +01:00
Peter Nelson 3c94e81665 Codechange: Use ZOOM_LVL_MIN to refer to first zoom level.
Many uses of ZOOM_LVL_NORMAL actually just want the first zoom level slot, so use ZOOM_LVL_MIN to make this clearer.
2024-04-04 22:27:03 +01:00
Loïc Guilloux 11aa3694fa
Fix: [Win32] Force font mapper to only use TrueType fonts (#12406) 2024-04-01 22:59:13 +02:00
Patric Stout a3cfd23cf9
Codechange: rename byte to uint8_t (#12308) 2024-03-16 23:59:32 +01:00
Michael Lutz 36cf6b1d13 Feature: Scalable OpenTTD TrueType font made by Zephyris.
This uses the normal variant for the small font, not the all-caps version.
2024-01-14 22:50:56 +01:00
Michael Lutz 6e766a2e81 Change: Allow TrueType fonts to provide our private-use glyphs. 2024-01-14 22:50:56 +01:00
Patric Stout d3ee045c2d
Codechange: refactor the Windows-only DllLoader in a cross-platform LibraryLoader (#11751) 2024-01-10 21:38:58 +00:00
Peter Nelson b85ecf9ac2
Codechange: Replace pointer to Sprite array with reference to SpriteCollection. (#11580)
Add `SpriteLoader::SpriteCollection` type which is an array of `SpriteLoad::Sprite`.

This removes the ambiguity of what `SpriteLoader::Sprite *` is pointing to,
and cleans up mismatches using both dereference -> and array access [] for the
same object.
2023-12-20 20:38:21 +00:00
Peter Nelson d4008850e3 Codechange: Ensure function opening `{` is on new line. 2023-11-09 20:15:38 +00:00
frosch 5733145c59 Cleanup: Remove unneeded parameters. 2023-09-19 22:49:59 +02:00
frosch b6c8f301be Codechange: Silence warnings about intentionally unused parameters. 2023-09-19 22:49:59 +02:00
Rubidium eaae0bb5e7 Codechange: automatic adding of _t to (u)int types, and WChar to char32_t
for i in `find src -type f|grep -v 3rdparty/fmt|grep -v 3rdparty/catch2|grep -v 3rdparty/opengl|grep -v stdafx.h`; do sed 's/uint16& /uint16 \&/g;s/int8\([ >*),;[]\)/int8_t\1/g;s/int16\([ >*),;[]\)/int16_t\1/g;s/int32\([ >*),;[]\)/int32_t\1/g;s/int64\([ >*),;[]\)/int64_t\1/g;s/ uint32(/ uint32_t(/g;s/_uint8_t/_uint8/;s/Uint8_t/Uint8/;s/ft_int64_t/ft_int64/g;s/uint64$/uint64_t/;s/WChar/char32_t/g;s/char32_t char32_t/char32_t WChar/' -i $i; done
2023-07-19 19:30:14 +02:00
PeterN eda3defcb5
Codechange: Pass language for font detection as std::string. (#10964) 2023-06-06 20:55:56 +00:00
PeterN 7a0b6b7ddf
Codechange: Remove Freetype bits on Win32/OSX. (#10960)
These platforms have their own specific font rendering.
2023-06-06 19:43:27 +01:00
Peter Nelson c38df2d589 Codechange: Use std::map instead of custom SmallMap. 2023-05-18 12:18:30 +01:00
Rubidium 4dd5f994be Codechange: replace strncasecmp with case ignoring variant of StrStarts/EndsWith 2023-04-29 10:25:25 +02:00
Rubidium f74e26ca7e Codechange: replace error/usererror printf variant with fmt variant and rename 2023-04-25 17:55:09 +02:00
Rubidium f5f6306af3 Codechange: use string/fmt instead of printf for ShowInfo(F) 2023-04-24 17:51:54 +02:00
PeterN e97bf271dc
Codechange: Make SpriteType, CargoSortType, SourceType and ScriptType enum classes. (#10663)
This avoids a (soft) namespace conflict between the four ST_* enums.
2023-04-16 20:00:55 +01:00
Charles Pigott b282664242 Codechange: Replace all usages of alloca/AllocaM with more modern/less discouraged alternatives 2023-04-15 16:57:00 +01:00
Peter Nelson 8149ba338f Change: Check glyph size before trying to render it.
This change of order ensures that the "Font glyph is foot large" occurs
even if the glyph is too large for an alloca() allocation.
2023-01-14 20:50:59 +00:00
Peter Nelson fa0c67b10a Change: Remove guess-work from calls to GetGlyphOutline().
This API method is intended to be called twice, so don't attempt to guess
the required size.
2023-01-14 20:50:59 +00:00
Peter Nelson 5370e910d3 Change: Use std::vector for fallback font list. 2023-01-14 20:50:59 +00:00
glx22 e6c857cdba Codechange: [windows] cache the actually loaded font name 2022-12-23 23:23:03 +01:00
glx22 af3df959c2 Codechange: reduce code duplication 2022-12-23 23:23:03 +01:00
Peter Nelson 8599041ce4 Fix: GetDefaultFontHeight() is static, don't use -> 2022-12-18 11:46:01 -05:00
Peter Nelson 9666e46739 Feature: Variable GUI scale.
GUI scale is now variable from 100% to 500%, and no longer restricted to
powers-of-2.
2022-11-12 18:28:39 +00:00
Peter Nelson 062ea68422 Change: Scale position of font shadow. 2022-11-12 18:28:39 +00:00
Peter Nelson 2cdd8b7429 Change: Separate fontcache implementations. 2022-09-25 18:34:24 +01:00
Peter Nelson f6ad8e1c9c Change: Rename some freetype things to fontcache.
The font cache supports more than just FreeType as a font provider, but still used freetype in some naming.

This now uses more suitable terms.
2022-09-25 18:34:24 +01:00
Peter Nelson 273988551d Fix: font_win32.cpp compile failure with WITH_FREETYPE 2022-09-25 18:34:24 +01:00
rubidium42 55a11710a6 Codechange: convert printf DEBUG statements to fmt Debug statements 2021-06-13 12:45:45 +02:00
glx22 744a9e4745 Codechange: [WIN32] Add a wrapper around GetProcAddress() 2021-06-10 23:17:29 +02:00
rubidium42 77330d09fd Codechange: move font settings to std::string 2021-05-13 23:13:17 +02:00
Niels Martin Hansen c800dcaff8 Fix: [Win32] Font glyphs of certain widths broke
Font glyphs between 33 and 39 pixels wide, in the Win32 font system, used wrong alignment and caused glyphs to appear broken.
When in the 33 to 39 pixel range, glyphs without AA were rounded down to 32 pixel pitch, instead of up to 64 pixel pitch.
2021-04-10 11:39:28 +02:00
Niels Martin Hansen 746f1ca11a Codechange: Remove the now meaningless console_cp parameter from OTTD2FS 2021-04-07 09:31:47 +02:00
Niels Martin Hansen e0561dbded Fix #8713: Change OTTD2FS and FS2OTTD to return string objects instead of static buffers 2021-04-07 09:31:47 +02:00