#include "replacefont.h"

ReplaceFont::ReplaceFont(const std::string& name, const std::string* repl) : name(name), repl(repl) {}

void ReplaceFont::applyFont(const std::string& in, std::string& out) const {
	out.reserve(in.size()*2);

	for(size_t pos_in = 0; pos_in < in.size(); ++pos_in) {
		char c = in[pos_in];
		if(c >= 'a' && c <= 'z') {
			out += repl[c - 'a'];
		} else if(c >= 'A' && c <= 'Z') {
			out += repl[c - 'A' + 26];
		} else {
			out += c;
		}
	}
}

const std::string& ReplaceFont::getName() const {
	return name;
}

bool ReplaceFont::canApply(const std::string& in) const {
	return true;
}