mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Expose SetFontSize in Fontcache class.
parent
9b6bd1dfe1
commit
23d1304779
|
@ -55,6 +55,11 @@ int FontCache::GetDefaultFontHeight(FontSize fs)
|
||||||
return _default_font_height[fs];
|
return _default_font_height[fs];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FontCache::SetFontSize([[maybe_unused]] int pixels)
|
||||||
|
{
|
||||||
|
Debug(fontcache, 0, "Font {} isn't resizable.", this->GetFontName());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the font name of a given font size.
|
* Get the font name of a given font size.
|
||||||
* @param fs The font size to look up.
|
* @param fs The font size to look up.
|
||||||
|
|
|
@ -65,6 +65,8 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual int GetFontSize() const { return this->height; }
|
virtual int GetFontSize() const { return this->height; }
|
||||||
|
|
||||||
|
virtual void SetFontSize([[maybe_unused]] int pixels);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Map a SpriteID to the key
|
* Map a SpriteID to the key
|
||||||
* @param key The key to map to.
|
* @param key The key to map to.
|
||||||
|
|
|
@ -32,8 +32,6 @@
|
||||||
class FreeTypeFontCache : public TrueTypeFontCache {
|
class FreeTypeFontCache : public TrueTypeFontCache {
|
||||||
private:
|
private:
|
||||||
FT_Face face; ///< The font face associated with this font.
|
FT_Face face; ///< The font face associated with this font.
|
||||||
|
|
||||||
void SetFontSize(int pixels);
|
|
||||||
const Sprite *InternalGetGlyph(GlyphID key, bool aa) override;
|
const Sprite *InternalGetGlyph(GlyphID key, bool aa) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -44,6 +42,7 @@ public:
|
||||||
std::string GetFontName() override { return fmt::format("{}, {}", face->family_name, face->style_name); }
|
std::string GetFontName() override { return fmt::format("{}, {}", face->family_name, face->style_name); }
|
||||||
bool IsBuiltInFont() override { return false; }
|
bool IsBuiltInFont() override { return false; }
|
||||||
const void *GetOSHandle() override { return &face; }
|
const void *GetOSHandle() override { return &face; }
|
||||||
|
void SetFontSize(int pixels) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
FT_Library _library = nullptr;
|
FT_Library _library = nullptr;
|
||||||
|
@ -64,6 +63,8 @@ FreeTypeFontCache::FreeTypeFontCache(FontSize fs, FT_Face face, int pixels) : Tr
|
||||||
|
|
||||||
void FreeTypeFontCache::SetFontSize(int pixels)
|
void FreeTypeFontCache::SetFontSize(int pixels)
|
||||||
{
|
{
|
||||||
|
this->req_size = pixels;
|
||||||
|
|
||||||
if (pixels == 0) {
|
if (pixels == 0) {
|
||||||
/* Try to determine a good height based on the minimal height recommended by the font. */
|
/* Try to determine a good height based on the minimal height recommended by the font. */
|
||||||
int scaled_height = ScaleGUITrad(FontCache::GetDefaultFontHeight(this->fs));
|
int scaled_height = ScaleGUITrad(FontCache::GetDefaultFontHeight(this->fs));
|
||||||
|
|
|
@ -126,6 +126,8 @@ void CoreTextFontCache::ClearFontCache()
|
||||||
|
|
||||||
void CoreTextFontCache::SetFontSize(int pixels)
|
void CoreTextFontCache::SetFontSize(int pixels)
|
||||||
{
|
{
|
||||||
|
this->req_size = pixels;
|
||||||
|
|
||||||
if (pixels == 0) {
|
if (pixels == 0) {
|
||||||
/* Try to determine a good height based on the height recommended by the font. */
|
/* Try to determine a good height based on the height recommended by the font. */
|
||||||
int scaled_height = ScaleGUITrad(FontCache::GetDefaultFontHeight(this->fs));
|
int scaled_height = ScaleGUITrad(FontCache::GetDefaultFontHeight(this->fs));
|
||||||
|
|
|
@ -121,6 +121,8 @@ Win32FontCache::~Win32FontCache()
|
||||||
|
|
||||||
void Win32FontCache::SetFontSize(int pixels)
|
void Win32FontCache::SetFontSize(int pixels)
|
||||||
{
|
{
|
||||||
|
this->req_size = pixels;
|
||||||
|
|
||||||
if (pixels == 0) {
|
if (pixels == 0) {
|
||||||
/* Try to determine a good height based on the minimal height recommended by the font. */
|
/* Try to determine a good height based on the minimal height recommended by the font. */
|
||||||
int scaled_height = ScaleGUITrad(FontCache::GetDefaultFontHeight(this->fs));
|
int scaled_height = ScaleGUITrad(FontCache::GetDefaultFontHeight(this->fs));
|
||||||
|
|
Loading…
Reference in New Issue