FontBot/src/turnfont.cpp

29 lines
928 B
C++
Raw Normal View History

2022-01-06 14:23:11 +01:00
#include "turnfont.h"
const static std::string repl [] = {"ɐ", "q", "ɔ", "p", "ǝ", "ɟ", "ƃ", "ɥ", "ı", "ɾ", "ʞ", "ן", "ɯ", "u", "o", "d", "b", "ɹ", "s", "ʇ", "n", "ʌ", "ʍ", "x", "ʎ", "z", "", "q", "Ͻ", "", "Ǝ", "", "ƃ", "H", "I", "ſ", "ʞ", "˥", "W", "N", "O", "Ԁ", "", "", "S", "", "", "Λ", "M", "X", "ʎ", "Z"};
TurnFont::TurnFont() {}
void TurnFont::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.insert(0, repl[c - 'a']);
} else if(c >= 'A' && c <= 'Z') {
out.insert(0, repl[c - 'A' + 26]);
} else {
out.insert(0, 1, c);
}
}
}
const std::string& TurnFont::getName() const {
const static std::string NAME = "UpsideDown";
return NAME;
}
bool TurnFont::canApply(const std::string& in) const {
return true;
}