OpenTTD Source 20261112-master-gbcbec5e63f
string_osx.h File Reference

Functions related to localized text support on OSX. More...

Go to the source code of this file.

Data Structures

class  OSXStringIterator
 String iterator using CoreText as a backend. More...
struct  OSXStringIterator::CharInfo
 Break info for a character. More...
class  CoreTextParagraphLayoutFactory
 Helper class to construct a new CoreTextParagraphLayout. More...

Functions

void MacOSSetCurrentLocaleName (std::string_view iso_code)
 Store current language locale as a CoreFoundation locale.
int MacOSStringCompare (std::string_view s1, std::string_view s2)
 Compares two strings using case insensitive natural sort.
int MacOSStringContains (std::string_view str, std::string_view value, bool case_insensitive)
 Search if a string is contained in another string using the current locale.
void MacOSRegisterExternalFont (std::string_view file_path)
 Register an external font file with the CoreText system.

Detailed Description

Functions related to localized text support on OSX.

Definition in file string_osx.h.

Function Documentation

◆ MacOSRegisterExternalFont()

void MacOSRegisterExternalFont ( std::string_view file_path)

Register an external font file with the CoreText system.

Parameters
file_pathUTF-8 encoded path of the font.

Definition at line 274 of file string_osx.cpp.

◆ MacOSSetCurrentLocaleName()

void MacOSSetCurrentLocaleName ( std::string_view iso_code)

Store current language locale as a CoreFoundation locale.

Parameters
iso_codeThe ISO language code to set.

Definition at line 286 of file string_osx.cpp.

References _osx_locale.

Referenced by ReadLanguagePack().

◆ MacOSStringCompare()

int MacOSStringCompare ( std::string_view s1,
std::string_view s2 )

Compares two strings using case insensitive natural sort.

Parameters
s1First string to compare.
s2Second string to compare.
Returns
1 if s1 < s2, 2 if s1 == s2, 3 if s1 > s2, or 0 if not supported by the OS.

Definition at line 299 of file string_osx.cpp.

References _osx_locale.

Referenced by StrNaturalCompare().

◆ MacOSStringContains()

int MacOSStringContains ( std::string_view str,
std::string_view value,
bool case_insensitive )

Search if a string is contained in another string using the current locale.

Parameters
strString to search in.
valueString to search for.
case_insensitiveSearch case-insensitive.
Returns
1 if value was found, 0 if it was not found, or -1 if not supported by the OS.

Definition at line 320 of file string_osx.cpp.

References _osx_locale.

Referenced by StrNaturalContains(), and StrNaturalContainsIgnoreCase().