2012-12-19 20:24:53 +03:00
|
|
|
/*
|
2023-02-01 16:42:03 +02:00
|
|
|
* CTrueTypeFont.h, part of VCMI engine
|
2012-12-19 20:24:53 +03:00
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
2017-07-13 10:26:03 +02:00
|
|
|
#pragma once
|
2012-12-19 20:24:53 +03:00
|
|
|
|
2023-02-01 20:42:06 +02:00
|
|
|
#include "../render/IFont.h"
|
2022-07-26 15:07:42 +02:00
|
|
|
|
2023-02-01 20:42:06 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
2012-12-19 20:24:53 +03:00
|
|
|
class JsonNode;
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
|
2023-04-04 21:23:32 +02:00
|
|
|
class CBitmapFont;
|
|
|
|
|
2023-04-17 23:11:16 +02:00
|
|
|
using TTF_Font = struct _TTF_Font;
|
2012-12-19 20:24:53 +03:00
|
|
|
|
|
|
|
class CTrueTypeFont : public IFont
|
|
|
|
{
|
2023-04-04 21:23:32 +02:00
|
|
|
std::unique_ptr<CBitmapFont> fallbackFont;
|
2012-12-19 20:24:53 +03:00
|
|
|
const std::pair<std::unique_ptr<ui8[]>, ui64> data;
|
|
|
|
|
|
|
|
const std::unique_ptr<TTF_Font, void (*)(TTF_Font*)> font;
|
|
|
|
const bool blended;
|
2023-04-04 21:23:32 +02:00
|
|
|
const bool dropShadow;
|
2012-12-19 20:24:53 +03:00
|
|
|
|
|
|
|
std::pair<std::unique_ptr<ui8[]>, ui64> loadData(const JsonNode & config);
|
|
|
|
TTF_Font * loadFont(const JsonNode & config);
|
|
|
|
int getFontStyle(const JsonNode & config);
|
|
|
|
|
2023-07-31 18:50:55 +02:00
|
|
|
void renderText(SDL_Surface * surface, const std::string & data, const ColorRGBA & color, const Point & pos) const override;
|
2012-12-19 20:24:53 +03:00
|
|
|
public:
|
|
|
|
CTrueTypeFont(const JsonNode & fontConfig);
|
2023-04-04 21:23:32 +02:00
|
|
|
~CTrueTypeFont();
|
2012-12-19 20:24:53 +03:00
|
|
|
|
2013-09-08 19:49:23 +03:00
|
|
|
size_t getLineHeight() const override;
|
|
|
|
size_t getGlyphWidth(const char * data) const override;
|
|
|
|
size_t getStringWidth(const std::string & data) const override;
|
2012-12-19 20:24:53 +03:00
|
|
|
};
|