Commit Graph

82 Commits

Author SHA1 Message Date
Peter Nelson a28ab8cac2
Codechange: Replace C-style casts to size_t with static_cast. (#12455)
* Codechange: Replace C-style casts to size_t with static_cast.

This touches only simple value-type casts.

* Codechange: Replace static_cast<size_t>(-1) with SIZE_MAX

Co-authored-by: Rubidium <rubidium@openttd.org>
2024-04-19 20:34:36 +01:00
Peter Nelson 6d276698b6
Fix: Memory leak in ICUParagraphLayout::NextLine() (#11895)
This function calls icu::BreakIterator::createLineInstance() but does not clean up after it.

Instead use a static instance that is cloned (for thread-safety) and deleted as necessary.
2024-01-27 20:13:42 +00:00
Peter Nelson d6ccfdbbd9
Fix #11827: Make Layouter::GetCharPosition() aware of ligatures. (#11831)
When ligatures happen the precise individual character position is not known, so instead return the previous position (which is that of the ligature.)
2024-01-20 17:16:42 +00:00
Peter Nelson ae575a7a5b Codechange: Store text run positions in vector of points.
This simplifies the interlaced vector of x/y positions.
2024-01-19 00:08:31 +00:00
Peter Nelson a6873ef7dd
Codechange: Avoid repeatedly calling virtual methods in text drawing loop. (#11774) 2024-01-14 19:06:50 +00:00
Niels Martin Hansen 4765d0f8c2 Change: Text Layouter support querying all lines for character at pixel 2023-09-13 16:11:08 +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
Niels Martin Hansen 103d88ee33 Fix: Layouter not taking stripped formatting codes into account when mapping visual coordinates to/from original string 2023-06-26 17:31:17 +02:00
Niels Martin Hansen ed3f14686d Fix: Layouter::GetCharAtPosition counting wrong
Bug introduced in commit 60399e
2023-06-18 21:07:40 +02:00
Rubidium 96fef9f643 Codechange: allocate enough memory to layout the strings 2023-06-06 18:08:11 +02:00
Rubidium 3323402aaa Codechange: rename smallvec_type to container_func and use only when needed 2023-05-20 16:53:10 +02:00
Peter Nelson bf8f24f9a8 Codechange: Use unique_ptr for text layout font mapping.
This must stay a pointer as the value passed to other structures.
2023-05-18 12:18:30 +01:00
Peter Nelson c38df2d589 Codechange: Use std::map instead of custom SmallMap. 2023-05-18 12:18:30 +01:00
Patric Stout a05ae2497f Codechange: simplify how GetCharPosition() works 2023-05-08 19:21:42 +02:00
Patric Stout 60399e17bd Codechange: C++-ify the Layouter and related functions
They all now access a std::string_view, instead of a "const char *"
or std::string (in some cases).

Additionally, GetCharAtPosition and friends now return an index
instead of a "const char *", as it makes for a more clear interface.
2023-05-08 19:21:42 +02:00
Patric Stout 81d4fa6999 Feature: drop ICU-lx in favour of directly interfacing with harfbuzz
This means we have RTL support again with ICU 58+. It makes use of:
- ICU for bidi-itemization
- ICU for script-itemization
- OpenTTD for style-itemization
- harfbuzz for shaping
2023-05-01 22:17:56 +02:00
Patric Stout 9cb60768fe Codechange: split implementations of ParagraphLayouterFactory into their own file 2023-05-01 22:17:56 +02:00
Rubidium c578917783 Fix #10057: FallbackParagraphLayout fails to properly wrap
... during the first word after a new run has been started.
2023-01-15 11:43:22 +01:00
Peter Nelson daaa058493 Change: Vertically centre sprite font relative to TrueType font. 2022-12-18 11:46:01 -05:00
PeterN cea62ef73d
Fix #10161: Ignore ascender in FallbackLayouter for non-built-in fonts. (#10169) 2022-11-13 17:10:34 +00: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
Frédéric Simonis ac4a7d02c7
Codechange: Improve LineCache queries (#9417)
Adds the support to query the linecache without copying the string.
This uses a custom transparent comparator in conjunction with
a query type using a std::string_view.
2021-08-16 11:18:47 +02:00
rubidium42 55a11710a6 Codechange: convert printf DEBUG statements to fmt Debug statements 2021-06-13 12:45:45 +02:00
Charles Pigott 9b800a96ed
Codechange: Remove min/max functions in favour of STL variants (#8502) 2021-01-08 11:16:18 +01:00
Lars Wendler cf29d23ba4 Fix: build with icu-68.1
icu-68.1 removed public macro definitions for TRUE and FALSE

Signed-off-by: Lars Wendler <polynomial-c@gentoo.org>
2020-10-30 18:07:58 +00:00
glx 0c80ae5288 Fix: Ignore not printable characters when layouting a string 2020-02-15 23:15:58 +00:00
S. D. Cloudt 13cc8a0cee Cleanup: Removed SVN headers 2019-11-10 17:59:20 +00:00
Charles Pigott 150884a93f Fix: Remove workaround for clang-3.8, now that GCC9 warns about it 2019-09-30 14:00:06 +01:00
pnda a35b43ce93 Fix #6666: Mismatched parentheses in RTL languages 2019-07-07 18:30:51 +02:00
Henry Wilson 7c8e7c6b6e Codechange: Use null pointer literal instead of the NULL macro 2019-04-10 23:22:20 +02:00
Michael Lutz baf9229931 Codechange: Replace AutoDeleteSmallVector with direct std::vector use in text layout code. 2019-04-09 22:45:15 +02:00
Michael Lutz 329bb52613 Codechange: Store text layout runs directly as values in a std::vector instead of heap allocated.
This reduces memory allocations and heap fragmentation.
2019-04-09 22:45:15 +02:00
Michael Lutz fbc4cef180 Codechange: Use override specifier for text layout classes. 2019-04-09 22:45:15 +02:00
glx22 66dd7c3879
Fix: MSVC warnings (#7423) 2019-03-28 00:09:33 +01:00
Henry Wilson cc62f4163f Cleanup: Remove unused size template parameters from SmallMap and Auto[Free|Delete]SmallVector 2019-03-26 20:15:57 +00:00
Henry Wilson ab711e6942 Codechange: Replaced SmallVector::[Begin|End]() with std alternatives 2019-03-26 20:15:57 +00:00
Henry Wilson a0f36a50e6 Codechange: Replaced SmallVector::Append() with std::vector::[push|emplace]_back() 2019-03-26 20:15:57 +00:00
Henry Wilson 097328c3d7 Codechange: Replaced SmallVector::Get() const with std alternatives 2019-03-26 20:15:57 +00:00
Henry Wilson a690936ed7 Codechange: Replace SmallVector::Length() with std::vector::size() 2019-03-26 20:15:57 +00:00
Henry Wilson bfd79e59dc Codechange: Replace SmallVector::Clear() with std::vector::clear() 2019-03-26 20:15:57 +00:00
Patric Stout 52d7e7d45e Codechange: ICU_LAYOUT is in reality ICU_LX (according to their CMake files)
By naming it in a different way, things get a bit confusing.
Especially if we are switching to CMake, which autodetects these
things, we need to use the name the authors of ICU gave it; not
our interpertation of that name.
2019-03-11 10:16:00 +01:00
Michael Lutz 32ce1ce347 Add: [OSX] Text layout using the native CoreText API.
By default, the native API will be used instead of ICU, but if ICU is
forced in using configure, it will take precedence.
2018-12-08 20:13:27 +01:00
Charles Pigott e0c0394e37 Fix: Remove various dead or unnecessary assignments 2018-10-31 12:41:49 +01:00
Stefan Strogin fec44b0d09 Fix #6854: Compilation with ICU 62 (#6912) 2018-09-20 22:36:45 +02:00
Ingo von Borstel 88b77a7883
Fix #6844: Compile warning when compiling dedicated server (#6849) 2018-07-07 18:48:17 +02:00
Michael Lutz 574f547aca Fix 768a31b: When cascading to another text layouter, clear the old font run state left over from the previous (failed) layout attempt. 2018-06-16 11:04:03 +02:00
Michael Lutz 768a31bfe3 Add: [Win32] Text layout using the native Windows Uniscribe library.
Uniscribe is sometimes producing different results compared to ICU, especially
when RTL and LTR content is mixed. Comparing the results to other programs
(like editors or web browsers) leads me to believe that the result are at least
not worse than ICU and possibly better.
2018-06-06 21:37:09 +02:00
Michael Lutz a4278c302b Codechange: Move ParagraphLayouter-specific functions into factory classes instead of relying on overloads. 2018-06-06 21:37:09 +02:00
PeterN 3b32075e8a
Add: {PUSH_COLOUR} and {POP_COLOUR} control codes to handle switching colours. (#6737)
This replaces the internal SCC_PREVIOUS_COLOUR swap.
2018-04-19 19:33:21 +01:00
Pavel Stupnikov 9175c349da Fix #6465: Add {NORMAL_FONT} and {MONO_FONT} control codes to GS strings (#6726) 2018-04-17 18:41:31 +01:00