mirror of https://github.com/OpenTTD/OpenTTD
Merge bb6ef04d7a
into 6b6caa6fa8
commit
74d6200ba1
|
@ -2369,7 +2369,7 @@ static bool ConFont(std::span<std::string_view> argv)
|
||||||
FontCacheSubSetting *setting = GetFontCacheSubSetting(fs);
|
FontCacheSubSetting *setting = GetFontCacheSubSetting(fs);
|
||||||
/* Make sure all non sprite fonts are loaded. */
|
/* Make sure all non sprite fonts are loaded. */
|
||||||
if (!setting->font.empty() && !fc->HasParent()) {
|
if (!setting->font.empty() && !fc->HasParent()) {
|
||||||
InitFontCache(fs == FS_MONO);
|
InitFontCache(fs);
|
||||||
fc = FontCache::Get(fs);
|
fc = FontCache::Get(fs);
|
||||||
}
|
}
|
||||||
IConsolePrint(CC_DEFAULT, "{} font:", FontSizeToName(fs));
|
IConsolePrint(CC_DEFAULT, "{} font:", FontSizeToName(fs));
|
||||||
|
|
|
@ -126,10 +126,10 @@ void SetFont(FontSize fontsize, const std::string &font, uint size)
|
||||||
CheckForMissingGlyphs();
|
CheckForMissingGlyphs();
|
||||||
_fcsettings = std::move(backup);
|
_fcsettings = std::move(backup);
|
||||||
} else {
|
} else {
|
||||||
InitFontCache(true);
|
InitFontCache(fontsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadStringWidthTable(fontsize == FS_MONO);
|
LoadStringWidthTable(fontsize);
|
||||||
UpdateAllVirtCoords();
|
UpdateAllVirtCoords();
|
||||||
ReInitAllWindows(true);
|
ReInitAllWindows(true);
|
||||||
|
|
||||||
|
@ -213,15 +213,13 @@ std::string GetFontCacheFontName(FontSize fs)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* (Re)initialize the font cache related things, i.e. load the non-sprite fonts.
|
* (Re)initialize the font cache related things, i.e. load the non-sprite fonts.
|
||||||
* @param monospace Whether to initialise the monospace or regular fonts.
|
* @param fontsizes Font sizes to be initialised.
|
||||||
*/
|
*/
|
||||||
void InitFontCache(bool monospace)
|
void InitFontCache(FontSizes fontsizes)
|
||||||
{
|
{
|
||||||
FontCache::InitializeFontCaches();
|
FontCache::InitializeFontCaches();
|
||||||
|
|
||||||
for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) {
|
for (FontSize fs : fontsizes) {
|
||||||
if (monospace != (fs == FS_MONO)) continue;
|
|
||||||
|
|
||||||
FontCache *fc = FontCache::Get(fs);
|
FontCache *fc = FontCache::Get(fs);
|
||||||
if (fc->HasParent()) delete fc;
|
if (fc->HasParent()) delete fc;
|
||||||
|
|
||||||
|
|
|
@ -70,16 +70,6 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual int GetFontSize() const { return this->height; }
|
virtual int GetFontSize() const { return this->height; }
|
||||||
|
|
||||||
/**
|
|
||||||
* Map a SpriteID to the key
|
|
||||||
* @param key The key to map to.
|
|
||||||
* @param sprite The sprite that is being mapped.
|
|
||||||
*/
|
|
||||||
virtual void SetUnicodeGlyph(char32_t key, SpriteID sprite) = 0;
|
|
||||||
|
|
||||||
/** Initialize the glyph map */
|
|
||||||
virtual void InitializeUnicodeGlyphMap() = 0;
|
|
||||||
|
|
||||||
/** Clear the font cache. */
|
/** Clear the font cache. */
|
||||||
virtual void ClearFontCache() = 0;
|
virtual void ClearFontCache() = 0;
|
||||||
|
|
||||||
|
@ -153,23 +143,9 @@ public:
|
||||||
virtual bool IsBuiltInFont() = 0;
|
virtual bool IsBuiltInFont() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Map a SpriteID to the font size and key */
|
inline void ClearFontCache(FontSizes fontsizes)
|
||||||
inline void SetUnicodeGlyph(FontSize size, char32_t key, SpriteID sprite)
|
|
||||||
{
|
{
|
||||||
FontCache::Get(size)->SetUnicodeGlyph(key, sprite);
|
for (FontSize fs : fontsizes) {
|
||||||
}
|
|
||||||
|
|
||||||
/** Initialize the glyph map */
|
|
||||||
inline void InitializeUnicodeGlyphMap()
|
|
||||||
{
|
|
||||||
for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) {
|
|
||||||
FontCache::Get(fs)->InitializeUnicodeGlyphMap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void ClearFontCache()
|
|
||||||
{
|
|
||||||
for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) {
|
|
||||||
FontCache::Get(fs)->ClearFontCache();
|
FontCache::Get(fs)->ClearFontCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -231,10 +207,14 @@ inline FontCacheSubSetting *GetFontCacheSubSetting(FontSize fs)
|
||||||
|
|
||||||
uint GetFontCacheFontSize(FontSize fs);
|
uint GetFontCacheFontSize(FontSize fs);
|
||||||
std::string GetFontCacheFontName(FontSize fs);
|
std::string GetFontCacheFontName(FontSize fs);
|
||||||
void InitFontCache(bool monospace);
|
void InitFontCache(FontSizes fontsizes);
|
||||||
void UninitFontCache();
|
void UninitFontCache();
|
||||||
|
|
||||||
bool GetFontAAState();
|
bool GetFontAAState();
|
||||||
void SetFont(FontSize fontsize, const std::string &font, uint size);
|
void SetFont(FontSize fontsize, const std::string &font, uint size);
|
||||||
|
|
||||||
|
/* Implemented in spritefontcache.cpp */
|
||||||
|
void InitializeUnicodeGlyphMap();
|
||||||
|
void SetUnicodeGlyph(FontSize size, char32_t key, SpriteID sprite);
|
||||||
|
|
||||||
#endif /* FONTCACHE_H */
|
#endif /* FONTCACHE_H */
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "../stdafx.h"
|
#include "../stdafx.h"
|
||||||
#include "../fontcache.h"
|
#include "../fontcache.h"
|
||||||
#include "../gfx_layout.h"
|
#include "../gfx_layout.h"
|
||||||
|
#include "../string_func.h"
|
||||||
#include "../zoom_func.h"
|
#include "../zoom_func.h"
|
||||||
#include "spritefontcache.h"
|
#include "spritefontcache.h"
|
||||||
|
|
||||||
|
@ -31,41 +32,43 @@ static int ScaleFontTrad(int value)
|
||||||
return UnScaleByZoom(value * ZOOM_BASE, _font_zoom);
|
return UnScaleByZoom(value * ZOOM_BASE, _font_zoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
static std::array<std::unordered_map<char32_t, SpriteID>, FS_END> _char_maps{}; ///< Glyph map for each font size.
|
||||||
* Create a new sprite font cache.
|
|
||||||
* @param fs The font size to create the cache for.
|
|
||||||
*/
|
|
||||||
SpriteFontCache::SpriteFontCache(FontSize fs) : FontCache(fs)
|
|
||||||
{
|
|
||||||
this->InitializeUnicodeGlyphMap();
|
|
||||||
this->height = ScaleGUITrad(FontCache::GetDefaultFontHeight(this->fs));
|
|
||||||
this->ascender = (this->height - ScaleFontTrad(FontCache::GetDefaultFontHeight(this->fs))) / 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get SpriteID associated with a character.
|
* Get SpriteID associated with a character.
|
||||||
* @param key Character to find.
|
* @param key Character to find.
|
||||||
* @return SpriteID for character, or 0 if not present.
|
* @return SpriteID for character, or 0 if not present.
|
||||||
*/
|
*/
|
||||||
SpriteID SpriteFontCache::GetUnicodeGlyph(char32_t key)
|
static SpriteID GetUnicodeGlyph(FontSize fs, char32_t key)
|
||||||
{
|
{
|
||||||
const auto found = this->char_map.find(key);
|
auto found = _char_maps[fs].find(key);
|
||||||
if (found == std::end(this->char_map)) return 0;
|
if (found != std::end(_char_maps[fs])) return found->second;
|
||||||
return found->second;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpriteFontCache::SetUnicodeGlyph(char32_t key, SpriteID sprite)
|
/**
|
||||||
|
* Set the SpriteID for a unicode character.
|
||||||
|
* @param fs Font size to set.
|
||||||
|
* @param key Unicode character to set.
|
||||||
|
* @param sprite SpriteID of character.
|
||||||
|
*/
|
||||||
|
void SetUnicodeGlyph(FontSize fs, char32_t key, SpriteID sprite)
|
||||||
{
|
{
|
||||||
this->char_map[key] = sprite;
|
_char_maps[fs][key] = sprite;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpriteFontCache::InitializeUnicodeGlyphMap()
|
/**
|
||||||
|
* Initialize the glyph map for a font size.
|
||||||
|
* This populates the glyph map with the baseset font sprites.
|
||||||
|
* @param fs Font size to initialize.
|
||||||
|
*/
|
||||||
|
void InitializeUnicodeGlyphMap(FontSize fs)
|
||||||
{
|
{
|
||||||
/* Clear out existing glyph map if it exists */
|
/* Clear out existing glyph map if it exists */
|
||||||
this->char_map.clear();
|
_char_maps[fs].clear();
|
||||||
|
|
||||||
SpriteID base;
|
SpriteID base;
|
||||||
switch (this->fs) {
|
switch (fs) {
|
||||||
default: NOT_REACHED();
|
default: NOT_REACHED();
|
||||||
case FS_MONO: // Use normal as default for mono spaced font
|
case FS_MONO: // Use normal as default for mono spaced font
|
||||||
case FS_NORMAL: base = SPR_ASCII_SPACE; break;
|
case FS_NORMAL: base = SPR_ASCII_SPACE; break;
|
||||||
|
@ -76,24 +79,45 @@ void SpriteFontCache::InitializeUnicodeGlyphMap()
|
||||||
for (uint i = ASCII_LETTERSTART; i < 256; i++) {
|
for (uint i = ASCII_LETTERSTART; i < 256; i++) {
|
||||||
SpriteID sprite = base + i - ASCII_LETTERSTART;
|
SpriteID sprite = base + i - ASCII_LETTERSTART;
|
||||||
if (!SpriteExists(sprite)) continue;
|
if (!SpriteExists(sprite)) continue;
|
||||||
this->SetUnicodeGlyph(i, sprite);
|
SetUnicodeGlyph(fs, i, sprite);
|
||||||
this->SetUnicodeGlyph(i + SCC_SPRITE_START, sprite);
|
SetUnicodeGlyph(fs, i + SCC_SPRITE_START, sprite);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Modify map to move non-standard glyphs to a better unicode codepoint. */
|
||||||
for (const auto &unicode_map : _default_unicode_map) {
|
for (const auto &unicode_map : _default_unicode_map) {
|
||||||
uint8_t key = unicode_map.key;
|
uint8_t key = unicode_map.key;
|
||||||
if (key == CLRA) {
|
if (key == CLRA) {
|
||||||
/* Clear the glyph. This happens if the glyph at this code point
|
/* Clear the glyph. This happens if the glyph at this code point
|
||||||
* is non-standard and should be accessed by an SCC_xxx enum
|
* is non-standard and should be accessed by an SCC_xxx enum
|
||||||
* entry only. */
|
* entry only. */
|
||||||
this->SetUnicodeGlyph(unicode_map.code, 0);
|
SetUnicodeGlyph(fs, unicode_map.code, 0);
|
||||||
} else {
|
} else {
|
||||||
SpriteID sprite = base + key - ASCII_LETTERSTART;
|
SpriteID sprite = base + key - ASCII_LETTERSTART;
|
||||||
this->SetUnicodeGlyph(unicode_map.code, sprite);
|
SetUnicodeGlyph(fs, unicode_map.code, sprite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initialize the glyph map.
|
||||||
|
*/
|
||||||
|
void InitializeUnicodeGlyphMap()
|
||||||
|
{
|
||||||
|
for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) {
|
||||||
|
InitializeUnicodeGlyphMap(fs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new sprite font cache.
|
||||||
|
* @param fs The font size to create the cache for.
|
||||||
|
*/
|
||||||
|
SpriteFontCache::SpriteFontCache(FontSize fs) : FontCache(fs)
|
||||||
|
{
|
||||||
|
this->height = ScaleGUITrad(FontCache::GetDefaultFontHeight(this->fs));
|
||||||
|
this->ascender = (this->height - ScaleFontTrad(FontCache::GetDefaultFontHeight(this->fs))) / 2;
|
||||||
|
}
|
||||||
|
|
||||||
void SpriteFontCache::ClearFontCache()
|
void SpriteFontCache::ClearFontCache()
|
||||||
{
|
{
|
||||||
Layouter::ResetFontCache(this->fs);
|
Layouter::ResetFontCache(this->fs);
|
||||||
|
@ -104,21 +128,21 @@ void SpriteFontCache::ClearFontCache()
|
||||||
const Sprite *SpriteFontCache::GetGlyph(GlyphID key)
|
const Sprite *SpriteFontCache::GetGlyph(GlyphID key)
|
||||||
{
|
{
|
||||||
SpriteID sprite = static_cast<SpriteID>(key & ~SPRITE_GLYPH);
|
SpriteID sprite = static_cast<SpriteID>(key & ~SPRITE_GLYPH);
|
||||||
if (sprite == 0) sprite = this->GetUnicodeGlyph('?');
|
if (sprite == 0) sprite = GetUnicodeGlyph(this->fs, '?');
|
||||||
return GetSprite(sprite, SpriteType::Font);
|
return GetSprite(sprite, SpriteType::Font);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint SpriteFontCache::GetGlyphWidth(GlyphID key)
|
uint SpriteFontCache::GetGlyphWidth(GlyphID key)
|
||||||
{
|
{
|
||||||
SpriteID sprite = static_cast<SpriteID>(key & ~SPRITE_GLYPH);
|
SpriteID sprite = static_cast<SpriteID>(key & ~SPRITE_GLYPH);
|
||||||
if (sprite == 0) sprite = this->GetUnicodeGlyph('?');
|
if (sprite == 0) sprite = GetUnicodeGlyph(this->fs, '?');
|
||||||
return SpriteExists(sprite) ? GetSprite(sprite, SpriteType::Font)->width + ScaleFontTrad(this->fs != FS_NORMAL ? 1 : 0) : 0;
|
return SpriteExists(sprite) ? GetSprite(sprite, SpriteType::Font)->width + ScaleFontTrad(this->fs != FS_NORMAL ? 1 : 0) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
GlyphID SpriteFontCache::MapCharToGlyph(char32_t key, [[maybe_unused]] bool allow_fallback)
|
GlyphID SpriteFontCache::MapCharToGlyph(char32_t key, [[maybe_unused]] bool allow_fallback)
|
||||||
{
|
{
|
||||||
assert(IsPrintable(key));
|
assert(IsPrintable(key));
|
||||||
SpriteID sprite = this->GetUnicodeGlyph(key);
|
SpriteID sprite = GetUnicodeGlyph(this->fs, key);
|
||||||
if (sprite == 0) return 0;
|
if (sprite == 0) return 0;
|
||||||
return SPRITE_GLYPH | sprite;
|
return SPRITE_GLYPH | sprite;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,15 +10,12 @@
|
||||||
#ifndef SPRITEFONTCACHE_H
|
#ifndef SPRITEFONTCACHE_H
|
||||||
#define SPRITEFONTCACHE_H
|
#define SPRITEFONTCACHE_H
|
||||||
|
|
||||||
#include "../string_func.h"
|
|
||||||
#include "../fontcache.h"
|
#include "../fontcache.h"
|
||||||
|
|
||||||
/** Font cache for fonts that are based on a freetype font. */
|
/** Font cache for fonts that are based on a freetype font. */
|
||||||
class SpriteFontCache : public FontCache {
|
class SpriteFontCache : public FontCache {
|
||||||
public:
|
public:
|
||||||
SpriteFontCache(FontSize fs);
|
SpriteFontCache(FontSize fs);
|
||||||
void SetUnicodeGlyph(char32_t key, SpriteID sprite) override;
|
|
||||||
void InitializeUnicodeGlyphMap() override;
|
|
||||||
void ClearFontCache() override;
|
void ClearFontCache() override;
|
||||||
const Sprite *GetGlyph(GlyphID key) override;
|
const Sprite *GetGlyph(GlyphID key) override;
|
||||||
uint GetGlyphWidth(GlyphID key) override;
|
uint GetGlyphWidth(GlyphID key) override;
|
||||||
|
@ -26,10 +23,6 @@ public:
|
||||||
GlyphID MapCharToGlyph(char32_t key, bool allow_fallback = true) override;
|
GlyphID MapCharToGlyph(char32_t key, bool allow_fallback = true) override;
|
||||||
std::string GetFontName() override { return "sprite"; }
|
std::string GetFontName() override { return "sprite"; }
|
||||||
bool IsBuiltInFont() override { return true; }
|
bool IsBuiltInFont() override { return true; }
|
||||||
|
|
||||||
private:
|
|
||||||
std::unordered_map<char32_t, SpriteID> char_map{}; ///< Mapping of characters to sprite IDs.
|
|
||||||
SpriteID GetUnicodeGlyph(char32_t key);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SPRITEFONTCACHE_H */
|
#endif /* SPRITEFONTCACHE_H */
|
||||||
|
|
|
@ -46,8 +46,6 @@ public:
|
||||||
TrueTypeFontCache(FontSize fs, int pixels);
|
TrueTypeFontCache(FontSize fs, int pixels);
|
||||||
virtual ~TrueTypeFontCache();
|
virtual ~TrueTypeFontCache();
|
||||||
int GetFontSize() const override { return this->used_size; }
|
int GetFontSize() const override { return this->used_size; }
|
||||||
void SetUnicodeGlyph(char32_t key, SpriteID sprite) override { this->parent->SetUnicodeGlyph(key, sprite); }
|
|
||||||
void InitializeUnicodeGlyphMap() override { this->parent->InitializeUnicodeGlyphMap(); }
|
|
||||||
const Sprite *GetGlyph(GlyphID key) override;
|
const Sprite *GetGlyph(GlyphID key) override;
|
||||||
void ClearFontCache() override;
|
void ClearFontCache() override;
|
||||||
uint GetGlyphWidth(GlyphID key) override;
|
uint GetGlyphWidth(GlyphID key) override;
|
||||||
|
|
13
src/gfx.cpp
13
src/gfx.cpp
|
@ -8,6 +8,7 @@
|
||||||
/** @file gfx.cpp Handling of drawing text and other gfx related stuff. */
|
/** @file gfx.cpp Handling of drawing text and other gfx related stuff. */
|
||||||
|
|
||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
|
#include "gfx_func.h"
|
||||||
#include "gfx_layout.h"
|
#include "gfx_layout.h"
|
||||||
#include "progress.h"
|
#include "progress.h"
|
||||||
#include "zoom_func.h"
|
#include "zoom_func.h"
|
||||||
|
@ -1240,14 +1241,14 @@ static void GfxMainBlitter(const Sprite *sprite, int x, int y, BlitterMode mode,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize _stringwidth_table cache
|
* Initialize _stringwidth_table cache for the specified font sizes.
|
||||||
* @param monospace Whether to load the monospace cache or the normal fonts.
|
* @param fontsizes Font sizes to initialise.
|
||||||
*/
|
*/
|
||||||
void LoadStringWidthTable(bool monospace)
|
void LoadStringWidthTable(FontSizes fontsizes)
|
||||||
{
|
{
|
||||||
ClearFontCache();
|
ClearFontCache(fontsizes);
|
||||||
|
|
||||||
for (FontSize fs = monospace ? FS_MONO : FS_BEGIN; fs < (monospace ? FS_END : FS_MONO); fs++) {
|
for (FontSize fs : fontsizes) {
|
||||||
for (uint i = 0; i != 224; i++) {
|
for (uint i = 0; i != 224; i++) {
|
||||||
_stringwidth_table[fs][i] = GetGlyphWidth(fs, i + 32);
|
_stringwidth_table[fs][i] = GetGlyphWidth(fs, i + 32);
|
||||||
}
|
}
|
||||||
|
@ -1812,7 +1813,7 @@ bool AdjustGUIZoom(bool automatic)
|
||||||
if (old_font_zoom != _font_zoom) {
|
if (old_font_zoom != _font_zoom) {
|
||||||
GfxClearFontSpriteCache();
|
GfxClearFontSpriteCache();
|
||||||
}
|
}
|
||||||
ClearFontCache();
|
ClearFontCache(FONTSIZES_ALL);
|
||||||
LoadStringWidthTable();
|
LoadStringWidthTable();
|
||||||
|
|
||||||
SetupWidgetDimensions();
|
SetupWidgetDimensions();
|
||||||
|
|
|
@ -149,7 +149,7 @@ int GetStringHeight(StringID str, int maxw);
|
||||||
int GetStringLineCount(std::string_view str, int maxw);
|
int GetStringLineCount(std::string_view str, int maxw);
|
||||||
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion);
|
Dimension GetStringMultiLineBoundingBox(StringID str, const Dimension &suggestion);
|
||||||
Dimension GetStringMultiLineBoundingBox(std::string_view str, const Dimension &suggestion, FontSize fontsize = FS_NORMAL);
|
Dimension GetStringMultiLineBoundingBox(std::string_view str, const Dimension &suggestion, FontSize fontsize = FS_NORMAL);
|
||||||
void LoadStringWidthTable(bool monospace = false);
|
void LoadStringWidthTable(FontSizes fontsizes = FONTSIZES_REQUIRED);
|
||||||
|
|
||||||
void DrawDirtyBlocks();
|
void DrawDirtyBlocks();
|
||||||
void AddDirtyBlock(int left, int top, int right, int bottom);
|
void AddDirtyBlock(int left, int top, int right, int bottom);
|
||||||
|
|
|
@ -258,6 +258,13 @@ enum FontSize : uint8_t {
|
||||||
};
|
};
|
||||||
DECLARE_INCREMENT_DECREMENT_OPERATORS(FontSize)
|
DECLARE_INCREMENT_DECREMENT_OPERATORS(FontSize)
|
||||||
|
|
||||||
|
using FontSizes = EnumBitSet<FontSize, uint8_t>;
|
||||||
|
|
||||||
|
/** Mask of all possible font sizes. */
|
||||||
|
constexpr FontSizes FONTSIZES_ALL{FS_NORMAL, FS_SMALL, FS_LARGE, FS_MONO};
|
||||||
|
/** Mask of font sizes required to be present. */
|
||||||
|
constexpr FontSizes FONTSIZES_REQUIRED{FS_NORMAL, FS_SMALL, FS_LARGE};
|
||||||
|
|
||||||
inline std::string_view FontSizeToName(FontSize fs)
|
inline std::string_view FontSizeToName(FontSize fs)
|
||||||
{
|
{
|
||||||
static const std::string_view SIZE_TO_NAME[] = { "medium", "small", "large", "mono" };
|
static const std::string_view SIZE_TO_NAME[] = { "medium", "small", "large", "mono" };
|
||||||
|
|
|
@ -245,7 +245,7 @@ static void RealChangeBlitter(std::string_view repl_blitter)
|
||||||
|
|
||||||
/* Clear caches that might have sprites for another blitter. */
|
/* Clear caches that might have sprites for another blitter. */
|
||||||
VideoDriver::GetInstance()->ClearSystemSprites();
|
VideoDriver::GetInstance()->ClearSystemSprites();
|
||||||
ClearFontCache();
|
ClearFontCache(FONTSIZES_ALL);
|
||||||
GfxClearSpriteCache();
|
GfxClearSpriteCache();
|
||||||
ReInitAllWindows(false);
|
ReInitAllWindows(false);
|
||||||
}
|
}
|
||||||
|
@ -326,7 +326,7 @@ void CheckBlitter()
|
||||||
{
|
{
|
||||||
if (!SwitchNewGRFBlitter()) return;
|
if (!SwitchNewGRFBlitter()) return;
|
||||||
|
|
||||||
ClearFontCache();
|
ClearFontCache(FONTSIZES_ALL);
|
||||||
GfxClearSpriteCache();
|
GfxClearSpriteCache();
|
||||||
ReInitAllWindows(false);
|
ReInitAllWindows(false);
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ void GfxLoadSprites()
|
||||||
|
|
||||||
SwitchNewGRFBlitter();
|
SwitchNewGRFBlitter();
|
||||||
VideoDriver::GetInstance()->ClearSystemSprites();
|
VideoDriver::GetInstance()->ClearSystemSprites();
|
||||||
ClearFontCache();
|
ClearFontCache(FONTSIZES_ALL);
|
||||||
GfxInitSpriteMem();
|
GfxInitSpriteMem();
|
||||||
LoadSpriteTables();
|
LoadSpriteTables();
|
||||||
GfxInitPalettes();
|
GfxInitPalettes();
|
||||||
|
|
|
@ -700,7 +700,7 @@ int openttd_main(std::span<std::string_view> arguments)
|
||||||
InitializeLanguagePacks();
|
InitializeLanguagePacks();
|
||||||
|
|
||||||
/* Initialize the font cache */
|
/* Initialize the font cache */
|
||||||
InitFontCache(false);
|
InitFontCache(FONTSIZES_REQUIRED);
|
||||||
|
|
||||||
/* This must be done early, since functions use the SetWindowDirty* calls */
|
/* This must be done early, since functions use the SetWindowDirty* calls */
|
||||||
InitWindowSystem();
|
InitWindowSystem();
|
||||||
|
|
|
@ -182,6 +182,6 @@ bool SetFallbackFont(FontCacheSettings *settings, const std::string &language_is
|
||||||
if (best_font == nullptr) return false;
|
if (best_font == nullptr) return false;
|
||||||
|
|
||||||
callback->SetFontNames(settings, best_font, &best_index);
|
callback->SetFontNames(settings, best_font, &best_index);
|
||||||
InitFontCache(callback->Monospace());
|
InitFontCache(callback->Monospace() ? FontSizes{FS_MONO} : FONTSIZES_REQUIRED);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1036,9 +1036,8 @@ struct GameOptionsWindow : Window {
|
||||||
this->SetWidgetDisabledState(WID_GO_GUI_FONT_AA, _fcsettings.prefer_sprite);
|
this->SetWidgetDisabledState(WID_GO_GUI_FONT_AA, _fcsettings.prefer_sprite);
|
||||||
this->SetDirty();
|
this->SetDirty();
|
||||||
|
|
||||||
InitFontCache(false);
|
InitFontCache(FONTSIZES_ALL);
|
||||||
InitFontCache(true);
|
ClearFontCache(FONTSIZES_ALL);
|
||||||
ClearFontCache();
|
|
||||||
CheckForMissingGlyphs();
|
CheckForMissingGlyphs();
|
||||||
SetupWidgetDimensions();
|
SetupWidgetDimensions();
|
||||||
UpdateAllVirtCoords();
|
UpdateAllVirtCoords();
|
||||||
|
@ -1051,7 +1050,7 @@ struct GameOptionsWindow : Window {
|
||||||
this->SetWidgetLoweredState(WID_GO_GUI_FONT_AA, _fcsettings.global_aa);
|
this->SetWidgetLoweredState(WID_GO_GUI_FONT_AA, _fcsettings.global_aa);
|
||||||
MarkWholeScreenDirty();
|
MarkWholeScreenDirty();
|
||||||
|
|
||||||
ClearFontCache();
|
ClearFontCache(FONTSIZES_ALL);
|
||||||
break;
|
break;
|
||||||
#endif /* HAS_TRUETYPE_FONT */
|
#endif /* HAS_TRUETYPE_FONT */
|
||||||
|
|
||||||
|
|
|
@ -2278,7 +2278,7 @@ std::string_view GetCurrentLanguageIsoCode()
|
||||||
*/
|
*/
|
||||||
bool MissingGlyphSearcher::FindMissingGlyphs()
|
bool MissingGlyphSearcher::FindMissingGlyphs()
|
||||||
{
|
{
|
||||||
InitFontCache(this->Monospace());
|
InitFontCache(this->Monospace() ? FontSizes{FS_MONO} : FONTSIZES_REQUIRED);
|
||||||
|
|
||||||
this->Reset();
|
this->Reset();
|
||||||
for (auto text = this->NextString(); text.has_value(); text = this->NextString()) {
|
for (auto text = this->NextString(); text.has_value(); text = this->NextString()) {
|
||||||
|
@ -2395,7 +2395,7 @@ void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher)
|
||||||
/* Our fallback font does miss characters too, so keep the
|
/* Our fallback font does miss characters too, so keep the
|
||||||
* user chosen font as that is more likely to be any good than
|
* user chosen font as that is more likely to be any good than
|
||||||
* the wild guess we made */
|
* the wild guess we made */
|
||||||
InitFontCache(searcher->Monospace());
|
InitFontCache(searcher->Monospace() ? FontSizes{FS_MONO} : FONTSIZES_REQUIRED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -2412,12 +2412,12 @@ void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher)
|
||||||
ShowErrorMessage(GetEncodedString(STR_JUST_RAW_STRING, std::move(err_str)), {}, WL_WARNING);
|
ShowErrorMessage(GetEncodedString(STR_JUST_RAW_STRING, std::move(err_str)), {}, WL_WARNING);
|
||||||
|
|
||||||
/* Reset the font width */
|
/* Reset the font width */
|
||||||
LoadStringWidthTable(searcher->Monospace());
|
LoadStringWidthTable(searcher->Monospace() ? FontSizes{FS_MONO} : FONTSIZES_REQUIRED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Update the font with cache */
|
/* Update the font with cache */
|
||||||
LoadStringWidthTable(searcher->Monospace());
|
LoadStringWidthTable(searcher->Monospace() ? FontSizes{FS_MONO} : FONTSIZES_REQUIRED);
|
||||||
|
|
||||||
#if !(defined(WITH_ICU_I18N) && defined(WITH_HARFBUZZ)) && !defined(WITH_UNISCRIBE) && !defined(WITH_COCOA)
|
#if !(defined(WITH_ICU_I18N) && defined(WITH_HARFBUZZ)) && !defined(WITH_UNISCRIBE) && !defined(WITH_COCOA)
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -21,8 +21,6 @@ public:
|
||||||
this->height = FontCache::GetDefaultFontHeight(this->fs);
|
this->height = FontCache::GetDefaultFontHeight(this->fs);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetUnicodeGlyph(char32_t, SpriteID) override {}
|
|
||||||
void InitializeUnicodeGlyphMap() override {}
|
|
||||||
void ClearFontCache() override {}
|
void ClearFontCache() override {}
|
||||||
const Sprite *GetGlyph(GlyphID) override { return nullptr; }
|
const Sprite *GetGlyph(GlyphID) override { return nullptr; }
|
||||||
uint GetGlyphWidth(GlyphID) override { return this->height / 2; }
|
uint GetGlyphWidth(GlyphID) override { return this->height / 2; }
|
||||||
|
|
Loading…
Reference in New Issue