FontBot/src/turnfont.cpp

29 lines
928 B
C++
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;
}