2012-12-19 20:24:53 +03:00
|
|
|
/*
|
2023-02-01 16:42:03 +02:00
|
|
|
* CBitmapHanFont.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
|
|
|
|
|
2013-09-08 19:49:23 +03:00
|
|
|
class CBitmapFont;
|
|
|
|
|
|
|
|
/// supports multi-byte characters for such languages like Chinese
|
|
|
|
class CBitmapHanFont : public IFont
|
|
|
|
{
|
2013-10-21 00:53:27 +03:00
|
|
|
std::unique_ptr<CBitmapFont> fallback;
|
2013-09-08 19:49:23 +03:00
|
|
|
// data, directly copied from file
|
|
|
|
const std::pair<std::unique_ptr<ui8[]>, ui64> data;
|
|
|
|
|
|
|
|
// size of the font. Not available in file but needed for proper rendering
|
|
|
|
const size_t size;
|
|
|
|
|
|
|
|
size_t getCharacterDataOffset(size_t index) const;
|
|
|
|
size_t getCharacterIndex(ui8 first, ui8 second) const;
|
|
|
|
|
2023-07-31 18:50:55 +02:00
|
|
|
void renderCharacter(SDL_Surface * surface, int characterIndex, const ColorRGBA & color, int &posX, int &posY) const;
|
|
|
|
void renderText(SDL_Surface * surface, const std::string & data, const ColorRGBA & color, const Point & pos) const override;
|
2013-09-08 19:49:23 +03:00
|
|
|
public:
|
|
|
|
CBitmapHanFont(const JsonNode & config);
|
|
|
|
|
|
|
|
size_t getLineHeight() const override;
|
|
|
|
size_t getGlyphWidth(const char * data) const override;
|
2012-12-19 20:24:53 +03:00
|
|
|
};
|