OpenTTD Source 20251213-master-g1091fa6071
string_uniscribe.cpp File Reference

Functions related to laying out text on Win32. More...

#include "../../stdafx.h"
#include "../../debug.h"
#include "string_uniscribe.h"
#include "../../gfx_func.h"
#include "../../gfx_layout_fallback.h"
#include "../../language.h"
#include "../../strings_func.h"
#include "../../string_func.h"
#include "../../core/utf8.hpp"
#include "../../table/control_codes.h"
#include "../../zoom_func.h"
#include "win32.h"
#include <windows.h>
#include <usp10.h>
#include "../../safeguards.h"

Go to the source code of this file.

Data Structures

struct  UniscribeRun
 Contains all information about a run of characters. More...
 
class  UniscribeParagraphLayout
 Wrapper for doing layouts with Uniscribe. More...
 
class  UniscribeParagraphLayout::UniscribeVisualRun
 Visual run contains data about the bit of text with the same font. More...
 
class  UniscribeParagraphLayout::UniscribeLine
 A single line worth of VisualRuns. More...
 

Functions

static std::vector< SCRIPT_ITEM > UniscribeItemizeString (UniscribeParagraphLayoutFactory::CharType *buff, int32_t length)
 Break a string into language formatting ranges.
 
static bool UniscribeShapeRun (const UniscribeParagraphLayoutFactory::CharType *buff, UniscribeRun &range)
 Generate and place glyphs for a run of characters.
 
void UniscribeResetScriptCache (FontSize)
 
static HFONT HFontFromFont (const Font &font)
 Load the matching native Windows font.
 

Variables

static std::map< FontIndex, SCRIPT_CACHE > _script_cache
 Uniscribe cache for internal font information, cleared when OTTD changes fonts.
 

Detailed Description

Functions related to laying out text on Win32.

Definition in file string_uniscribe.cpp.

Function Documentation

◆ HFontFromFont()

static HFONT HFontFromFont ( const Font font)
static

Load the matching native Windows font.

Definition at line 146 of file string_uniscribe.cpp.

References convert_to_fs(), FontCache::GetFontName(), FontCache::GetHeight(), and FontCache::GetOSHandle().

Referenced by UniscribeShapeRun().

◆ UniscribeItemizeString()

static std::vector< SCRIPT_ITEM > UniscribeItemizeString ( UniscribeParagraphLayoutFactory::CharType buff,
int32_t  length 
)
static

Break a string into language formatting ranges.

Definition at line 287 of file string_uniscribe.cpp.

References _current_language, _current_text_dir, TD_RTL, and LanguagePackHeader::winlangid.

Referenced by UniscribeParagraphLayoutFactory::GetParagraphLayout(), and UniscribeStringIterator::SetString().

◆ UniscribeResetScriptCache()

void UniscribeResetScriptCache ( FontSize  size)

Definition at line 137 of file string_uniscribe.cpp.

◆ UniscribeShapeRun()

static bool UniscribeShapeRun ( const UniscribeParagraphLayoutFactory::CharType buff,
UniscribeRun range 
)
static

Generate and place glyphs for a run of characters.

Determine the glyph positions for a run.

Definition at line 198 of file string_uniscribe.cpp.

References _script_cache, UniscribeRun::FallbackShape(), FontCache::GetGlyphWidth(), HFontFromFont(), and FontCache::IsBuiltInFont().

Referenced by UniscribeParagraphLayoutFactory::GetParagraphLayout().

Variable Documentation

◆ _script_cache

std::map<FontIndex, SCRIPT_CACHE> _script_cache
static

Uniscribe cache for internal font information, cleared when OTTD changes fonts.

Definition at line 34 of file string_uniscribe.cpp.

Referenced by UniscribeShapeRun().