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
|
|
|
|
|
2012-12-19 20:24:53 +03:00
|
|
|
typedef struct _TTF_Font TTF_Font;
|
|
|
|
|
|
|
|
class CTrueTypeFont : public IFont
|
|
|
|
{
|
|
|
|
const std::pair<std::unique_ptr<ui8[]>, ui64> data;
|
|
|
|
|
|
|
|
const std::unique_ptr<TTF_Font, void (*)(TTF_Font*)> font;
|
|
|
|
const bool blended;
|
|
|
|
|
|
|
|
std::pair<std::unique_ptr<ui8[]>, ui64> loadData(const JsonNode & config);
|
|
|
|
TTF_Font * loadFont(const JsonNode & config);
|
|
|
|
int getFontStyle(const JsonNode & config);
|
|
|
|
|
2013-09-08 19:49:23 +03:00
|
|
|
void renderText(SDL_Surface * surface, const std::string & data, const SDL_Color & color, const Point & pos) const override;
|
2012-12-19 20:24:53 +03:00
|
|
|
public:
|
|
|
|
CTrueTypeFont(const JsonNode & fontConfig);
|
|
|
|
|
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
|
|
|
};
|