mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: Return fontcache font name as std::string.
This commit is contained in:
parent
532007737e
commit
3ae1a80576
|
@ -132,7 +132,7 @@ public:
|
||||||
* Get the name of this font.
|
* Get the name of this font.
|
||||||
* @return The name of the font.
|
* @return The name of the font.
|
||||||
*/
|
*/
|
||||||
virtual const char *GetFontName() = 0;
|
virtual std::string GetFontName() = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the font cache of a given font size.
|
* Get the font cache of a given font size.
|
||||||
|
|
|
@ -33,16 +33,16 @@ private:
|
||||||
FT_Face face; ///< The font face associated with this font.
|
FT_Face face; ///< The font face associated with this font.
|
||||||
|
|
||||||
void SetFontSize(FontSize fs, FT_Face face, int pixels);
|
void SetFontSize(FontSize fs, FT_Face face, int pixels);
|
||||||
virtual const void *InternalGetFontTable(uint32 tag, size_t &length);
|
const void *InternalGetFontTable(uint32 tag, size_t &length) override;
|
||||||
virtual const Sprite *InternalGetGlyph(GlyphID key, bool aa);
|
const Sprite *InternalGetGlyph(GlyphID key, bool aa) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
FreeTypeFontCache(FontSize fs, FT_Face face, int pixels);
|
FreeTypeFontCache(FontSize fs, FT_Face face, int pixels);
|
||||||
~FreeTypeFontCache();
|
~FreeTypeFontCache();
|
||||||
virtual void ClearFontCache();
|
void ClearFontCache() override;
|
||||||
virtual GlyphID MapCharToGlyph(WChar key);
|
GlyphID MapCharToGlyph(WChar key) override;
|
||||||
virtual const char *GetFontName() { return face->family_name; }
|
std::string GetFontName() override { return face->family_name; }
|
||||||
virtual bool IsBuiltInFont() { return false; }
|
bool IsBuiltInFont() override { return false; }
|
||||||
};
|
};
|
||||||
|
|
||||||
FT_Library _library = nullptr;
|
FT_Library _library = nullptr;
|
||||||
|
|
|
@ -31,7 +31,7 @@ public:
|
||||||
virtual bool GetDrawGlyphShadow();
|
virtual bool GetDrawGlyphShadow();
|
||||||
virtual GlyphID MapCharToGlyph(WChar key) { assert(IsPrintable(key)); return SPRITE_GLYPH | key; }
|
virtual GlyphID MapCharToGlyph(WChar key) { assert(IsPrintable(key)); return SPRITE_GLYPH | key; }
|
||||||
virtual const void *GetFontTable(uint32 tag, size_t &length) { length = 0; return nullptr; }
|
virtual const void *GetFontTable(uint32 tag, size_t &length) { length = 0; return nullptr; }
|
||||||
virtual const char *GetFontName() { return "sprite"; }
|
virtual std::string GetFontName() { return "sprite"; }
|
||||||
virtual bool IsBuiltInFont() { return true; }
|
virtual bool IsBuiltInFont() { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ public:
|
||||||
|
|
||||||
void ClearFontCache() override;
|
void ClearFontCache() override;
|
||||||
GlyphID MapCharToGlyph(WChar key) override;
|
GlyphID MapCharToGlyph(WChar key) override;
|
||||||
const char *GetFontName() override { return font_name.c_str(); }
|
std::string GetFontName() override { return font_name; }
|
||||||
bool IsBuiltInFont() override { return false; }
|
bool IsBuiltInFont() override { return false; }
|
||||||
const void *GetOSHandle() override { return font.get(); }
|
const void *GetOSHandle() override { return font.get(); }
|
||||||
};
|
};
|
||||||
|
|
|
@ -180,7 +180,7 @@ static CTRunDelegateCallbacks _sprite_font_callback = {
|
||||||
if (font == nullptr) {
|
if (font == nullptr) {
|
||||||
if (!_font_cache[i.second->fc->GetSize()]) {
|
if (!_font_cache[i.second->fc->GetSize()]) {
|
||||||
/* Cache font information. */
|
/* Cache font information. */
|
||||||
CFAutoRelease<CFStringRef> font_name(CFStringCreateWithCString(kCFAllocatorDefault, i.second->fc->GetFontName(), kCFStringEncodingUTF8));
|
CFAutoRelease<CFStringRef> font_name(CFStringCreateWithCString(kCFAllocatorDefault, i.second->fc->GetFontName().c_str(), kCFStringEncodingUTF8));
|
||||||
_font_cache[i.second->fc->GetSize()].reset(CTFontCreateWithName(font_name.get(), i.second->fc->GetFontSize(), nullptr));
|
_font_cache[i.second->fc->GetSize()].reset(CTFontCreateWithName(font_name.get(), i.second->fc->GetFontSize(), nullptr));
|
||||||
}
|
}
|
||||||
font = _font_cache[i.second->fc->GetSize()].get();
|
font = _font_cache[i.second->fc->GetSize()].get();
|
||||||
|
|
|
@ -34,7 +34,7 @@ public:
|
||||||
~Win32FontCache();
|
~Win32FontCache();
|
||||||
void ClearFontCache() override;
|
void ClearFontCache() override;
|
||||||
GlyphID MapCharToGlyph(WChar key) override;
|
GlyphID MapCharToGlyph(WChar key) override;
|
||||||
const char *GetFontName() override { return this->fontname.c_str(); }
|
std::string GetFontName() override { return this->fontname; }
|
||||||
const void *GetOSHandle() override { return &this->logfont; }
|
const void *GetOSHandle() override { return &this->logfont; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -152,7 +152,7 @@ static HFONT HFontFromFont(Font *font)
|
||||||
logfont.lfHeight = font->fc->GetHeight();
|
logfont.lfHeight = font->fc->GetHeight();
|
||||||
logfont.lfWeight = FW_NORMAL;
|
logfont.lfWeight = FW_NORMAL;
|
||||||
logfont.lfCharSet = DEFAULT_CHARSET;
|
logfont.lfCharSet = DEFAULT_CHARSET;
|
||||||
convert_to_fs(font->fc->GetFontName(), logfont.lfFaceName, lengthof(logfont.lfFaceName));
|
convert_to_fs(font->fc->GetFontName().c_str(), logfont.lfFaceName, lengthof(logfont.lfFaceName));
|
||||||
|
|
||||||
return CreateFontIndirect(&logfont);
|
return CreateFontIndirect(&logfont);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue