OpenTTD
string_osx.cpp File Reference

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 "macos.h"
#include <CoreFoundation/CoreFoundation.h>

Go to the source code of this file.

Data Structures

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...
 

Functions

static CGFloat SpriteFontGetWidth (void *ref_con)
 Get the width of an encoded sprite font character. More...
 
void MacOSResetScriptCache (FontSize size)
 Delete CoreText font reference for a specific font size. More...
 
void MacOSSetCurrentLocaleName (const char *iso_code)
 Store current language locale as a CoreFounation locale. More...
 
int MacOSStringCompare (const char *s1, const char *s2)
 Compares two strings using case insensitive natural sort. More...
 

Variables

static CFLocaleRef _osx_locale = NULL
 Cached current locale. More...
 
static CTFontRef _font_cache [FS_END]
 CoreText cache for font information, cleared when OTTD changes fonts. More...
 
static CTRunDelegateCallbacks _sprite_font_callback
 

Detailed Description

Functions related to localized text support on OSX.

Definition in file string_osx.cpp.

Function Documentation

◆ MacOSResetScriptCache()

void MacOSResetScriptCache ( FontSize  size)

Delete CoreText font reference for a specific font size.

Definition at line 271 of file string_osx.cpp.

References _font_cache.

Referenced by CoreTextParagraphLayoutFactory::AppendToBuffer(), and Layouter::ResetFontCache().

◆ MacOSSetCurrentLocaleName()

void MacOSSetCurrentLocaleName ( const char *  iso_code)

Store current language locale as a CoreFounation locale.

Definition at line 280 of file string_osx.cpp.

References _osx_locale, and MacOSVersionIsAtLeast().

Referenced by CoreTextParagraphLayoutFactory::AppendToBuffer().

◆ MacOSStringCompare()

int MacOSStringCompare ( const char *  s1,
const char *  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 298 of file string_osx.cpp.

References _osx_locale, and MacOSVersionIsAtLeast().

Referenced by CoreTextParagraphLayoutFactory::AppendToBuffer().

◆ SpriteFontGetWidth()

static CGFloat SpriteFontGetWidth ( void *  ref_con)
static

Get the width of an encoded sprite font character.

Definition at line 118 of file string_osx.cpp.

References GetGlyphWidth().

Variable Documentation

◆ _font_cache

CTFontRef _font_cache[FS_END]
static

CoreText cache for font information, cleared when OTTD changes fonts.

Definition at line 27 of file string_osx.cpp.

Referenced by CoreTextParagraphLayoutFactory::GetParagraphLayout(), and MacOSResetScriptCache().

◆ _osx_locale

CFLocaleRef _osx_locale = NULL
static

Cached current locale.

Definition at line 25 of file string_osx.cpp.

Referenced by MacOSSetCurrentLocaleName(), and MacOSStringCompare().

◆ _sprite_font_callback

CTRunDelegateCallbacks _sprite_font_callback
static
Initial value:
= {
kCTRunDelegateCurrentVersion, NULL, NULL, NULL,
}
static CGFloat SpriteFontGetWidth(void *ref_con)
Get the width of an encoded sprite font character.
Definition: string_osx.cpp:118

Definition at line 126 of file string_osx.cpp.