OpenTTD Source 20251213-master-g1091fa6071
gfx_layout_fallback.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef GFX_LAYOUT_FALLBACK_H
11#define GFX_LAYOUT_FALLBACK_H
12
13#include "gfx_layout.h"
14
19public:
21 typedef char32_t CharType;
23 static const bool SUPPORTS_RTL = false;
24
25 static std::unique_ptr<ParagraphLayouter> GetParagraphLayout(char32_t *buff, char32_t *buff_end, FontMap &font_mapping);
26 static size_t AppendToBuffer(char32_t *buff, const char32_t *buffer_last, char32_t c);
27};
28
34inline char32_t SwapRtlPairedCharacters(char32_t c)
35{
36 /* There are many more paired brackets, but for fallback purposes we only handle ASCII brackets. */
37 /* https://www.unicode.org/Public/UCD/latest/ucd/BidiBrackets.txt */
38 switch (c) {
39 case U'(': return U')';
40 case U')': return U'(';
41 case U'[': return U']';
42 case U']': return U'[';
43 case U'{': return U'}';
44 case U'}': return U'{';
45 default: return c;
46 }
47}
48
49#endif /* GFX_LAYOUT_FALLBACK_H */
Helper class to construct a new FallbackParagraphLayout.
char32_t CharType
Helper for GetLayouter, to get the right type.
static std::unique_ptr< ParagraphLayouter > GetParagraphLayout(char32_t *buff, char32_t *buff_end, FontMap &font_mapping)
Get the actual ParagraphLayout for the given buffer.
static const bool SUPPORTS_RTL
Helper for GetLayouter, to get whether the layouter supports RTL.
static size_t AppendToBuffer(char32_t *buff, const char32_t *buffer_last, char32_t c)
Append a wide character to the internal buffer.
Functions related to laying out the texts.
std::vector< std::pair< int, Font > > FontMap
Mapping from index to font.
Definition gfx_layout.h:107
char32_t SwapRtlPairedCharacters(char32_t c)
Swap paired brackets for fallback RTL layouting.