mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r25437) -Codechange: rework the FreeTypeSettings structure to make it better grouped
This commit is contained in:
parent
13c450a66b
commit
94a5fe6b92
|
@ -179,7 +179,7 @@ void InitFreeType(bool monospace)
|
|||
UnloadFace(&_face_large);
|
||||
}
|
||||
|
||||
if (StrEmpty(_freetype.small_font) && StrEmpty(_freetype.medium_font) && StrEmpty(_freetype.large_font) && StrEmpty(_freetype.mono_font)) {
|
||||
if (StrEmpty(_freetype.small.font) && StrEmpty(_freetype.medium.font) && StrEmpty(_freetype.large.font) && StrEmpty(_freetype.mono.font)) {
|
||||
DEBUG(freetype, 1, "No font faces specified, using sprite fonts instead");
|
||||
return;
|
||||
}
|
||||
|
@ -195,25 +195,25 @@ void InitFreeType(bool monospace)
|
|||
|
||||
/* Load each font */
|
||||
if (monospace) {
|
||||
LoadFreeTypeFont(_freetype.mono_font , &_face_mono, "mono");
|
||||
LoadFreeTypeFont(_freetype.mono.font , &_face_mono, "mono");
|
||||
|
||||
if (_face_mono != NULL) {
|
||||
SetFontGeometry(_face_mono, FS_MONO, _freetype.mono_size);
|
||||
SetFontGeometry(_face_mono, FS_MONO, _freetype.mono.size);
|
||||
}
|
||||
} else {
|
||||
LoadFreeTypeFont(_freetype.small_font, &_face_small, "small");
|
||||
LoadFreeTypeFont(_freetype.medium_font, &_face_medium, "medium");
|
||||
LoadFreeTypeFont(_freetype.large_font, &_face_large, "large");
|
||||
LoadFreeTypeFont(_freetype.small.font, &_face_small, "small");
|
||||
LoadFreeTypeFont(_freetype.medium.font, &_face_medium, "medium");
|
||||
LoadFreeTypeFont(_freetype.large.font, &_face_large, "large");
|
||||
|
||||
/* Set each font size */
|
||||
if (_face_small != NULL) {
|
||||
SetFontGeometry(_face_small, FS_SMALL, _freetype.small_size);
|
||||
SetFontGeometry(_face_small, FS_SMALL, _freetype.small.size);
|
||||
}
|
||||
if (_face_medium != NULL) {
|
||||
SetFontGeometry(_face_medium, FS_NORMAL, _freetype.medium_size);
|
||||
SetFontGeometry(_face_medium, FS_NORMAL, _freetype.medium.size);
|
||||
}
|
||||
if (_face_large != NULL) {
|
||||
SetFontGeometry(_face_large, FS_LARGE, _freetype.large_size);
|
||||
SetFontGeometry(_face_large, FS_LARGE, _freetype.large.size);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -343,10 +343,10 @@ static bool GetFontAAState(FontSize size)
|
|||
|
||||
switch (size) {
|
||||
default: NOT_REACHED();
|
||||
case FS_NORMAL: return _freetype.medium_aa;
|
||||
case FS_SMALL: return _freetype.small_aa;
|
||||
case FS_LARGE: return _freetype.large_aa;
|
||||
case FS_MONO: return _freetype.mono_aa;
|
||||
case FS_NORMAL: return _freetype.medium.aa;
|
||||
case FS_SMALL: return _freetype.small.aa;
|
||||
case FS_LARGE: return _freetype.large.aa;
|
||||
case FS_MONO: return _freetype.mono.aa;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,19 +25,19 @@ void InitializeUnicodeGlyphMap();
|
|||
|
||||
#ifdef WITH_FREETYPE
|
||||
|
||||
/** Settings for a single freetype font. */
|
||||
struct FreeTypeSubSetting {
|
||||
char font[MAX_PATH]; ///< The name of the font, or path to the font.
|
||||
uint size; ///< The (requested) size of the font.
|
||||
bool aa; ///< Whether to do anti aliasing or not.
|
||||
};
|
||||
|
||||
/** Settings for the freetype fonts. */
|
||||
struct FreeTypeSettings {
|
||||
char small_font[MAX_PATH];
|
||||
char medium_font[MAX_PATH];
|
||||
char large_font[MAX_PATH];
|
||||
char mono_font[MAX_PATH];
|
||||
uint small_size;
|
||||
uint medium_size;
|
||||
uint large_size;
|
||||
uint mono_size;
|
||||
bool small_aa;
|
||||
bool medium_aa;
|
||||
bool large_aa;
|
||||
bool mono_aa;
|
||||
FreeTypeSubSetting small; ///< The smallest font; mostly used for zoomed out view.
|
||||
FreeTypeSubSetting medium; ///< The normal font size.
|
||||
FreeTypeSubSetting large; ///< The largest font; mostly used for newspapers.
|
||||
FreeTypeSubSetting mono; ///< The mono space font used for license/readme viewers.
|
||||
};
|
||||
|
||||
extern FreeTypeSettings _freetype;
|
||||
|
|
|
@ -2095,9 +2095,9 @@ class LanguagePackGlyphSearcher : public MissingGlyphSearcher {
|
|||
/* virtual */ void SetFontNames(FreeTypeSettings *settings, const char *font_name)
|
||||
{
|
||||
#ifdef WITH_FREETYPE
|
||||
strecpy(settings->small_font, font_name, lastof(settings->small_font));
|
||||
strecpy(settings->medium_font, font_name, lastof(settings->medium_font));
|
||||
strecpy(settings->large_font, font_name, lastof(settings->large_font));
|
||||
strecpy(settings->small.font, font_name, lastof(settings->small.font));
|
||||
strecpy(settings->medium.font, font_name, lastof(settings->medium.font));
|
||||
strecpy(settings->large.font, font_name, lastof(settings->large.font));
|
||||
#endif /* WITH_FREETYPE */
|
||||
}
|
||||
};
|
||||
|
|
|
@ -135,35 +135,35 @@ def = false
|
|||
ifdef = WITH_FREETYPE
|
||||
name = ""small_font""
|
||||
type = SLE_STRB
|
||||
var = _freetype.small_font
|
||||
var = _freetype.small.font
|
||||
def = NULL
|
||||
|
||||
[SDTG_STR]
|
||||
ifdef = WITH_FREETYPE
|
||||
name = ""medium_font""
|
||||
type = SLE_STRB
|
||||
var = _freetype.medium_font
|
||||
var = _freetype.medium.font
|
||||
def = NULL
|
||||
|
||||
[SDTG_STR]
|
||||
ifdef = WITH_FREETYPE
|
||||
name = ""large_font""
|
||||
type = SLE_STRB
|
||||
var = _freetype.large_font
|
||||
var = _freetype.large.font
|
||||
def = NULL
|
||||
|
||||
[SDTG_STR]
|
||||
ifdef = WITH_FREETYPE
|
||||
name = ""mono_font""
|
||||
type = SLE_STRB
|
||||
var = _freetype.mono_font
|
||||
var = _freetype.mono.font
|
||||
def = NULL
|
||||
|
||||
[SDTG_VAR]
|
||||
ifdef = WITH_FREETYPE
|
||||
name = ""small_size""
|
||||
type = SLE_UINT
|
||||
var = _freetype.small_size
|
||||
var = _freetype.small.size
|
||||
def = 0
|
||||
min = 0
|
||||
max = 72
|
||||
|
@ -172,7 +172,7 @@ max = 72
|
|||
ifdef = WITH_FREETYPE
|
||||
name = ""medium_size""
|
||||
type = SLE_UINT
|
||||
var = _freetype.medium_size
|
||||
var = _freetype.medium.size
|
||||
def = 0
|
||||
min = 0
|
||||
max = 72
|
||||
|
@ -181,7 +181,7 @@ max = 72
|
|||
ifdef = WITH_FREETYPE
|
||||
name = ""large_size""
|
||||
type = SLE_UINT
|
||||
var = _freetype.large_size
|
||||
var = _freetype.large.size
|
||||
def = 0
|
||||
min = 0
|
||||
max = 72
|
||||
|
@ -190,7 +190,7 @@ max = 72
|
|||
ifdef = WITH_FREETYPE
|
||||
name = ""mono_size""
|
||||
type = SLE_UINT
|
||||
var = _freetype.mono_size
|
||||
var = _freetype.mono.size
|
||||
def = 0
|
||||
min = 0
|
||||
max = 72
|
||||
|
@ -198,25 +198,25 @@ max = 72
|
|||
[SDTG_BOOL]
|
||||
ifdef = WITH_FREETYPE
|
||||
name = ""small_aa""
|
||||
var = _freetype.small_aa
|
||||
var = _freetype.small.aa
|
||||
def = false
|
||||
|
||||
[SDTG_BOOL]
|
||||
ifdef = WITH_FREETYPE
|
||||
name = ""medium_aa""
|
||||
var = _freetype.medium_aa
|
||||
var = _freetype.medium.aa
|
||||
def = false
|
||||
|
||||
[SDTG_BOOL]
|
||||
ifdef = WITH_FREETYPE
|
||||
name = ""large_aa""
|
||||
var = _freetype.large_aa
|
||||
var = _freetype.large.aa
|
||||
def = false
|
||||
|
||||
[SDTG_BOOL]
|
||||
ifdef = WITH_FREETYPE
|
||||
name = ""mono_aa""
|
||||
var = _freetype.mono_aa
|
||||
var = _freetype.mono.aa
|
||||
def = false
|
||||
|
||||
[SDTG_VAR]
|
||||
|
|
|
@ -136,7 +136,7 @@ TextfileWindow::TextfileWindow(TextfileType file_type) : Window(&_textfile_desc)
|
|||
/* virtual */ void TextfileWindow::SetFontNames(FreeTypeSettings *settings, const char *font_name)
|
||||
{
|
||||
#ifdef WITH_FREETYPE
|
||||
strecpy(settings->mono_font, font_name, lastof(settings->mono_font));
|
||||
strecpy(settings->mono.font, font_name, lastof(settings->mono.font));
|
||||
#endif /* WITH_FREETYPE */
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue