2012-12-19 20:24:53 +03:00
|
|
|
/*
|
2023-02-01 16:42:03 +02:00
|
|
|
* IFont.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
|
|
|
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_BEGIN
|
2023-01-18 17:32:57 +02:00
|
|
|
class Point;
|
2023-07-31 18:50:55 +02:00
|
|
|
class ColorRGBA;
|
2022-07-26 15:07:42 +02:00
|
|
|
VCMI_LIB_NAMESPACE_END
|
|
|
|
|
2012-12-19 20:24:53 +03:00
|
|
|
struct SDL_Surface;
|
|
|
|
|
2024-08-17 22:54:29 +02:00
|
|
|
class IFont : boost::noncopyable
|
2012-12-19 20:24:53 +03:00
|
|
|
{
|
|
|
|
protected:
|
|
|
|
/// Internal function to render font, see renderTextLeft
|
2023-07-31 18:50:55 +02:00
|
|
|
virtual void renderText(SDL_Surface * surface, const std::string & data, const ColorRGBA & color, const Point & pos) const = 0;
|
2012-12-19 20:24:53 +03:00
|
|
|
|
2024-07-22 11:52:33 +02:00
|
|
|
int getScalingFactor() const;
|
|
|
|
|
2012-12-19 20:24:53 +03:00
|
|
|
public:
|
|
|
|
virtual ~IFont()
|
|
|
|
{}
|
|
|
|
|
|
|
|
/// Returns height of font
|
|
|
|
virtual size_t getLineHeight() const = 0;
|
2013-09-08 19:49:23 +03:00
|
|
|
/// Returns width, in pixels of a character glyph. Pointer must contain at least characterSize valid bytes
|
|
|
|
virtual size_t getGlyphWidth(const char * data) const = 0;
|
2012-12-19 20:24:53 +03:00
|
|
|
/// Return width of the string
|
2013-09-08 19:49:23 +03:00
|
|
|
virtual size_t getStringWidth(const std::string & data) const;
|
2012-12-19 20:24:53 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param surface - destination to print text on
|
|
|
|
* @param data - string to print
|
|
|
|
* @param color - font color
|
|
|
|
* @param pos - position of rendered font
|
|
|
|
*/
|
|
|
|
/// pos = topleft corner of the text
|
2023-07-31 18:50:55 +02:00
|
|
|
void renderTextLeft(SDL_Surface * surface, const std::string & data, const ColorRGBA & color, const Point & pos) const;
|
2012-12-19 20:24:53 +03:00
|
|
|
/// pos = center of the text
|
2023-07-31 18:50:55 +02:00
|
|
|
void renderTextRight(SDL_Surface * surface, const std::string & data, const ColorRGBA & color, const Point & pos) const;
|
2012-12-19 20:24:53 +03:00
|
|
|
/// pos = bottomright corner of the text
|
2023-07-31 18:50:55 +02:00
|
|
|
void renderTextCenter(SDL_Surface * surface, const std::string & data, const ColorRGBA & color, const Point & pos) const;
|
2012-12-19 20:24:53 +03:00
|
|
|
|
|
|
|
/// pos = topleft corner of the text
|
2023-07-31 18:50:55 +02:00
|
|
|
void renderTextLinesLeft(SDL_Surface * surface, const std::vector<std::string> & data, const ColorRGBA & color, const Point & pos) const;
|
2012-12-19 20:24:53 +03:00
|
|
|
/// pos = center of the text
|
2023-07-31 18:50:55 +02:00
|
|
|
void renderTextLinesRight(SDL_Surface * surface, const std::vector<std::string> & data, const ColorRGBA & color, const Point & pos) const;
|
2012-12-19 20:24:53 +03:00
|
|
|
/// pos = bottomright corner of the text
|
2023-07-31 18:50:55 +02:00
|
|
|
void renderTextLinesCenter(SDL_Surface * surface, const std::vector<std::string> & data, const ColorRGBA & color, const Point & pos) const;
|
2012-12-19 20:24:53 +03:00
|
|
|
};
|
|
|
|
|