<commit_before>#include "text.h"
#include "font.h"
#include "sprite.h"

#include <SDL_ttf.h>

namespace mw {

	Text::Text() : characterSize_(0) {
		setText("");
	}

	Text::Text(std::string text, const Font& font) :
	    characterSize_((float) font.getCharacterSize()), font_(font) {

		setText(text);
	}

	Text::Text(std::string text, const Font& font, float characterSize) :
	    characterSize_(characterSize), font_(font) {

	    setText(text);
	}

	void Text::setText(std::string text) {
		// Text changed?
		if (text_ != text) {
		    // Try to load the text to a new texture.
            text_ = text;
			if (!loadTextToTexture(text)) {
			    // Texture loading failed.
			    texture_ = mw::Texture();
			}
		}
	}

	bool Text::loadTextToTexture(std::string str) {
	    // Font available?
		if (font_.getTtfFont()) {
			if (str.size() > 0) {
				SDL_Color color = {255, 255, 255, 255};
				SDL_Surface* surface = TTF_RenderUTF8_Blended(font_.getTtfFont(), str.c_str(), color);
				// No error?<commit_msg>Replaced TTF_RenderUTF8_Blended with TTF_RenderUTF8_Blended_Wrapped<commit_after>#include "text.h"
#include "font.h"
#include "sprite.h"

#include <SDL_ttf.h>

namespace mw {

	Text::Text() : characterSize_(0) {
		setText("");
	}

	Text::Text(std::string text, const Font& font) :
	    characterSize_((float) font.getCharacterSize()), font_(font) {

		setText(text);
	}

	Text::Text(std::string text, const Font& font, float characterSize) :
	    characterSize_(characterSize), font_(font) {

	    setText(text);
	}

	void Text::setText(std::string text) {
		// Text changed?
		if (text_ != text) {
		    // Try to load the text to a new texture.
            text_ = text;
			if (!loadTextToTexture(text)) {
			    // Texture loading failed.
			    texture_ = mw::Texture();
			}
		}
	}

	bool Text::loadTextToTexture(std::string str) {
	    // Font available?
		if (font_.getTtfFont()) {
			if (str.size() > 0) {
				SDL_Color color = {255, 255, 255, 255};
				SDL_Surface* surface = TTF_RenderUTF8_Blended_Wrapped(font_.getTtfFont(), str.c_str(), color, 500);
				
				// No error?
{'fraction_non_alphanumeric': 0.15520534861509075, 'fraction_numerical': 0.016714422158548233, 'mean_word_length': 3.3828451882845187, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3048029', 'n_tokens_mistral': 844, 'n_tokens_neox': 725, 'n_words': 165}