OpenTTD Source  20241121-master-g67a0fccfad
gfx_layout_icu.cpp File Reference

Handling of laying out with ICU / Harfbuzz. More...

#include "stdafx.h"
#include "gfx_layout_icu.h"
#include "debug.h"
#include "strings_func.h"
#include "language.h"
#include "table/control_codes.h"
#include "zoom_func.h"
#include "3rdparty/icu/scriptrun.h"
#include <unicode/ubidi.h>
#include <unicode/brkiter.h>
#include <hb.h>
#include <hb-ft.h>
#include "safeguards.h"

Go to the source code of this file.

Data Structures

class  ICURun
 Helper class to store the information of all the runs of a paragraph in. More...
 
class  ICUParagraphLayout
 Wrapper for doing layouts with ICU. More...
 
class  ICUParagraphLayout::ICUVisualRun
 Visual run contains data about the bit of text with the same font. More...
 
class  ICUParagraphLayout::ICULine
 A single line worth of VisualRuns. More...
 

Functions

std::vector< ICURunItemizeBidi (UChar *buff, size_t length)
 Itemize the string into runs per embedding level. More...
 
std::vector< ICURunItemizeScript (UChar *buff, size_t length, std::vector< ICURun > &runs_current)
 Itemize the string into runs per script, based on the previous created runs. More...
 
std::vector< ICURunItemizeStyle (std::vector< ICURun > &runs_current, FontMap &font_mapping)
 Itemize the string into runs per style, based on the previous created runs. More...
 

Variables

constexpr float FONT_SCALE = 64.0
 HarfBuzz FreeType integration sets the font scaling, which is always in 1/64th of a pixel.
 

Detailed Description

Handling of laying out with ICU / Harfbuzz.

Definition in file gfx_layout_icu.cpp.

Function Documentation

◆ ItemizeBidi()

std::vector<ICURun> ItemizeBidi ( UChar *  buff,
size_t  length 
)

Itemize the string into runs per embedding level.

Later on, based on the levels, we can deduce the order of a subset of runs.

Parameters
buffThe string to itemize.
lengthThe length of the string.
Returns
The runs.

Definition at line 250 of file gfx_layout_icu.cpp.

References _current_text_dir, Debug, and TD_RTL.

◆ ItemizeScript()

std::vector<ICURun> ItemizeScript ( UChar *  buff,
size_t  length,
std::vector< ICURun > &  runs_current 
)

Itemize the string into runs per script, based on the previous created runs.

Basically, this always returns the same or more runs than given.

Parameters
buffThe string to itemize.
lengthThe length of the string.
runs_currentThe current runs.
Returns
The runs.

Definition at line 302 of file gfx_layout_icu.cpp.

◆ ItemizeStyle()

std::vector<ICURun> ItemizeStyle ( std::vector< ICURun > &  runs_current,
FontMap font_mapping 
)

Itemize the string into runs per style, based on the previous created runs.

Basically, this always returns the same or more runs than given.

Parameters
runs_currentThe current runs.
font_mappingThe font mapping.
Returns
The runs.

Definition at line 335 of file gfx_layout_icu.cpp.