24 PRETTY_INFO <<
"The font " << _fontName <<
" is loaded and ready to use." << std::endl;
32 PRETTY_INFO <<
"The font " << _fontName <<
" is loaded and ready to use." << std::endl;
41 PRETTY_INFO <<
"The font " << _fontName <<
" is loaded and ready to use." << std::endl;
51 PRETTY_INFO <<
"The font " << _fontName <<
" is loaded and ready to use." << std::endl;
54GUI::ECS::Systems::Font::Font(
const std::string &name,
const std::string &path,
const unsigned int size,
const std::string &application,
const bool bold)
62 PRETTY_INFO <<
"The font " << _fontName <<
" is loaded and ready to use." << std::endl;
65GUI::ECS::Systems::Font::Font(
const std::string &name,
const std::string &path,
const unsigned int size,
const std::string &application,
const bool bold,
const bool italic)
74 PRETTY_INFO <<
"The font " << _fontName <<
" is loaded and ready to use." << std::endl;
82 PRETTY_INFO <<
"The font " << _fontName <<
" is loaded and ready to use." << std::endl;
91 PRETTY_INFO <<
"The font " << _fontName <<
" is loaded and ready to use." << std::endl;
94GUI::ECS::Systems::Font::Font(
const std::uint32_t entityId,
const std::string &name,
const std::string &path,
const unsigned int size,
const std::string &application)
101 PRETTY_INFO <<
"The font " << _fontName <<
" is loaded and ready to use." << std::endl;
104GUI::ECS::Systems::Font::Font(
const std::uint32_t entityId,
const std::string &name,
const std::string &path,
const unsigned int size,
const std::string &application,
const bool bold)
112 PRETTY_INFO <<
"The font " << _fontName <<
" is loaded and ready to use." << std::endl;
115GUI::ECS::Systems::Font::Font(
const std::uint32_t entityId,
const std::string &name,
const std::string &path,
const unsigned int size,
const std::string &application,
const bool bold,
const bool italic)
124 PRETTY_INFO <<
"The font " << _fontName <<
" is loaded and ready to use." << std::endl;
146 _fontInstanceSet =
false;
147 PRETTY_DEBUG <<
"Creating a font instance" << std::endl;
148 std::shared_ptr<sf::Font> node = std::make_shared<sf::Font>();
150 const bool response = node->openFromFile(path);
154 <<
"Error: Failed to load font from " << _fontPath << std::endl;
160 _fontInstance = node;
162 _fontInstanceSet =
true;
167 _fontDefaultSize = size;
172 _fontApplication = application;
197 return _fontApplication;
202 return _fontDefaultSize;
207 if (!_fontInstanceSet) {
211 std::any node = std::make_any<std::shared_ptr<sf::Font>>(_fontInstance);
212 if (!node.has_value()) {
223 std::string indentation =
"";
224 for (
unsigned int i = 0; i < indent; ++i) {
227 std::string result = indentation +
"Font:\n";
231 result += indentation +
"- Font Name: '" + _fontName +
"'\n";
232 result += indentation +
"- Font Path: '" + _fontPath +
"'\n";
233 result += indentation +
"- Font instance set: " +
Recoded::myToString(_fontInstanceSet) +
"\n";
234 result += indentation +
"- Font Application: '" + _fontApplication +
"'\n";
242 if (!systemFont.has_value()) {
244 <<
"No font found." << std::endl;
247 const std::string errMsg =
"<There is no sf::Font instance to manipulate>, system error: ";
249 if (!fontCapsule.has_value()) {
252 const std::shared_ptr<sf::Font> font = fontCapsule.value();
253 _fontInstance = font;
254 _fontInstanceSet =
true;
265 return _fontInstanceSet;
Header file for the Font class, responsible for managing fonts within the program.
#define PRECISE_DEBUG
Debug log with precise details.
#define PRETTY_DEBUG
Debug log with details and colour.
#define PRETTY_INFO
Info log with details and colour.
#define PRETTY_CRITICAL
Critical log with details and colour.
#define PRETTY_SUCCESS
Success log with details and colour.
This is the class in charge of informing the user that the height they entered is invalid.
This is the class in charge of informing the user that they tried to access a non-existant font insta...
Manages font entities in the GUI ECS.
const std::any getFontInstance() const
Retrieves the font instance.
void setFontPath(const std::string &path)
Sets the file path of the font and loads it.
const bool isItalic() const
Checks if the font is italic.
Font()
Default constructor.
void setFontApplication(const std::string application)
Sets the application or context for the font.
void update(const GUI::ECS::Systems::Font ©)
Updates the font with properties from another font.
const bool isLoaded() const
Checks if the font instance is loaded.
const std::string getApplication() const
Retrieves the application context of the font.
void setFontName(const std::string &name)
Sets the font name.
const std::string getFontPath() const
Retrieves the file path of the font.
const std::string getFontName() const
Retrieves the font name.
GUI::ECS::Systems::Font & operator=(const GUI::ECS::Systems::Font ©)
Assignment operator.
void setItalic(const bool italic)
Sets the italic property of the font.
const unsigned int getDefaultSize() const
Retrieves the default size of the font.
const std::string getInfo(const unsigned int indent=0) const
This is a function meant for debugging purposes It will dump the current state of the variables upon ...
const bool isBold() const
Checks if the font is bold.
void setBold(const bool bold)
Sets the bold property of the font.
void setFontDefaultSize(const unsigned int size)
Sets the default size of the font.
std::ostream & operator<<(std::ostream &os, const Clock &item)
Outputs the clock's info to a stream.
const std::string myToString(const Rect< RectType > &rectangle)
Converts a Rect<T> object to its string representation.
std::optional< T > unCast(const std::any &classNode, const bool raiseOnError=true, const std::string customErrorMessage="")
Casts the content of a std::any back to its original type.