OpenTTD Source: src/gfx_layout.h File Reference

OpenTTD Source 15.3

Data Structures | Typedefs | Functions
gfx_layout.h File Reference

Functions related to laying out the texts. More...

`#include "misc/lrucache.hpp"`
`#include "fontcache.h"`
`#include "gfx_func.h"`
`#include "core/math_func.hpp"`
`#include <string_view>`

Go to the source code of this file.

## Data Structures
struct | FontState
| Text drawing parameters, which can change while drawing a line, but are kept between multiple parts of the same text, e.g. More...
struct | std::hash< std::vector< T > >
struct | std::hash< FontState >
class | Font
| Container with information about a font. More...
class | ParagraphLayouter
| Interface to glue fallback and normal layouter into one. More...
class | ParagraphLayouter::Position
| Position of a glyph within a VisualRun. More...
class | ParagraphLayouter::VisualRun
| Visual run contains data about the bit of text with the same font. More...
class | ParagraphLayouter::Line
| A single line worth of VisualRuns. More...
class | Layouter
| The layouter performs all the layout work. More...
struct | Layouter::LineCacheKey
| Key into the linecache. More...
struct | Layouter::LineCacheQuery
struct | Layouter::LineCacheEqualTo
struct | Layouter::LineCacheItem
| Item in the linecache. More...
struct | std::hash< Layouter::LineCacheQuery >
struct | Layouter::LineCacheHash

## Typedefs
using | FontMap = std::vector< std::pair< int, Font * > >
| Mapping from index to font.

## Functions
ParagraphLayouter::Position | GetCharPosInString (std::string_view str, size_t pos, FontSize start_fontsize=FS_NORMAL)
| Get the leading corner of a character in a single-line string relative to the start of the string.
ptrdiff_t | GetCharAtPosition (std::string_view str, int x, FontSize start_fontsize=FS_NORMAL)
| Get the character from a string that is drawn at a specific position.

## Detailed Description

Functions related to laying out the texts.

Definition in file gfx_layout.h.

## Typedef Documentation

## ◆ FontMap

using FontMap = std::vector<std::pair<int, Font *> >

Mapping from index to font.

The pointer is owned by FontColourMap.

Definition at line 106 of file gfx_layout.h.

## Function Documentation

## ◆ GetCharAtPosition()

ptrdiff_t GetCharAtPosition | ( | std::string_view | str,
|  | int | x,
|  | FontSize | start_fontsize
| ) |  |

Get the character from a string that is drawn at a specific position.

Parameters

  str | String to test.
  x | Position relative to the start of the string.
  start_fontsize | Font size to start the text with.

Returns
  Index of the character position or -1 if there is no character at the position.

Definition at line 441 of file gfx_layout.cpp.

References Layouter::GetCharAtPosition().

Referenced by IConsoleWindow::GetTextCharacterAtPosition().

## ◆ GetCharPosInString()

ParagraphLayouter::Position GetCharPosInString | ( | std::string_view | str,
|  | size_t | pos,
|  | FontSize | start_fontsize
| ) |  |

Get the leading corner of a character in a single-line string relative to the start of the string.

Parameters

  str | String containing the character.
  pos | Index to the character in the string.
  start_fontsize | Font size to start the text with.

Returns
  Upper left corner of the glyph associated with the character.

Definition at line 425 of file gfx_layout.cpp.

References Layouter::GetCharPosition().

Referenced by QueryString::GetBoundingRect(), IConsoleWindow::GetTextBoundingRect(), Textbuf::UpdateCaretPosition(), and Textbuf::UpdateMarkedText().