summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2013-06-23 15:23:22 +0000
committerrubidium <rubidium@openttd.org>2013-06-23 15:23:22 +0000
commit94a5fe6b927da6e898968d240a3486dbe60d6be8 (patch)
tree2431528829a54d93eceac0f6628fce848e47d5b1
parent13c450a66bef275a88d687e6f500425b91126f8f (diff)
downloadopenttd-94a5fe6b927da6e898968d240a3486dbe60d6be8.tar.xz
(svn r25437) -Codechange: rework the FreeTypeSettings structure to make it better grouped
-rw-r--r--src/fontcache.cpp26
-rw-r--r--src/fontcache.h24
-rw-r--r--src/strings.cpp6
-rw-r--r--src/table/misc_settings.ini24
-rw-r--r--src/textfile_gui.cpp2
5 files changed, 41 insertions, 41 deletions
diff --git a/src/fontcache.cpp b/src/fontcache.cpp
index 9e8ed0e1d..d764c1f75 100644
--- a/src/fontcache.cpp
+++ b/src/fontcache.cpp
@@ -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;
}
}
diff --git a/src/fontcache.h b/src/fontcache.h
index 786edf906..7c1e8a843 100644
--- a/src/fontcache.h
+++ b/src/fontcache.h
@@ -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;
diff --git a/src/strings.cpp b/src/strings.cpp
index ca7295c78..204e20687 100644
--- a/src/strings.cpp
+++ b/src/strings.cpp
@@ -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 */
}
};
diff --git a/src/table/misc_settings.ini b/src/table/misc_settings.ini
index 630e35f69..1a2b5ef6b 100644
--- a/src/table/misc_settings.ini
+++ b/src/table/misc_settings.ini
@@ -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]
diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp
index 0613df336..987fa09cd 100644
--- a/src/textfile_gui.cpp
+++ b/src/textfile_gui.cpp
@@ -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 */
}