19#ifndef FOOLSENGINE_TEXTRENDER_H
20#define FOOLSENGINE_TEXTRENDER_H
22#include <SDL2/SDL_ttf.h>
45 explicit TextFont(
const std::string& fontPath, uint16_t pointSize);
77 const std::string& text,
78 glm::u8vec3 textColor,
79 glm::u8vec3 backgroundColor
91 const std::string& text,
92 glm::u8vec4 textColor,
106 const std::string& text,
107 glm::u8vec4 textColor
119 static TTF_Font*
LoadFont(
const std::string& fontPath, uint16_t pointSize);
127 static std::shared_ptr<Texture>
MakeTexture(SDL_Surface* surface);
174 inline static std::string getResourceConstructorName() {
return "fromFile"; }
176 std::shared_ptr<IResource>
createResource(
const nlohmann::json& methodParameters)
override;
ResourceConstructor(int explicitlyInitializeMe)
Definition resource_database.hpp:491
Resource(int explicitlyInitializeMe)
Definition resource_database.hpp:389
std::shared_ptr< IResource > createResource(const nlohmann::json &methodParameters) override
Creates a resource object using the parameters specified in methodParameters.
Definition text_render.cpp:27
A wrapper class over SDL_ttf, providing methods to generate text textures from text using a font as a...
Definition text_render.hpp:35
static std::string getResourceTypeName()
Gets the resource type string for this class.
Definition text_render.hpp:52
TTF_Font * mFont
A pointer to the underlying SDL_ttf font resource.
Definition text_render.hpp:133
uint16_t mPointSize
The point size with which the font was loaded.
Definition text_render.hpp:145
static TTF_Font * LoadFont(const std::string &fontPath, uint16_t pointSize)
The function responsible for actually loading the font from the path specified.
Definition text_render.cpp:20
std::string mFontPath
The path from which this font was loaded.
Definition text_render.hpp:139
std::shared_ptr< Texture > renderText(const std::string &text, glm::u8vec3 textColor, glm::u8vec3 backgroundColor) const
Uses this font to render some text against a solid background.
Definition text_render.cpp:33
std::string getFontPath() const
Gets the path of the TTF font file from which this resource was loaded.
Definition text_render.hpp:59
std::shared_ptr< Texture > renderTextArea(const std::string &text, glm::u8vec4 textColor, uint32_t wrapLength=0) const
Renders a texture for some text with a transparent background, which may run multiple lines,...
Definition text_render.cpp:72
TextFont(const std::string &fontPath, uint16_t pointSize)
Constructs a new Text Font object.
Definition text_render.cpp:7
static std::shared_ptr< Texture > MakeTexture(SDL_Surface *surface)
Utility function for converting an SDL surface into a Texture resource.
Definition text_render.cpp:93
uint16_t getPointSize() const
Gets the point size with which the font was loaded.
Definition text_render.hpp:66
Namespace containing all class definitions and functions related to the ToyMaker engine.
Definition camera_system.hpp:20
Headers relating to resources and their management for a given project.
Header containing definitions of classes and functions related to loading and using Texture resources...