OpenTTD Source 20241224-master-gf74b0cf984
|
Functions related to localized text support on OSX. More...
#include "../../stdafx.h"
#include "string_osx.h"
#include "../../string_func.h"
#include "../../strings_func.h"
#include "../../table/control_codes.h"
#include "../../fontcache.h"
#include "../../zoom_func.h"
#include "macos.h"
#include <CoreFoundation/CoreFoundation.h>
Go to the source code of this file.
Data Structures | |
struct | CTRunDelegateCallbacks |
class | CoreTextParagraphLayout |
Wrapper for doing layouts with CoreText. More... | |
class | CoreTextParagraphLayout::CoreTextVisualRun |
Visual run contains data about the bit of text with the same font. More... | |
class | CoreTextParagraphLayout::CoreTextLine |
A single line worth of VisualRuns. More... | |
Typedefs | |
typedef const struct __CTRunDelegate * | CTRunDelegateRef |
typedef void(* | CTRunDelegateDeallocateCallback) (void *refCon) |
typedef CGFloat(* | CTRunDelegateGetAscentCallback) (void *refCon) |
typedef CGFloat(* | CTRunDelegateGetDescentCallback) (void *refCon) |
typedef CGFloat(* | CTRunDelegateGetWidthCallback) (void *refCon) |
Enumerations | |
enum | { kCTRunDelegateVersion1 = 1 , kCTRunDelegateCurrentVersion = kCTRunDelegateVersion1 } |
Functions | |
CTRunDelegateRef | CTRunDelegateCreate (const CTRunDelegateCallbacks *callbacks, void *refCon) AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER |
static CGFloat | SpriteFontGetWidth (void *ref_con) |
Get the width of an encoded sprite font character. | |
void | MacOSResetScriptCache (FontSize size) |
Delete CoreText font reference for a specific font size. | |
void | MacOSRegisterExternalFont (const char *file_path) |
Register an external font file with the CoreText system. | |
void | MacOSSetCurrentLocaleName (const char *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 (const std::string_view str, const std::string_view value, bool case_insensitive) |
Search if a string is contained in another string using the current locale. | |
Variables | |
const CFStringRef kCTRunDelegateAttributeName | AVAILABLE_MAC_OS_X_VERSION_10_5_AND_LATER |
static CFAutoRelease< CFLocaleRef > | _osx_locale |
Cached current locale. | |
static CFAutoRelease< CTFontRef > | _font_cache [FS_END] |
CoreText cache for font information, cleared when OTTD changes fonts. | |
static CTRunDelegateCallbacks | _sprite_font_callback |
Functions related to localized text support on OSX.
Definition in file string_osx.cpp.
typedef void(* CTRunDelegateDeallocateCallback) (void *refCon) |
Definition at line 27 of file string_osx.cpp.
typedef CGFloat(* CTRunDelegateGetAscentCallback) (void *refCon) |
Definition at line 28 of file string_osx.cpp.
typedef CGFloat(* CTRunDelegateGetDescentCallback) (void *refCon) |
Definition at line 29 of file string_osx.cpp.
typedef CGFloat(* CTRunDelegateGetWidthCallback) (void *refCon) |
Definition at line 30 of file string_osx.cpp.
typedef const struct __CTRunDelegate* CTRunDelegateRef |
Definition at line 25 of file string_osx.cpp.
anonymous enum |
Definition at line 39 of file string_osx.cpp.
void MacOSRegisterExternalFont | ( | const char * | file_path | ) |
Register an external font file with the CoreText system.
Definition at line 303 of file string_osx.cpp.
References MacOSVersionIsAtLeast().
void MacOSResetScriptCache | ( | FontSize | size | ) |
Delete CoreText font reference for a specific font size.
Definition at line 297 of file string_osx.cpp.
References _font_cache.
Referenced by Layouter::ResetFontCache().
void MacOSSetCurrentLocaleName | ( | const char * | iso_code | ) |
Store current language locale as a CoreFoundation locale.
Definition at line 314 of file string_osx.cpp.
References _osx_locale, and MacOSVersionIsAtLeast().
Referenced by ReadLanguagePack().
int MacOSStringCompare | ( | std::string_view | s1, |
std::string_view | s2 | ||
) |
Compares two strings using case insensitive natural sort.
s1 | First string to compare. |
s2 | Second string to compare. |
Definition at line 329 of file string_osx.cpp.
References _osx_locale, and MacOSVersionIsAtLeast().
Referenced by StrNaturalCompare().
int MacOSStringContains | ( | const std::string_view | str, |
const std::string_view | value, | ||
bool | case_insensitive | ||
) |
Search if a string is contained in another string using the current locale.
str | String to search in. |
value | String to search for. |
case_insensitive | Search case-insensitive. |
Definition at line 353 of file string_osx.cpp.
References _osx_locale, and MacOSVersionIsAtLeast().
Referenced by StrNaturalContains(), and StrNaturalContainsIgnoreCase().
|
static |
Get the width of an encoded sprite font character.
Definition at line 138 of file string_osx.cpp.
References GetGlyphWidth().
|
static |
CoreText cache for font information, cleared when OTTD changes fonts.
Definition at line 53 of file string_osx.cpp.
Referenced by CoreTextParagraphLayoutFactory::GetParagraphLayout(), and MacOSResetScriptCache().
|
static |
Cached current locale.
Definition at line 51 of file string_osx.cpp.
Referenced by MacOSSetCurrentLocaleName(), MacOSStringCompare(), MacOSStringContains(), and OSXStringIterator::SetString().
|
static |
Definition at line 146 of file string_osx.cpp.